Skip to content

Commit

Permalink
feat: Plugin.specs() can now reload and keeps existing state
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 2, 2022
1 parent ebf15fc commit 330dbe7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ function M.spec()
-- spec is a module
local function _load(name)
local modname = name and (Config.spec .. "." .. name) or Config.spec
package.loaded[modname] = nil
Util.try(function()
spec:normalize(require(modname))
end, "Failed to load **" .. modname .. "**")
Expand All @@ -212,7 +213,14 @@ function M.load()
spec.plugins["lazy.nvim"] = nil
spec:add({ "folke/lazy.nvim", lazy = true })

local existing = Config.plugins
Config.plugins = spec.plugins
-- copy state. This wont do anything during startup
for name, plugin in pairs(existing) do
if Config.plugins[name] then
Config.plugins[name]._ = plugin._
end
end
Util.track()

Util.track("state")
Expand Down

0 comments on commit 330dbe7

Please sign in to comment.