mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(plugin): added config.defaults.cond. Fixes #640
This commit is contained in:
parent
10f5844abf
commit
9afba388fa
3 changed files with 13 additions and 3 deletions
|
@ -9,6 +9,9 @@ M.defaults = {
|
|||
defaults = {
|
||||
lazy = false, -- should plugins be lazy-loaded?
|
||||
version = nil,
|
||||
-- default `cond` you can use to globally disable a lot of plugins
|
||||
-- when running inside vscode for example
|
||||
cond = nil, ---@type boolean|fun(self:LazyPlugin):boolean|nil
|
||||
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
||||
},
|
||||
-- leave nil when passing the spec as the first argument to setup()
|
||||
|
|
|
@ -266,8 +266,12 @@ function M._load(plugin, reason, opts)
|
|||
return Util.error("Plugin " .. plugin.name .. " is not installed")
|
||||
end
|
||||
|
||||
if plugin.cond ~= nil and not (opts and opts.force) then
|
||||
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
|
||||
local cond = plugin.cond
|
||||
if cond == nil then
|
||||
cond = Config.options.defaults.cond
|
||||
end
|
||||
if cond ~= nil and not (opts and opts.force) then
|
||||
if cond == false or (type(cond) == "function" and not cond(plugin)) then
|
||||
plugin._.cond = false
|
||||
return
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue