commit 66a565d38888ffcd6ea379c84c3b949c2fb77e75
parent 1176f60ec639c4c8fd476b6a335416feeffa36ef
Author: EinfachToll <istjanichtzufassen@googlemail.com>
Date: Sun, 22 Apr 2018 21:25:09 +0200
Merge branch 'mMontu-dev' into dev
Diffstat:
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt
@@ -2458,6 +2458,8 @@ Limitations:
- 'list' is intended to work with lists nicely indented with 'shiftwidth'.
- 'syntax' is only available for the default syntax so far.
+The options above can be suffixed with ':quick' (e.g.: 'expr:quick') in order
+to use some workarounds to make folds work faster.
------------------------------------------------------------------------------
*g:vimwiki_list_ignore_newline*
diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
@@ -147,18 +147,18 @@ endfunction
" Vimwiki buffer.
function! s:set_windowlocal_options()
let foldmethod = vimwiki#vars#get_global('folding')
- if foldmethod ==? 'expr'
+ if foldmethod =~? '^expr.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
- elseif foldmethod ==? 'list' || foldmethod ==? 'lists'
+ elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
setlocal foldmethod=expr
setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
- elseif foldmethod ==? 'syntax'
+ elseif foldmethod =~? '^syntax.*'
setlocal foldmethod=syntax
setlocal foldtext=VimwikiFoldText()
- elseif foldmethod ==? 'custom'
+ elseif foldmethod =~? '^custom.*'
" do nothing
else
setlocal foldmethod=manual
@@ -229,6 +229,16 @@ augroup vimwiki
exe 'autocmd InsertLeave *'.s:ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.s:ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
+ if vimwiki#vars#get_global('folding') =~? ':quick$'
+ " from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text
+ " Don't screw up folds when inserting text that might affect them, until
+ " leaving insert mode. Foldmethod is local to the window. Protect against
+ " screwing up folding when switching between windows.
+ exe 'autocmd InsertEnter *'.s:ext.' if !exists("w:last_fdm") | let w:last_fdm=&foldmethod'.
+ \ ' | setlocal foldmethod=manual | endif'
+ exe 'autocmd InsertLeave,WinLeave *'.s:ext.' if exists("w:last_fdm") |'.
+ \ 'let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif'
+ endif
endfor
augroup END