From aa7cdbad55f986b376e0bcf3f8dd1046f9ccc141 Mon Sep 17 00:00:00 2001 From: Daniil Tsivinsky Date: Sun, 15 Mar 2026 19:21:43 +0300 Subject: [PATCH] neovim: fix PackUpdate command and also allow to pass arguments to it --- neovim/.config/nvim/lua/pack.lua | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/neovim/.config/nvim/lua/pack.lua b/neovim/.config/nvim/lua/pack.lua index 4bd17d2..3d749da 100644 --- a/neovim/.config/nvim/lua/pack.lua +++ b/neovim/.config/nvim/lua/pack.lua @@ -45,9 +45,34 @@ function M.add(opts) end function M.register_user_commands() - vim.api.nvim_create_user_command("PackUpdate", function() - vim.pack.update() - end, {}) + vim.api.nvim_create_user_command("PackUpdate", function(args) + local plugins_to_update = {} + + if args.args == "" then + local all_plugins = vim.pack.get() + for _, plugin in ipairs(all_plugins) do + table.insert(plugins_to_update, plugin.spec.name) + end + else + plugins_to_update = args.fargs + end + + vim.pack.update(plugins_to_update) + end, { + nargs = "*", + complete = function(text) + local plugins = vim.pack.get() + + local options = {} + for _, plugin in ipairs(plugins) do + if string.find(plugin.spec.name, "^" .. text .. "$") == nil then + table.insert(options, plugin.spec.name) + end + end + + return options + end, + }) vim.api.nvim_create_user_command("PackClean", function() local plugins = vim.pack.get()