From f91203e4f62594fcd2d0d9780aa2e5ff1975eced Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 10:52:52 +0200 Subject: [PATCH] fix(plugin): ignore any installed deps of a disabled conditional plugin. Fixes #1053 --- lua/lazy/core/plugin.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index c78f327..00039ef 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -11,6 +11,7 @@ M.loading = false ---@field fragments table ---@field disabled table ---@field dirty table +---@field ignore_installed table ---@field modules string[] ---@field notifs {msg:string, level:number, file?:string}[] ---@field importing? string @@ -30,6 +31,7 @@ function Spec.new(spec, opts) self.modules = {} self.dirty = {} self.notifs = {} + self.ignore_installed = {} self.optional = opts and opts.optional if spec then self:parse(spec) @@ -247,6 +249,14 @@ function Spec:fix_cond() end if cond == false or (type(cond) == "function" and not cond(plugin)) then plugin._.cond = false + local stack = { plugin } + while #stack > 0 do + local p = table.remove(stack) + for _, dep in ipairs(p.dependencies or {}) do + table.insert(stack, self.plugins[dep]) + end + self.ignore_installed[p.name] = true + end plugin.enabled = false end end @@ -469,10 +479,8 @@ function M.update_state() end end - for _, plugin in pairs(Config.spec.disabled) do - if plugin._.cond == false then - installed[plugin.name] = nil - end + for name in pairs(Config.spec.ignore_installed) do + installed[name] = nil end Config.to_clean = {}