Skip to content

Commit 0bc73db

Browse files
committed
fix(cache): only autoload when plugins have been parsed. Needed to support import
1 parent f6b0172 commit 0bc73db

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lua/lazy/core/cache.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ function M.check_autoload(modname, modpath)
8181
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
8282
-- we're not interested in loader time, so calculate delta here
8383
M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
84-
if not plugin._.loaded then
85-
if plugin.module == false then
86-
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
84+
-- only autoload when plugins have been loaded
85+
if #require("lazy.core.config").plugins > 0 then
86+
if not plugin._.loaded then
87+
if plugin.module == false then
88+
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
89+
end
90+
require("lazy.core.loader").load(plugin, { require = modname })
8791
end
88-
require("lazy.core.loader").load(plugin, { require = modname })
8992
end
9093
return true
9194
end

0 commit comments

Comments
 (0)