diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index 69f2b3e..25f1c57 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -227,10 +227,18 @@ function M.deactivate(plugin) end --- reload a plugin ----@param plugin LazyPlugin +---@param plugin LazyPlugin|string function M.reload(plugin) + if type(plugin) == "string" then + plugin = Config.plugins[plugin] + end + + if not plugin then + error("Plugin not found") + end + + local load = plugin._.loaded ~= nil M.deactivate(plugin) - local load = false -- plugin._.loaded ~= nil -- enable handlers Handler.enable(plugin) diff --git a/lua/lazy/view/commands.lua b/lua/lazy/view/commands.lua index 3b81e6b..1fa7cc1 100644 --- a/lua/lazy/view/commands.lua +++ b/lua/lazy/view/commands.lua @@ -53,6 +53,12 @@ M.commands = { -- when a command is executed with a bang, wait will be set require("lazy.core.loader").load(opts.plugins, { cmd = "Lazy load" }, { force = opts.wait }) end, + reload = function(opts) + for _, plugin in pairs(opts.plugins) do + Util.warn("Reloading **" .. plugin.name .. "**") + require("lazy.core.loader").reload(plugin) + end + end, log = Manage.log, build = Manage.build, clean = Manage.clean, diff --git a/lua/lazy/view/config.lua b/lua/lazy/view/config.lua index 0e7dbf6..cf7df1c 100644 --- a/lua/lazy/view/config.lua +++ b/lua/lazy/view/config.lua @@ -143,11 +143,17 @@ M.commands = { }, build = { desc = "Rebuild a plugin", - id = 13, + id = 15, plugins = true, plugins_required = true, key_plugin = "gb", }, + reload = { + desc = "Reload a plugin (experimental!!)", + plugins = true, + plugins_required = true, + id = 16, + }, } return M