" Author: Antony Lee <anntzer.lee@gmail.com> " Description: Helper functions for reStructuredText syntax folding " 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] if has_key(self.levels, curline - 1) " For over+under-lined headers, the regex will match both at the " overline and at the title itself; in that case, skip the second match. return endif let lines = split(a:match, '\n') let key = repeat(lines[-1][0], len(lines)) if !has_key(self.header_types, key) let self.max_level += 1 let self.header_types[key] = self.max_level endif 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 if has_key(b:RstFoldCache, v:lnum) return '>' . b:RstFoldCache[v:lnum] else return '=' endif endfunction function RstFold#GetRstFoldText() if !g:rst_fold_enabled return endif if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif let indent = repeat(' ', b:RstFoldCache[v:foldstart] - 1) let thisline = getline(v:foldstart) " For over+under-lined headers, skip the overline. let text = thisline =~ '^\([=`:.''"~^_*+#-]\)\1\+$' ? getline(v:foldstart + 1) : thisline return indent . text endfunction
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
dist | Folder | 0755 |
|
|
xml | Folder | 0755 |
|
|
README.txt | File | 773 B | 0644 |
|
RstFold.vim | File | 1.86 KB | 0644 |
|
ada.vim | File | 22.04 KB | 0644 |
|
adacomplete.vim | File | 3.58 KB | 0644 |
|
ccomplete.vim | File | 17.44 KB | 0644 |
|
clojurecomplete.vim | File | 7.84 KB | 0644 |
|
context.vim | File | 5.33 KB | 0644 |
|
contextcomplete.vim | File | 656 B | 0644 |
|
csscomplete.vim | File | 42.23 KB | 0644 |
|
decada.vim | File | 2.93 KB | 0644 |
|
getscript.vim | File | 24.28 KB | 0644 |
|
gnat.vim | File | 5.21 KB | 0644 |
|
gzip.vim | File | 6.26 KB | 0644 |
|
haskellcomplete.vim | File | 103.31 KB | 0644 |
|
htmlcomplete.vim | File | 24.89 KB | 0644 |
|
javascriptcomplete.vim | File | 26.39 KB | 0644 |
|
netrw.vim | File | 535.67 KB | 0644 |
|
netrwFileHandlers.vim | File | 9.91 KB | 0644 |
|
netrwSettings.vim | File | 10.22 KB | 0644 |
|
netrw_gitignore.vim | File | 3.05 KB | 0644 |
|
paste.vim | File | 672 B | 0644 |
|
phpcomplete.vim | File | 345.82 KB | 0644 |
|
python3complete.vim | File | 21.07 KB | 0644 |
|
pythoncomplete.vim | File | 21.53 KB | 0644 |
|
rubycomplete.vim | File | 24.42 KB | 0644 |
|
rust.vim | File | 10.22 KB | 0644 |
|
rustfmt.vim | File | 2.92 KB | 0644 |
|
spellfile.vim | File | 6.09 KB | 0644 |
|
sqlcomplete.vim | File | 38.27 KB | 0644 |
|
syntaxcomplete.vim | File | 30.54 KB | 0644 |
|
tar.vim | File | 22.53 KB | 0644 |
|
tohtml.vim | File | 31.69 KB | 0644 |
|
vimball.vim | File | 23.76 KB | 0644 |
|
xmlcomplete.vim | File | 14.59 KB | 0644 |
|
xmlformat.vim | File | 5.28 KB | 0644 |
|
zip.vim | File | 14.3 KB | 0644 |
|