Skip to content

Commit

Permalink
feat: added module=false to skip auto-loading of plugins on require
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 19, 2022
1 parent 55d194c commit 1efa710
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

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**,
**file types** and **key mappings**.

Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ end
function M.autoload(modname)
-- check if a lazy plugin should be loaded
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
local path = plugin.dir .. "/lua/" .. modname:gsub("%.", "/") .. pattern
if vim.loop.fs_stat(path) then
Expand Down
1 change: 1 addition & 0 deletions lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local M = {}
---@field cmd? string[]
---@field ft? string[]
---@field keys? string[]
---@field module? false

---@class LazyPluginRef
---@field branch? string
Expand Down

0 comments on commit 1efa710

Please sign in to comment.