mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-23 11:27:46 +02:00
ftplugin: Avoid changing global viewoptions
As mentioned in an earlier commit, viewoptions is global, so it's probably best to override it only temporarily for mkview. (loadview is moved to autoload just for symmetry and in case we need to do something more complex, like saving/restoring foldmethod, later)
This commit is contained in:
parent
7b72ee47b9
commit
a6907bac85
2 changed files with 14 additions and 4 deletions
|
@ -1,6 +1,18 @@
|
|||
if exists('g:loaded_taskwiki_auto') | finish | endif
|
||||
let g:loaded_taskwiki_auto = 1
|
||||
|
||||
function! taskwiki#MkView() abort
|
||||
let viewoptions = &viewoptions
|
||||
set viewoptions-=options
|
||||
mkview
|
||||
let &viewoptions = viewoptions
|
||||
endfunction
|
||||
|
||||
function! taskwiki#LoadView() abort
|
||||
silent! loadview
|
||||
silent! doautocmd SessionLoadPost
|
||||
endfunction
|
||||
|
||||
function! taskwiki#FoldInit() abort
|
||||
" Unless vimwiki is configured to use its folding, set our own
|
||||
if &foldtext !~? 'VimwikiFold'
|
||||
|
|
|
@ -41,10 +41,8 @@ augroup taskwiki
|
|||
autocmd BufWrite <buffer> TaskWikiBufferSave
|
||||
" Save and load the view to preserve folding, if desired
|
||||
if !exists('g:taskwiki_dont_preserve_folds')
|
||||
setlocal viewoptions-=options
|
||||
autocmd BufWinLeave <buffer> mkview
|
||||
autocmd BufWinEnter <buffer> silent! loadview
|
||||
autocmd BufWinEnter <buffer> silent! doautocmd SessionLoadPost
|
||||
autocmd BufWinLeave <buffer> call taskwiki#MkView()
|
||||
autocmd BufWinEnter <buffer> call taskwiki#LoadView()
|
||||
endif
|
||||
" Reset cache when switching buffers
|
||||
execute "autocmd BufEnter <buffer> :" . g:taskwiki_py . "cache.load_current().reset()"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue