Fix #590: Add support for fold markers

This commit is contained in:
Karl Yngve Lervåg 2016-10-16 10:52:02 +02:00
parent 7fb8643d4f
commit 074fb6c8d2
2 changed files with 18 additions and 1 deletions

View File

@ -29,6 +29,7 @@ function! vimtex#fold#init_options() " {{{1
call vimtex#util#set_default('g:vimtex_fold_documentclass', 0)
call vimtex#util#set_default('g:vimtex_fold_usepackage', 1)
call vimtex#util#set_default('g:vimtex_fold_newcommands', 1)
call vimtex#util#set_default('g:vimtex_fold_markers', 1)
" Disable manual mode in vimdiff
let g:vimtex_fold_manual = &diff ? 0 : g:vimtex_fold_manual
@ -44,8 +45,11 @@ function! vimtex#fold#init_script() " {{{1
"
" List of identifiers for improving efficiency
"
let s:folded = '\v^\s*\%|^\s*\]\{'
let s:folded = '\v'
let s:folded .= ' ^\s*\%'
let s:folded .= '|^\s*\]\{'
let s:folded .= '|^\s*}\s*$'
let s:folded .= '|\%\s*%(\{\{\{|}}})'
let s:folded .= '|\\%(' . join([
\ 'begin',
\ 'end',
@ -208,6 +212,13 @@ function! vimtex#fold#level(lnum) " {{{1
endif
endif
" Fold markers
if line =~# '%\s*{{{'
return 'a1'
elseif line =~# '%\s*}}}'
return 's1'
endif
" Never fold \end{document}
if line =~# '^\s*\\end{document}'
return 0

View File

@ -510,6 +510,12 @@ Options~
Default value: 0
*g:vimtex_fold_markers*
Use this option to disable/enable vim-style markers for folding, i.e. pairs
of `{{{` and `}}}`.
Default value: 1
*g:vimtex_imaps_enabled*
Use this option to disable/enable the insert mode mappings.