feat(plugin): added support for `cond` for imports (#1079)

Co-authored-by: abeldekat <abel@nomail.com>
This commit is contained in:
abeldekat 2023-10-06 15:46:46 +02:00 committed by GitHub
parent acda8d29ca
commit 58e954a735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -380,6 +380,9 @@ function Spec:import(spec)
if vim.tbl_contains(self.modules, spec.import) then if vim.tbl_contains(self.modules, spec.import) then
return return
end 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 if spec.enabled == false or (type(spec.enabled) == "function" and not spec.enabled()) then
return return
end end

View File

@ -75,3 +75,4 @@
---@class LazySpecImport ---@class LazySpecImport
---@field import string spec module to import ---@field import string spec module to import
---@field enabled? boolean|(fun():boolean) ---@field enabled? boolean|(fun():boolean)
---@field cond? boolean|(fun():boolean)