diff options
| author | 2026-05-13 13:43:08 +0100 | |
|---|---|---|
| committer | 2026-05-13 13:43:08 +0100 | |
| commit | f2e2edad1b088b2fbaba49fb5a334434343fc972 (patch) | |
| tree | 68139b934c743db6a3e6479bdc9f56d2315ddfe0 /dot_config/nvim/lua/config | |
| parent | cd0071297b904028024fcd7a7035516d7d2942de (diff) | |
| download | dotfiles-f2e2edad1b088b2fbaba49fb5a334434343fc972.tar.gz dotfiles-f2e2edad1b088b2fbaba49fb5a334434343fc972.tar.bz2 dotfiles-f2e2edad1b088b2fbaba49fb5a334434343fc972.zip | |
feat(nvim): add :PackClean, :PackUpdate, :PackSync user commands
Wraps vim.pack for a more ergonomic workflow:
- :PackClean - delete plugins no longer declared in vim.pack.add()
(computed from vim.pack.get() where active == false)
- :PackUpdate - run vim.pack.update(nil, { force = true }); skips
the confirmation buffer
- :PackSync - :PackClean followed by :PackUpdate
Diffstat (limited to 'dot_config/nvim/lua/config')
| -rw-r--r-- | dot_config/nvim/lua/config/pack.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/config/pack.lua b/dot_config/nvim/lua/config/pack.lua new file mode 100644 index 0000000..bdef872 --- /dev/null +++ b/dot_config/nvim/lua/config/pack.lua @@ -0,0 +1,41 @@ +-- User commands wrapping vim.pack for ergonomic update/clean/sync workflows. + +local function orphans() + return vim + .iter(vim.pack.get()) + :filter(function(x) + return not x.active + end) + :map(function(x) + return x.spec.name + end) + :totable() +end + +local function clean() + local names = orphans() + if #names == 0 then + vim.notify("no orphan plugins", vim.log.levels.INFO) + return + end + vim.pack.del(names) +end + +local function update() + vim.pack.update(nil, { force = true }) +end + +vim.api.nvim_create_user_command("PackClean", clean, { + desc = "Remove plugins not declared in vim.pack.add()", +}) + +vim.api.nvim_create_user_command("PackUpdate", update, { + desc = "Update all plugins without confirmation", +}) + +vim.api.nvim_create_user_command("PackSync", function() + clean() + update() +end, { + desc = "Clean orphan plugins then update the rest", +}) |
