60 lines
1.7 KiB
Lua
60 lines
1.7 KiB
Lua
vim.api.nvim_create_user_command(
|
|
"Q",
|
|
"q<bang>",
|
|
{ bang = true, desc = "Alias to :q" }
|
|
)
|
|
vim.api.nvim_create_user_command(
|
|
"Qa",
|
|
"qa<bang>",
|
|
{ bang = true, desc = "Alias to :qa" }
|
|
)
|
|
|
|
vim.api.nvim_create_user_command("PluginWatch", function()
|
|
require("pack").watch()
|
|
end, { desc = "Watch plugin configs for changes and hot-reload" })
|
|
|
|
vim.api.nvim_create_user_command("PluginUnwatch", function()
|
|
require("pack").unwatch()
|
|
end, { desc = "Stop watching plugin configs" })
|
|
|
|
local function complete_plugin_names(lead)
|
|
return vim.tbl_filter(function(name)
|
|
return name:find(lead, 1, true) == 1
|
|
end, require("pack").get_names())
|
|
end
|
|
|
|
vim.api.nvim_create_user_command("PluginReload", function(opts)
|
|
require("pack").reload_plugin(opts.args)
|
|
end, {
|
|
nargs = 1,
|
|
complete = complete_plugin_names,
|
|
desc = "Reload a plugin config by name",
|
|
})
|
|
|
|
vim.api.nvim_create_user_command("PluginUpdate", function(opts)
|
|
local names = #opts.fargs > 0 and opts.fargs or nil
|
|
require("pack").update(names)
|
|
end, {
|
|
nargs = "*",
|
|
complete = complete_plugin_names,
|
|
desc = "Update plugins (fetch from remote)",
|
|
})
|
|
|
|
vim.api.nvim_create_user_command("PluginUpdateOffline", function(opts)
|
|
local names = #opts.fargs > 0 and opts.fargs or nil
|
|
require("pack").update(names, { offline = true })
|
|
end, {
|
|
nargs = "*",
|
|
complete = complete_plugin_names,
|
|
desc = "Show pending plugin updates without fetching from remote",
|
|
})
|
|
|
|
vim.api.nvim_create_user_command("PluginRestore", function(opts)
|
|
local names = #opts.fargs > 0 and opts.fargs or nil
|
|
require("pack").update(names, { target = "lockfile" })
|
|
end, {
|
|
nargs = "*",
|
|
complete = complete_plugin_names,
|
|
desc = "Restore plugins to revisions in the lockfile",
|
|
})
|