Replies: 1 comment 4 replies
|
This is kinda more on how you wish to install it. lze intends to be agnostic to what is used to install things. As such, I probably will not be adding a built-in handler for this. Also I would add that the snippet you showed is already lazy. However it does run for every PackChanged not just nvim-treesitter How to do it like If you want to set The following only accepts a function, not a string. You can do that, this is just an example But for a proof of concept, you could do something like this. Turns out that pattern gets the path to the plugin. I haven't tested this I use nix for this stuff, but if its not correct its very close local augroup = nil
local build_handler = {
spec_field = "build",
set_lazy = false,
init = function() -- called when you register the handler
augroup = vim.api.nvim_create_augroup("lze_build_handler", { clear = true })
end,
cleanup = function() -- called if you deregister the handler (you probably wont)
if augroup then
vim.api.nvim_del_augroup_by_id(augroup)
end
end,
add = function(plugin) -- called for every plugin (you cannot modify the plugin here)
if type(plugin.build) == "function" then
local build = plugin.build
vim.api.nvim_create_autocmd('PackChanged', {
-- pattern gets the path. Which will end with the plugin's name. (maybe with a / at the end? IDK but probably not?)
pattern = "*/" .. plugin.name, -- I think this is how to match for that, but it is at least close.
group = augroup, -- <-- lets us remove all of them if we deregister this handler (you probably won't)
-- once = true, -- <-- if you want it to only trigger once (you probably dont?)
callback = function(ev)
local kind = ev.data.kind
if (kind == 'install' or kind == 'update') then
build(ev)
end
end,
})
end
end,
}
require('lze').register_handlers(build_handler)
-- and now you can use `build = function`
require('lze').load {
'nvim-treesitter',
build = function(ev)
vim.notify("nvim-treesitter updated/installed; running `:TSUpdate`", vim.log.levels.INFO)
vim.cmd('TSUpdate')
end,
} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi all,
Is there a way to have the same functionality as
build =? eg fortreesitterI would like to run:TSUpdateafter install or update.For now, I am doing:
Which seems to work just fine, but is a bit "overkill" as in this is listening to every plugin install/update/delete.
All reactions