" deprecated initialization using anyfold_activate variable
" still works but echoes a warning
au BufNewFile,BufRead * call anyfold#init(0)
First, this autocmd don't be included in an augroup, which make user cannot use autocmd! augroup_name to disable it.
Second, this autocmd make vim call this function when read or create a buffer, which means vim will source autoload/anyfold.vim. If we change it to (just move some lines from autoload function to plugin/anyfold.vim)
au BufNewFile,BufRead * call s:init()
function! s:init() abort
if exists("g:anyfold_activate")
let b:anyfold_activate = g:anyfold_activate
endif
if !exists("b:anyfold_activate")
return
elseif !b:anyfold_activate
return
endif
call anyfold#init(1)
endfunction
Now, if g: or b:anyfold_activate don't exist, the autoload function anyfold#init will not be called, so autoload/anyfold.vim will not be sourced, it can save time of sourcing a script.
First, this autocmd don't be included in an augroup, which make user cannot use
autocmd! augroup_name
to disable it.Second, this autocmd make vim call this function when read or create a buffer, which means vim will source
autoload/anyfold.vim
. If we change it to (just move some lines from autoload function toplugin/anyfold.vim
)Now, if g: or b:anyfold_activate don't exist, the autoload function
anyfold#init
will not be called, soautoload/anyfold.vim
will not be sourced, it can save time of sourcing a script.I think it will be better.
Thanks!