Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 330dbe7

Browse files
committedDec 2, 2022
feat: Plugin.specs() can now reload and keeps existing state
1 parent ebf15fc commit 330dbe7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

Diff for: ‎lua/lazy/core/plugin.lua

+8
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ function M.spec()
188188
-- spec is a module
189189
local function _load(name)
190190
local modname = name and (Config.spec .. "." .. name) or Config.spec
191+
package.loaded[modname] = nil
191192
Util.try(function()
192193
spec:normalize(require(modname))
193194
end, "Failed to load **" .. modname .. "**")
@@ -212,7 +213,14 @@ function M.load()
212213
spec.plugins["lazy.nvim"] = nil
213214
spec:add({ "folke/lazy.nvim", lazy = true })
214215

216+
local existing = Config.plugins
215217
Config.plugins = spec.plugins
218+
-- copy state. This wont do anything during startup
219+
for name, plugin in pairs(existing) do
220+
if Config.plugins[name] then
221+
Config.plugins[name]._ = plugin._
222+
end
223+
end
216224
Util.track()
217225

218226
Util.track("state")

0 commit comments

Comments
 (0)
Please sign in to comment.