Skip to content

Commit daab5fe

Browse files
committed
fix(loader): dont autoload when lazy handlers have not been setup yet. Fixes #1132
1 parent c059eec commit daab5fe

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lua/lazy/core/loader.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ M.init_done = false
1616
M.disabled_rtp_plugins = { packer_compiled = true }
1717
---@type table<string,string>
1818
M.did_ftdetect = {}
19+
M.did_handlers = false
1920

2021
function M.disable_rtp_plugin(plugin)
2122
M.disabled_rtp_plugins[plugin] = true
@@ -56,6 +57,7 @@ function M.setup()
5657
-- setup handlers
5758
Util.track("handlers")
5859
Handler.setup()
60+
M.did_handlers = true
5961
Util.track()
6062
end
6163

@@ -498,8 +500,11 @@ function M.auto_load(modname, modpath)
498500
local plugin = Plugin.find(modpath)
499501
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
500502
plugin._.rtp_loaded = true
501-
-- don't load if we're loading specs or if the plugin is already loaded
502-
if not (Plugin.loading or plugin._.loaded) then
503+
-- don't load if:
504+
-- * handlers haven't been setup yet
505+
-- * we're loading specs
506+
-- * the plugin is already loaded
507+
if M.did_handlers and not (Plugin.loading or plugin._.loaded) then
503508
if plugin.module == false then
504509
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
505510
end
@@ -508,9 +513,7 @@ function M.auto_load(modname, modpath)
508513
error("You're trying to load `" .. plugin.name .. "` for which `cond==false`")
509514
end
510515
end
511-
return true
512516
end
513-
return false
514517
end
515518

516519
---@param modname string

0 commit comments

Comments
 (0)