Mercurial > vim
comparison runtime/autoload/RstFold.vim @ 15334:9d3d7b0f4861
Update runtime files
commit https://github.com/vim/vim/commit/4c05fa08c9739e307ddc88ac91ba6d208f1fd68e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 1 15:32:17 2019 +0100
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 01 Jan 2019 15:45:06 +0100 |
parents | 2f7e67dd088c |
children |
comparison
equal
deleted
inserted
replaced
15333:37502e631202 | 15334:9d3d7b0f4861 |
---|---|
1 " Author: Antony Lee <anntzer.lee@gmail.com> | 1 " Author: Antony Lee <anntzer.lee@gmail.com> |
2 " Description: Helper functions for reStructuredText syntax folding | 2 " Description: Helper functions for reStructuredText syntax folding |
3 " Last Modified: 2018-01-07 | 3 " Last Modified: 2018-12-29 |
4 | 4 |
5 function s:CacheRstFold() | 5 function s:CacheRstFold() |
6 if !g:rst_fold_enabled | |
7 return | |
8 endif | |
9 | |
6 let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} | 10 let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} |
7 function closure.Process(match) dict | 11 function closure.Process(match) dict |
8 let curline = getcurpos()[1] | 12 let curline = getcurpos()[1] |
9 if has_key(self.levels, curline - 1) | 13 if has_key(self.levels, curline - 1) |
10 " For over+under-lined headers, the regex will match both at the | 14 " For over+under-lined headers, the regex will match both at the |
18 let self.header_types[key] = self.max_level | 22 let self.header_types[key] = self.max_level |
19 endif | 23 endif |
20 let self.levels[curline] = self.header_types[key] | 24 let self.levels[curline] = self.header_types[key] |
21 endfunction | 25 endfunction |
22 let save_cursor = getcurpos() | 26 let save_cursor = getcurpos() |
27 let save_mark = getpos("'[") | |
23 silent keeppatterns %s/\v^%(%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+)|%(%(([=`:.''"~^_*+#-])\3{2,}\n)?.{3,}\n([=`:.''"~^_*+#-])\4{2,})$/\=closure.Process(submatch(0))/gn | 28 silent keeppatterns %s/\v^%(%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+)|%(%(([=`:.''"~^_*+#-])\3{2,}\n)?.{3,}\n([=`:.''"~^_*+#-])\4{2,})$/\=closure.Process(submatch(0))/gn |
24 call setpos('.', save_cursor) | 29 call setpos('.', save_cursor) |
30 call setpos("'[", save_mark) | |
25 let b:RstFoldCache = closure.levels | 31 let b:RstFoldCache = closure.levels |
26 endfunction | 32 endfunction |
27 | 33 |
28 function RstFold#GetRstFold() | 34 function RstFold#GetRstFold() |
35 if !g:rst_fold_enabled | |
36 return | |
37 endif | |
38 | |
29 if !has_key(b:, 'RstFoldCache') | 39 if !has_key(b:, 'RstFoldCache') |
30 call s:CacheRstFold() | 40 call s:CacheRstFold() |
31 endif | 41 endif |
32 if has_key(b:RstFoldCache, v:lnum) | 42 if has_key(b:RstFoldCache, v:lnum) |
33 return '>' . b:RstFoldCache[v:lnum] | 43 return '>' . b:RstFoldCache[v:lnum] |
35 return '=' | 45 return '=' |
36 endif | 46 endif |
37 endfunction | 47 endfunction |
38 | 48 |
39 function RstFold#GetRstFoldText() | 49 function RstFold#GetRstFoldText() |
50 if !g:rst_fold_enabled | |
51 return | |
52 endif | |
53 | |
40 if !has_key(b:, 'RstFoldCache') | 54 if !has_key(b:, 'RstFoldCache') |
41 call s:CacheRstFold() | 55 call s:CacheRstFold() |
42 endif | 56 endif |
43 let indent = repeat(' ', b:RstFoldCache[v:foldstart] - 1) | 57 let indent = repeat(' ', b:RstFoldCache[v:foldstart] - 1) |
44 let thisline = getline(v:foldstart) | 58 let thisline = getline(v:foldstart) |