fix(loader): dont autoload when lazy handlers have not been setup yet. Fixes #1132

This commit is contained in:
Folke Lemaitre 2023-10-17 17:44:14 +02:00
parent c059eece0c
commit daab5fe280
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 7 additions and 4 deletions

View File

@ -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
@ -56,6 +57,7 @@ function M.setup()
-- setup handlers
Util.track("handlers")
Handler.setup()
M.did_handlers = true
Util.track()
end
@ -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
@ -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