Closed savq closed 3 years ago
Is there a current best practice to doing this sort of thing; say after PaqInstall'ing fzf/fzf.vim to run the fzf installer scripts? maybe there's a lua way to defer a command until after a previous function is completed? i know this is something you're figuring out, just wondering if there is something to do in the interim.
Hi. part of this feature is already in the dev branch, running shell commands to be specific. The second part, running user defined functions, is still pending what I'm doing this afternoon.
After that, I'd still need to run some tests, but I should be merging this weekend.
...way to defer a command until after a previous function is completed?
The tricky part is that we don't know when the install function ends. The hooks would run as callbacks to the install/update callbacks.
In the meantime, I can tell you that when paq prints out that it is installing something, it has in fact already done it. That's because I'm lazy Paq uses the same function to notify on success and failure.
Huge thanks @savq !!
Quick update:
So far the hooks work, except for one small issue: the plugin isn't added to the runtime the first time it's installed, so the hook will fail the first time it runs, but it'll suceed if one re-enters nvim and runs :PaqUpdate
.
This is super annoying of course, so for now I'm leaving this feature in it's own branch updatehooks
.
Note: So far, I've only tried running packadd!
and appending to vim.o.runtimepath
, the latter wouldn't be ideal anyways because it requires checking whether it's installing or updating something.
This works now. Paq can install fzf like so:
paq{'junegunn/fzf', hook=vim.fn['fzf#install'] }
Closing notes:
Running :packloadall!
will source newly installed packages correctly. It's not ideal, but it works.
Future work (including issue #2) may lead to a more organized two stage installation, a first batch of callbacks for installs, and a second for hooks and helptags; requiring only one :packloadall!
in the middle.
HUGE thank you @savq !!
Based on the README documentation, it isn't clear to me how to e.g. run a shell command after installing a plugin (from that plugin's directory). Is this possible using this feature? If so, could a short example for how to do it be added to the README?
As suggested here, let the user add a hook to the install function. Similar to Vim-Plug's
do
option.Notes: