From 97927e65f9729860a83dcefcc14c9dfdf8c491a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Mon, 11 Jan 2016 21:45:02 +0100 Subject: [PATCH] Fix #319 - Fold bibliographies --- autoload/vimtex/fold.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/vimtex/fold.vim b/autoload/vimtex/fold.vim index 75e87d7..8173f56 100644 --- a/autoload/vimtex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -106,7 +106,7 @@ function! vimtex#fold#level(lnum) " {{{1 " Check for normal lines first (optimization) let line = getline(a:lnum) - if line !~# '^\s*%\|\\\%(document\|begin\|end\|' + if line !~# '^\s*%\|\\\%(document\|begin\|end\|printbibliography\|' \ . 'front\|main\|back\|app\|sub\|section\|chapter\|part\)' return '=' endif @@ -199,6 +199,9 @@ function! s:refresh_folded_sections() let b:vimtex_fold_parts = [] endif + " Set bibliography fold level + let biblevel = level + 1 + " Parse section commands (chapter, [sub...]section) let lines = filter(copy(buffer), 'v:val =~ ''' . s:secs . '''') for part in g:vimtex_fold_sections @@ -211,6 +214,9 @@ function! s:refresh_folded_sections() endif endfor endfor + + " Add bibliography pattern + call insert(b:vimtex_fold_parts, ['^\s*\\printbibliography', biblevel]) endfunction " }}}1 @@ -235,6 +241,8 @@ function! vimtex#fold#text() " {{{1 let title = 'Backmatter' elseif line =~# '\\appendix' let title = 'Appendix' + elseif line =~# '\\printbibliography' + let title = 'Bibliography' elseif line =~# secpat1 . '.*}' let title = matchstr(line, secpat1 . '\zs.*\ze}') elseif line =~# secpat1