How to use PackChanged with ~/.config/nvim/plugin/ file structure
#37519
-
|
Related: Let's define a configuration as: -- init.lua-- plugin/completion.lua
vim.api.nvim_create_autocmd("PackChanged", {
pattern = "blink.cmp",
desc = "Run `:BlinkCmp build` after pack changed",
group = vim.api.nvim_create_augroup("blink_update", { clear = true }),
callback = function(e)
local kind, name = e.data.kind, e.data.spec.name
if kind == "install" or kind == "update" then
vim.cmd.packadd({ args = { name }, bang = false })
require("blink.cmp.fuzzy.build").build()
end
end,
})
vim.pack.add({
{ src = "https://github.com/Saghen/blink.cmp", version = "main" },
})
require("blink.cmp").setup()I would expect the This behavior feels unintuitive and effectively forces to define |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
|
Looks to be related to #35314 and the linked pr. |
Beta Was this translation helpful? Give feedback.
-
|
According to You don't need to keep actual lines in
|
Beta Was this translation helpful? Give feedback.
-
|
I was a little bit off with my assumptions. Essentially, all Instead of: -- /foo.lua
autocmd kind=install foo
packadd foo
-- /bar.lua
autocmd kind=install bar
packadd barWe need to bubble the autocmds: -- /init.lua
autocmd kind=install foo
autocmd kind=install bar
-- /foo.lua
packadd foo
-- /bar.lua
packadd barAs mentioned before, this behavior can be unintuitive, but I don't know if it should be fixed in the first place, so I'm closing this discussion. |
Beta Was this translation helpful? Give feedback.
I did think about several possible solutions to this and all of them provided trade-offs that I don't think are worthwhile:
vim.pa…