From 3ec4b496569ac94ddb8411ebb7ea01fb7be17acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 12 Jul 2016 09:06:21 +0200 Subject: [PATCH] Added option for folding of usepackage (#477) --- autoload/vimtex/fold.vim | 15 +++++++++------ doc/vimtex.txt | 13 +++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/autoload/vimtex/fold.vim b/autoload/vimtex/fold.vim index 0cb4f18..ad7ed6d 100644 --- a/autoload/vimtex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -26,6 +26,7 @@ function! vimtex#fold#init_options() " {{{1 \ 'subsection', \ 'subsubsection', \ ]) + call vimtex#util#set_default('g:vimtex_fold_usepackage', 1) " Disable manual mode in vimdiff let g:vimtex_fold_manual = &diff ? 0 : g:vimtex_fold_manual @@ -140,12 +141,14 @@ function! vimtex#fold#level(lnum) " {{{1 endif " Fold usepackages - if line =~# '^\s*\\usepackage\s*\[\s*\%($\|%\)' - let s:usepackage = 1 - return 'a1' - elseif get(s:, 'usepackage', 0) && line =~# '^\s*\]{' - let s:usepackage = 0 - return 's1' + if g:vimtex_fold_usepackage + if line =~# '^\s*\\usepackage\s*\[\s*\%($\|%\)' + let s:usepackage = 1 + return 'a1' + elseif get(s:, 'usepackage', 0) && line =~# '^\s*\]{' + let s:usepackage = 0 + return 's1' + endif endif " Fold chapters and sections diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 530998f..b1239d8 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -467,6 +467,18 @@ Options~ \ "subsubsection", \ ] < +*g:vimtex_fold_usepackage* + Use this option to disable/enable folding of long `\usepackage` lines. The + lines must be formatted like this for folding to work properly: > + + \usepackage[ + option 1, + ..., + option n + ]{name} +< + Default value: 1 + *g:vimtex_imaps_enabled* Use this option to disable/enable the insert mode mappings. @@ -1584,6 +1596,7 @@ Associated settings: |g:vimtex_fold_parts| |g:vimtex_fold_sections| |g:vimtex_fold_envs| + |g:vimtex_fold_usepackage| ============================================================================== INDENTATION *vimtex-indent*