diff --git a/nvim/lua/darcula/usercmds.lua b/nvim/lua/darcula/usercmds.lua index 6310bbb..1b5f235 100644 --- a/nvim/lua/darcula/usercmds.lua +++ b/nvim/lua/darcula/usercmds.lua @@ -38,6 +38,38 @@ vim.api.nvim_create_user_command( {} ) +vim.api.nvim_create_user_command( + "PlugClean", + function() + local stale = vim.iter(vim.pack.get()) + :filter(function(plugin) + return not plugin.active + end) + :map(function(plugin) + return plugin.spec.name + end) + :totable() + + if #stale == 0 then + vim.notify("No stale plugins", vim.log.levels.INFO) + return + end + + table.sort(stale) + vim.pack.del(stale) + vim.notify( + string.format( + "Removed %d stale plugin%s: %s", + #stale, + #stale == 1 and "" or "s", + table.concat(stale, ", ") + ), + vim.log.levels.INFO + ) + end, + {} +) + if not NV_DARCULA_ENABLE_COC then vim.api.nvim_create_user_command( "LspInfo",