From 330dbe72031e642d2cd04b671c6eb498d96e4b71 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 2 Dec 2022 17:02:25 +0100 Subject: [PATCH] feat: `Plugin.specs()` can now reload and keeps existing state --- lua/lazy/core/plugin.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 68d9873..ae04a80 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -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 .. "**") @@ -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")