Function called from within a post update hook doesn't work but using it as a post update hook works
ahmedelgabri opened this issue · 4 comments
I'm trying to add a custom post update hook, when I do this it blows up
let s:coc_extensions = [
\ 'coc-css',
\ 'coc-rls',
\ 'coc-html',
\ 'coc-json',
\ 'coc-pyls',
\ 'coc-yaml',
\ 'coc-emoji',
\ 'coc-tsserver',
\ 'coc-ultisnips',
\ 'coc-highlight'
\ ]
function! s:coc_plugins() abort
call coc#util#install() " Throws here
call coc#util#install_extension(join(get(s:, 'coc_extensions', [])))
endfunction
call minpac#add('https://github.com/neoclide/coc.nvim', {'do': function('s:coc_plugins')})
while this works as expected actually this also stopped working...
call minpac#add('https://github.com/neoclide/coc.nvim', {'do': { -> coc#util#install() } })
Any idea where is the problem & how to make it work?
I had to do this to make it work, but not sure if this is the right thing
function! s:coc_plugins() abort
+ execute 'packadd ' . a:name
call coc#util#install()
call coc#util#install_extension(join(get(s:, 'coc_extensions', [])))
endfunction
The post-update hook is called after updating by the git command is finished.
At the moment, the plugin might not be added to the 'runtimepath'. (Vim will update it after .vimrc
is loaded or packadd
is used.)
Adding execute 'packadd ' . a:name
looks right solution.
@k-takata perfect, thanks!
Sorry to revive this issue back, but execute 'packadd ' . a:name
is also not working properly. That's because hooks only run as a post-update
& they don't run after the initial install.
Is there is any way to be able to run this on initial install & on updates too?