mirror of https://github.com/folke/lazy.nvim.git
docs: added docs on optional
This commit is contained in:
parent
b1ad64a73e
commit
b0aa5348d8
|
@ -107,6 +107,7 @@ require("lazy").setup({
|
||||||
| **keys** | `string?` or `string[]` or `LazyKeys[]` or `fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]` | Lazy-load on key mapping |
|
| **keys** | `string?` or `string[]` or `LazyKeys[]` or `fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]` | Lazy-load on key mapping |
|
||||||
| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
|
| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
|
||||||
| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
|
| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
|
||||||
|
| **optional** | `boolean?` | When a spec is tagged optional, it will only be included in the final spec, when the same plugin has been specified at least once somewhere else without `optional`. This is mainly useful for Neovim distros, to allow setting options on plugins that may/may not be part of the user's plugins |
|
||||||
|
|
||||||
### Lazy Loading
|
### Lazy Loading
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,19 @@ M.loading = false
|
||||||
---@field modules string[]
|
---@field modules string[]
|
||||||
---@field notifs {msg:string, level:number, file?:string}[]
|
---@field notifs {msg:string, level:number, file?:string}[]
|
||||||
---@field importing? string
|
---@field importing? string
|
||||||
|
---@field optional? boolean
|
||||||
local Spec = {}
|
local Spec = {}
|
||||||
M.Spec = Spec
|
M.Spec = Spec
|
||||||
|
|
||||||
---@param spec? LazySpec
|
---@param spec? LazySpec
|
||||||
function Spec.new(spec)
|
---@param opts? {optional?:boolean}
|
||||||
|
function Spec.new(spec, opts)
|
||||||
local self = setmetatable({}, { __index = Spec })
|
local self = setmetatable({}, { __index = Spec })
|
||||||
self.plugins = {}
|
self.plugins = {}
|
||||||
self.disabled = {}
|
self.disabled = {}
|
||||||
self.modules = {}
|
self.modules = {}
|
||||||
self.notifs = {}
|
self.notifs = {}
|
||||||
|
self.optional = opts and opts.optional
|
||||||
if spec then
|
if spec then
|
||||||
self:parse(spec)
|
self:parse(spec)
|
||||||
end
|
end
|
||||||
|
@ -141,6 +144,7 @@ function Spec:warn(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Spec:fix_disabled()
|
function Spec:fix_disabled()
|
||||||
|
if not self.optional then
|
||||||
---@param plugin LazyPlugin
|
---@param plugin LazyPlugin
|
||||||
local function all_optional(plugin)
|
local function all_optional(plugin)
|
||||||
return (not plugin) or (rawget(plugin, "optional") and all_optional(plugin._.super))
|
return (not plugin) or (rawget(plugin, "optional") and all_optional(plugin._.super))
|
||||||
|
@ -152,6 +156,7 @@ function Spec:fix_disabled()
|
||||||
self.plugins[plugin.name] = nil
|
self.plugins[plugin.name] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---@type table<string,string[]> plugin to parent plugin
|
---@type table<string,string[]> plugin to parent plugin
|
||||||
local dep_of = {}
|
local dep_of = {}
|
||||||
|
|
Loading…
Reference in New Issue