neovim: add pack.register_user_commands function

This commit is contained in:
2026-03-13 21:44:38 +03:00
parent 559cd2b684
commit 4b132f0f11
2 changed files with 28 additions and 24 deletions

View File

@@ -44,4 +44,31 @@ function M.add(opts)
vim.pack.add(items)
end
function M.register_user_commands()
vim.api.nvim_create_user_command("PackUpdate", function()
vim.pack.update()
end, {})
vim.api.nvim_create_user_command("PackClean", function()
local plugins = vim.pack.get()
local items = {}
for _, plug in ipairs(plugins) do
if not plug.active then
table.insert(items, plug.spec.name)
end
end
if #items == 0 then
return
end
vim.pack.del(items)
local msg = "Deleted " .. #items .. " plugins"
vim.notify(msg)
end, {})
end
return M