neovim: add pack.register_user_commands function
This commit is contained in:
@@ -55,27 +55,4 @@ pack.add({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("PackUpdate", function()
|
pack.register_user_commands()
|
||||||
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, {})
|
|
||||||
|
|||||||
@@ -44,4 +44,31 @@ function M.add(opts)
|
|||||||
vim.pack.add(items)
|
vim.pack.add(items)
|
||||||
end
|
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
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user