-
Notifications
You must be signed in to change notification settings - Fork 42
/
folding.vim
38 lines (35 loc) · 802 Bytes
/
folding.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
" Helpers {{{1
function! s:SID()
return matchstr(expand('<sfile>'), '<SNR>\d\+_')
endfunction
function! HeadingDepth(lnum)
let level=0
let thisline = getline(a:lnum)
let hashCount = len(matchstr(thisline, '^#\{1,6}'))
if hashCount > 0
let level = hashCount
else
if thisline != ''
let nextline = getline(a:lnum + 1)
if nextline =~ '^==='
let level = 1
elseif nextline =~ '^---'
let level = 2
endif
endif
endif
return level
endfunction
function! FoldText()
return 'placeholder'
endfunction
" Setup {{{1
setlocal foldmethod=expr
let &l:foldtext = s:SID() . 'FoldText()'
command! -buffer FoldToggle
" Teardown {{{1
let b:undo_ftplugin .= '
\ | setlocal foldmethod< foldtext<
\ | delcommand FoldToggle
\ '
" vim:set fdm=marker: