2014-07-22 18:08:57 -04:00
|
|
|
" LaTeX plugin for Vim
|
|
|
|
"
|
|
|
|
" Maintainer: Karl Yngve Lervåg
|
|
|
|
" Email: karl.yngve@gmail.com
|
|
|
|
"
|
|
|
|
|
2014-07-15 08:52:45 -04:00
|
|
|
function! toc#fold_level(lnum) " {{{1
|
2014-07-20 09:51:13 -04:00
|
|
|
let pline = getline(a:lnum - 1)
|
|
|
|
let cline = getline(a:lnum)
|
|
|
|
let nline = getline(a:lnum + 1)
|
2014-07-20 09:59:20 -04:00
|
|
|
let l:pn = matchstr(pline, '\d$')
|
|
|
|
let l:cn = matchstr(cline, '\d$')
|
|
|
|
let l:nn = matchstr(nline, '\d$')
|
2014-07-20 09:51:13 -04:00
|
|
|
|
|
|
|
" Don't fold options
|
|
|
|
if cline =~# '^\s*$'
|
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
|
2014-07-20 09:59:20 -04:00
|
|
|
if l:nn > l:cn && g:latex_toc_fold_levels >= l:nn
|
|
|
|
return '>' . l:nn
|
2014-07-20 09:51:13 -04:00
|
|
|
endif
|
|
|
|
|
2014-07-20 09:59:20 -04:00
|
|
|
if l:cn < l:pn && l:cn >= l:nn && g:latex_toc_fold_levels >= l:cn
|
|
|
|
return l:cn
|
2014-07-20 09:51:13 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
return '='
|
2013-10-05 07:53:42 -04:00
|
|
|
endfunction
|
|
|
|
|
2014-07-15 08:52:45 -04:00
|
|
|
function! toc#fold_text() " {{{1
|
2014-07-20 09:51:13 -04:00
|
|
|
return getline(v:foldstart)
|
2013-10-05 07:53:42 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
" }}}1
|
|
|
|
|
2014-02-10 08:21:43 -05:00
|
|
|
" vim: fdm=marker
|