Fix messing up folding when Vim is in diff mode

This commit is contained in:
EinfachToll 2018-08-07 21:39:54 +02:00
parent 2185815b00
commit 5605f285c1

View File

@ -157,23 +157,25 @@ endfunction
" Vim defaults. So we enforce our settings here when the cursor enters a " Vim defaults. So we enforce our settings here when the cursor enters a
" Vimwiki buffer. " Vimwiki buffer.
function! s:set_windowlocal_options() function! s:set_windowlocal_options()
let foldmethod = vimwiki#vars#get_global('folding') if !&diff " if Vim is currently in diff mode, don't interfere with its folding
if foldmethod =~? '^expr.*' let foldmethod = vimwiki#vars#get_global('folding')
setlocal foldmethod=expr if foldmethod =~? '^expr.*'
setlocal foldexpr=VimwikiFoldLevel(v:lnum) setlocal foldmethod=expr
setlocal foldtext=VimwikiFoldText() setlocal foldexpr=VimwikiFoldLevel(v:lnum)
elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*' setlocal foldtext=VimwikiFoldText()
setlocal foldmethod=expr elseif foldmethod =~? '^list.*' || foldmethod =~? '^lists.*'
setlocal foldexpr=VimwikiFoldListLevel(v:lnum) setlocal foldmethod=expr
setlocal foldtext=VimwikiFoldText() setlocal foldexpr=VimwikiFoldListLevel(v:lnum)
elseif foldmethod =~? '^syntax.*' setlocal foldtext=VimwikiFoldText()
setlocal foldmethod=syntax elseif foldmethod =~? '^syntax.*'
setlocal foldtext=VimwikiFoldText() setlocal foldmethod=syntax
elseif foldmethod =~? '^custom.*' setlocal foldtext=VimwikiFoldText()
" do nothing elseif foldmethod =~? '^custom.*'
else " do nothing
setlocal foldmethod=manual else
normal! zE setlocal foldmethod=manual
normal! zE
endif
endif endif
if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel") if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel")