mirror of https://github.com/folke/lazy.nvim.git
feat: added `module=false` to skip auto-loading of plugins on `require`
This commit is contained in:
parent
55d194cf9c
commit
1efa710210
|
@ -108,6 +108,9 @@ module of plugin `A`, then plugin `A` will be loaded on demand as expected.
|
||||||
|
|
||||||
You can configure **lazy.nvim** to lazy-load all plugins by default with `config.defaults.lazy = true`.
|
You can configure **lazy.nvim** to lazy-load all plugins by default with `config.defaults.lazy = true`.
|
||||||
|
|
||||||
|
If you don't want this behavior for a certain plugin, you can specify that with `module=false`.
|
||||||
|
You can then manually load the plugin with `:Lazy load foobar.nvim`.
|
||||||
|
|
||||||
Additionally, you can also lazy-load on **events**, **commands**,
|
Additionally, you can also lazy-load on **events**, **commands**,
|
||||||
**file types** and **key mappings**.
|
**file types** and **key mappings**.
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ end
|
||||||
function M.autoload(modname)
|
function M.autoload(modname)
|
||||||
-- check if a lazy plugin should be loaded
|
-- check if a lazy plugin should be loaded
|
||||||
for _, plugin in pairs(Config.plugins) do
|
for _, plugin in pairs(Config.plugins) do
|
||||||
if not plugin._.loaded then
|
if not (plugin._.loaded or plugin.module == false) then
|
||||||
for _, pattern in ipairs({ ".lua", "/init.lua" }) do
|
for _, pattern in ipairs({ ".lua", "/init.lua" }) do
|
||||||
local path = plugin.dir .. "/lua/" .. modname:gsub("%.", "/") .. pattern
|
local path = plugin.dir .. "/lua/" .. modname:gsub("%.", "/") .. pattern
|
||||||
if vim.loop.fs_stat(path) then
|
if vim.loop.fs_stat(path) then
|
||||||
|
|
|
@ -26,6 +26,7 @@ local M = {}
|
||||||
---@field cmd? string[]
|
---@field cmd? string[]
|
||||||
---@field ft? string[]
|
---@field ft? string[]
|
||||||
---@field keys? string[]
|
---@field keys? string[]
|
||||||
|
---@field module? false
|
||||||
|
|
||||||
---@class LazyPluginRef
|
---@class LazyPluginRef
|
||||||
---@field branch? string
|
---@field branch? string
|
||||||
|
|
Loading…
Reference in New Issue