diff --git a/after/syntax/vimwiki.vim b/after/syntax/vimwiki.vim index 0c6580e..e74379a 100644 --- a/after/syntax/vimwiki.vim +++ b/after/syntax/vimwiki.vim @@ -54,7 +54,3 @@ setlocal conceallevel=3 if !exists('g:taskwiki_disable_concealcursor') setlocal concealcursor=nc endif - -" Configure custom FoldText function -setlocal foldmethod=syntax -setlocal foldtext=taskwiki#FoldText() diff --git a/autoload/taskwiki.vim b/autoload/taskwiki.vim index 5e59d0e..6d3ab8c 100644 --- a/autoload/taskwiki.vim +++ b/autoload/taskwiki.vim @@ -1,6 +1,14 @@ if exists('g:loaded_taskwiki_auto') | finish | endif let g:loaded_taskwiki_auto = 1 +function! taskwiki#FoldInit() abort + " Unless vimwiki is configured to use its folding, set our own + if &foldtext !~? 'VimwikiFold' + setlocal foldmethod=syntax + setlocal foldtext=taskwiki#FoldText() + endif +endfunction + " Altered version of the VimwikiFoldText, strips viewport params function! taskwiki#FoldText() let line = getline(v:foldstart) diff --git a/ftplugin/vimwiki/taskwiki.vim b/ftplugin/vimwiki/taskwiki.vim index 2eaf5e3..0db3948 100644 --- a/ftplugin/vimwiki/taskwiki.vim +++ b/ftplugin/vimwiki/taskwiki.vim @@ -46,7 +46,10 @@ augroup taskwiki autocmd BufWinEnter silent! loadview autocmd BufWinEnter silent! doautocmd SessionLoadPost endif + " Reset cache when switching buffers execute "autocmd BufEnter :" . g:taskwiki_py . "cache.load_current().reset()" + " Update window-local fold options + autocmd BufWinEnter call taskwiki#FoldInit() " Refresh on load (if possible, after loadview to preserve folds) if has('patch-8.1.1113') || has('nvim-0.4.0') diff --git a/tests/base.py b/tests/base.py index 92a7771..8861e44 100644 --- a/tests/base.py +++ b/tests/base.py @@ -67,6 +67,7 @@ class IntegrationTest(object): raise def configure_global_variables(self): + self.command('set foldlevel=99') self.command('let g:taskwiki_data_location="{0}"'.format(self.dir)) self.command('let g:taskwiki_taskrc_location="{0}"'.format(self.taskrc_path)) self.command('let g:vimwiki_list = [{"syntax": "%s", "ext": ".txt","path": "%s"}]' % (self.markup, self.dir))