wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.85k stars 265 forks source link

Separate install and update hooks #1180

Open bluebrown opened 1 year ago

bluebrown commented 1 year ago

Describe the feature

Hi, I find it a bit problematic to have the same hook run on update and install. For example, treesitter, will error if this runs on the first installation:

use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }

I think its because treesitter is not fully setup at this point yet. Once it has been installed, the command works as expected on subsequent updates.

I guess there are more situations where it makes sense to run some function on update but not on install. Hence it would be nice to have indivdual lifecycle hooks.

use { 
  'foo/bar', 
  onInstall = ':Something',
  onUpdate = ':Else',
}
ppwwyyxx commented 1 year ago

Also encountered the error on "TSUpdate".

bluebrown commented 1 year ago

@ppwwyyxx , in case of treesitter you can fix it like this.

 run = function()
      local ts_update = require("nvim-treesitter.install").update({ with_sync = true })
      ts_update()
    end,

But I still think splitting it into more than 1 lifecycle hook would make alot of sense.