cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user