From beeafc64563f9974ca09ff3518aafc7557de8f3a Mon Sep 17 00:00:00 2001 From: abeldekat Date: Fri, 6 Oct 2023 12:40:13 +0200 Subject: [PATCH] feat: when a plugin is disabled conditionally, do not import its additional plugin modules. --- lua/lazy/core/plugin.lua | 3 +++ lua/lazy/types.lua | 1 + 2 files changed, 4 insertions(+) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 95a21ec..12ba1a8 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -380,6 +380,9 @@ function Spec:import(spec) if vim.tbl_contains(self.modules, spec.import) then return end + if spec.cond == false or (type(spec.cond) == "function" and not spec.cond()) then + return + end if spec.enabled == false or (type(spec.enabled) == "function" and not spec.enabled()) then return end diff --git a/lua/lazy/types.lua b/lua/lazy/types.lua index e9c5fbb..30363b6 100644 --- a/lua/lazy/types.lua +++ b/lua/lazy/types.lua @@ -75,3 +75,4 @@ ---@class LazySpecImport ---@field import string spec module to import ---@field enabled? boolean|(fun():boolean) +---@field cond? boolean|(fun():boolean)