From 58e954a735767fd23c24c455dc09c5323951ec83 Mon Sep 17 00:00:00 2001 From: abeldekat <58370433+abeldekat@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:46:46 +0200 Subject: [PATCH] feat(plugin): added support for `cond` for imports (#1079) Co-authored-by: abeldekat --- 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)