Skip to content

Commit

Permalink
fix(loader): dont autoload when lazy handlers have not been setup yet.
Browse files Browse the repository at this point in the history
…Fixes #1132
  • Loading branch information
folke committed Oct 17, 2023
1 parent c059eec commit daab5fe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ M.init_done = false
M.disabled_rtp_plugins = { packer_compiled = true }
---@type table<string,string>
M.did_ftdetect = {}
M.did_handlers = false

function M.disable_rtp_plugin(plugin)
M.disabled_rtp_plugins[plugin] = true
Expand Down Expand Up @@ -56,6 +57,7 @@ function M.setup()
-- setup handlers
Util.track("handlers")
Handler.setup()
M.did_handlers = true
Util.track()
end

Expand Down Expand Up @@ -498,8 +500,11 @@ function M.auto_load(modname, modpath)
local plugin = Plugin.find(modpath)
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
plugin._.rtp_loaded = true
-- don't load if we're loading specs or if the plugin is already loaded
if not (Plugin.loading or plugin._.loaded) then
-- don't load if:
-- * handlers haven't been setup yet
-- * we're loading specs
-- * the plugin is already loaded
if M.did_handlers and not (Plugin.loading or plugin._.loaded) then
if plugin.module == false then
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
end
Expand All @@ -508,9 +513,7 @@ function M.auto_load(modname, modpath)
error("You're trying to load `" .. plugin.name .. "` for which `cond==false`")
end
end
return true
end
return false
end

---@param modname string
Expand Down

0 comments on commit daab5fe

Please sign in to comment.