diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-01 15:32:17 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-01 15:32:17 +0100 |
commit | 4c05fa08c9739e307ddc88ac91ba6d208f1fd68e (patch) | |
tree | 20372efd4201512b7d8035734795b2e351e29833 /runtime/autoload | |
parent | 6d5b4f566a2a50c1de7300336e9e4f5e761500a8 (diff) | |
download | vim-git-4c05fa08c9739e307ddc88ac91ba6d208f1fd68e.tar.gz |
Update runtime files
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/RstFold.vim | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/runtime/autoload/RstFold.vim b/runtime/autoload/RstFold.vim index 5becb0468..238b1e353 100644 --- a/runtime/autoload/RstFold.vim +++ b/runtime/autoload/RstFold.vim @@ -1,8 +1,12 @@ " Author: Antony Lee <anntzer.lee@gmail.com> " Description: Helper functions for reStructuredText syntax folding -" Last Modified: 2018-01-07 +" Last Modified: 2018-12-29 function s:CacheRstFold() + if !g:rst_fold_enabled + return + endif + let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} function closure.Process(match) dict let curline = getcurpos()[1] @@ -20,12 +24,18 @@ function s:CacheRstFold() let self.levels[curline] = self.header_types[key] endfunction let save_cursor = getcurpos() + let save_mark = getpos("'[") silent keeppatterns %s/\v^%(%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+)|%(%(([=`:.''"~^_*+#-])\3{2,}\n)?.{3,}\n([=`:.''"~^_*+#-])\4{2,})$/\=closure.Process(submatch(0))/gn call setpos('.', save_cursor) + call setpos("'[", save_mark) let b:RstFoldCache = closure.levels endfunction function RstFold#GetRstFold() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif @@ -37,6 +47,10 @@ function RstFold#GetRstFold() endfunction function RstFold#GetRstFoldText() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif |