From 0bc73db503e550076c0a8effb976a778c7cf5a6a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 2 Jan 2023 12:54:38 +0100 Subject: [PATCH] fix(cache): only autoload when plugins have been parsed. Needed to support `import` --- lua/lazy/core/cache.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lua/lazy/core/cache.lua b/lua/lazy/core/cache.lua index e825b245..2207f8f2 100644 --- a/lua/lazy/core/cache.lua +++ b/lua/lazy/core/cache.lua @@ -81,11 +81,14 @@ function M.check_autoload(modname, modpath) if plugin and modpath:find(plugin.dir, 1, true) == 1 then -- we're not interested in loader time, so calculate delta here M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start - if not plugin._.loaded then - if plugin.module == false then - error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false") + -- only autoload when plugins have been loaded + if #require("lazy.core.config").plugins > 0 then + if not plugin._.loaded then + if plugin.module == false then + error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false") + end + require("lazy.core.loader").load(plugin, { require = modname }) end - require("lazy.core.loader").load(plugin, { require = modname }) end return true end