Merge branch 'dev' of https://github.com/mMontu/vimwiki into mMontu-dev

Conflicts:
	plugin/vimwiki.vim
This commit is contained in:
EinfachToll 2018-04-22 21:24:28 +02:00
commit 503bc11dd9
2 changed files with 16 additions and 4 deletions

View File

@ -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*

View File

@ -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