cleanup
This commit is contained in:
@@ -31,11 +31,11 @@ M.map = {
|
|||||||
function M.by_names(names)
|
function M.by_names(names)
|
||||||
local out = {}
|
local out = {}
|
||||||
for _, name in ipairs(names) do
|
for _, name in ipairs(names) do
|
||||||
local spec = M.map[name]
|
local entry = M.map[name]
|
||||||
if not spec then
|
if not entry then
|
||||||
error("Unknown plugin spec: " .. tostring(name))
|
error("Unknown plugin registry entry: " .. tostring(name))
|
||||||
end
|
end
|
||||||
table.insert(out, spec)
|
table.insert(out, entry)
|
||||||
end
|
end
|
||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ local M = {}
|
|||||||
|
|
||||||
local loaded = {}
|
local loaded = {}
|
||||||
|
|
||||||
function M.load_once(key, specs, setup)
|
function M.load_once(key, plugins, setup)
|
||||||
if loaded[key] then
|
if loaded[key] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
loaded[key] = true
|
loaded[key] = true
|
||||||
vim.pack.add(specs)
|
vim.pack.add(plugins)
|
||||||
if setup then
|
if setup then
|
||||||
setup()
|
setup()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ function M.registry(names)
|
|||||||
return registry.by_names(names)
|
return registry.by_names(names)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Backward-compatible alias
|
|
||||||
M.specs = M.registry
|
|
||||||
|
|
||||||
function M.add(names, opts)
|
function M.add(names, opts)
|
||||||
vim.pack.add(M.registry(names), opts)
|
vim.pack.add(M.registry(names), opts)
|
||||||
end
|
end
|
||||||
@@ -23,8 +20,8 @@ function M.setup()
|
|||||||
vim.api.nvim_create_autocmd("PackChanged", {
|
vim.api.nvim_create_autocmd("PackChanged", {
|
||||||
group = group,
|
group = group,
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
local name, kind = ev.data.spec.name, ev.data.kind
|
local plugin_name, kind = ev.data.spec.name, ev.data.kind
|
||||||
if name == "nvim-treesitter" and kind == "update" then
|
if plugin_name == "nvim-treesitter" and kind == "update" then
|
||||||
if not ev.data.active then
|
if not ev.data.active then
|
||||||
vim.cmd.packadd("nvim-treesitter")
|
vim.cmd.packadd("nvim-treesitter")
|
||||||
end
|
end
|
||||||
@@ -64,11 +61,11 @@ function M.setup()
|
|||||||
|
|
||||||
vim.api.nvim_create_user_command("PackClean", function()
|
vim.api.nvim_create_user_command("PackClean", function()
|
||||||
local stale = vim.iter(vim.pack.get())
|
local stale = vim.iter(vim.pack.get())
|
||||||
:filter(function(p)
|
:filter(function(plugin)
|
||||||
return not p.active
|
return not plugin.active
|
||||||
end)
|
end)
|
||||||
:map(function(p)
|
:map(function(plugin)
|
||||||
return p.spec.name
|
return plugin.spec.name
|
||||||
end)
|
end)
|
||||||
:totable()
|
:totable()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user