This commit is contained in:
2026-04-13 21:48:04 +09:00
parent a31c84f9d7
commit 429b561ff4
3 changed files with 12 additions and 15 deletions

View File

@@ -31,11 +31,11 @@ M.map = {
function M.by_names(names)
local out = {}
for _, name in ipairs(names) do
local spec = M.map[name]
if not spec then
error("Unknown plugin spec: " .. tostring(name))
local entry = M.map[name]
if not entry then
error("Unknown plugin registry entry: " .. tostring(name))
end
table.insert(out, spec)
table.insert(out, entry)
end
return out
end

View File

@@ -2,12 +2,12 @@ local M = {}
local loaded = {}
function M.load_once(key, specs, setup)
function M.load_once(key, plugins, setup)
if loaded[key] then
return
end
loaded[key] = true
vim.pack.add(specs)
vim.pack.add(plugins)
if setup then
setup()
end

View File

@@ -6,9 +6,6 @@ function M.registry(names)
return registry.by_names(names)
end
-- Backward-compatible alias
M.specs = M.registry
function M.add(names, opts)
vim.pack.add(M.registry(names), opts)
end
@@ -23,8 +20,8 @@ function M.setup()
vim.api.nvim_create_autocmd("PackChanged", {
group = group,
callback = function(ev)
local name, kind = ev.data.spec.name, ev.data.kind
if name == "nvim-treesitter" and kind == "update" then
local plugin_name, kind = ev.data.spec.name, ev.data.kind
if plugin_name == "nvim-treesitter" and kind == "update" then
if not ev.data.active then
vim.cmd.packadd("nvim-treesitter")
end
@@ -64,11 +61,11 @@ function M.setup()
vim.api.nvim_create_user_command("PackClean", function()
local stale = vim.iter(vim.pack.get())
:filter(function(p)
return not p.active
:filter(function(plugin)
return not plugin.active
end)
:map(function(p)
return p.spec.name
:map(function(plugin)
return plugin.spec.name
end)
:totable()