fix:pack clean command

This commit is contained in:
2026-05-28 01:39:40 +09:00
parent 7399d50faf
commit 12204c0eda
3 changed files with 16 additions and 7 deletions

View File

@@ -52,9 +52,22 @@ function M.setup()
end, { desc = "Sync installed plugins to nvim-pack-lock.json" })
vim.api.nvim_create_user_command("PackClean", function()
local configured = M.registry(M.names())
local configured_names = {}
local configured_srcs = {}
for _, spec in ipairs(configured) do
configured_names[spec.name] = true
if spec.src then
configured_srcs[spec.src] = true
end
end
local stale = vim.iter(vim.pack.get())
:filter(function(plugin)
return not plugin.active
local spec = plugin.spec
local configured_by_name = configured_names[spec.name]
local configured_by_src = spec.src and configured_srcs[spec.src]
return not configured_by_name and not configured_by_src
end)
:map(function(plugin)
return plugin.spec.name
@@ -75,7 +88,7 @@ function M.setup()
vim.pack.del(stale)
vim.notify("PackClean: removed " .. #stale .. " plugin(s)", vim.log.levels.INFO)
end, { desc = "Delete inactive vim.pack plugins from disk" })
end, { desc = "Delete unconfigured vim.pack plugins from disk" })
end
return M

View File

@@ -25,7 +25,7 @@ M.map = {
["trouble.nvim"] = { name = "trouble.nvim", src = "https://github.com/folke/trouble.nvim" },
["grug-far.nvim"] = { name = "grug-far.nvim", src = "https://github.com/MagicDuck/grug-far.nvim" },
["nvim-ts-autotag"] = { name = "nvim-ts-autotag", src = "https://github.com/windwp/nvim-ts-autotag" },
["supermaven-nvim"] = { name = "supermaven-nvim", src = "https://github.com/supermaven-inc/supermaven-nvim" },
-- ["supermaven-nvim"] = { name = "supermaven-nvim", src = "https://github.com/supermaven-inc/supermaven-nvim" },
["symbol-usage"] = { name = "symbol-usage", src = "https://github.com/Wansmer/symbol-usage.nvim" },
}