savq / paq-nvim

🌚 Neovim package manager
MIT License
653 stars 39 forks source link

Add post-install hooks #1

Closed savq closed 3 years ago

savq commented 4 years ago

As suggested here, let the user add a hook to the install function. Similar to Vim-Plug's do option.

Notes:

megalithic commented 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.

savq commented 3 years ago

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.

megalithic commented 3 years ago

Huge thanks @savq !!

savq commented 3 years ago

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.

savq commented 3 years ago

This works now. Paq can install fzf like so:

paq{'junegunn/fzf', hook=vim.fn['fzf#install'] }

Closing notes:

megalithic commented 3 years ago

HUGE thank you @savq !!

kovasap commented 2 years ago

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?