mirror of https://github.com/folke/lazy.nvim.git
fix(loader): prevent loading plugins when loading specs
This commit is contained in:
parent
9d494e0594
commit
e1cd9cd0ad
|
@ -72,24 +72,22 @@ end
|
||||||
function M.check_autoload(modname, modpath)
|
function M.check_autoload(modname, modpath)
|
||||||
local start = uv.hrtime()
|
local start = uv.hrtime()
|
||||||
M.stats.autoload.total = M.stats.autoload.total + 1
|
M.stats.autoload.total = M.stats.autoload.total + 1
|
||||||
|
|
||||||
-- check plugins. Again fast, since we check the plugin name from the path.
|
-- check plugins. Again fast, since we check the plugin name from the path.
|
||||||
-- only needed when the plugin mod has been loaded
|
-- only needed when the plugin mod has been loaded
|
||||||
---@type LazyCorePlugin
|
---@type LazyCorePlugin
|
||||||
local Plugin = package.loaded["lazy.core.plugin"]
|
local Plugin = package.loaded["lazy.core.plugin"]
|
||||||
if Plugin then
|
if Plugin and not Plugin.loading then
|
||||||
local plugin = Plugin.find(modpath)
|
local plugin = Plugin.find(modpath)
|
||||||
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
|
if plugin and modpath:find(plugin.dir, 1, true) == 1 then
|
||||||
-- we're not interested in loader time, so calculate delta here
|
-- we're not interested in loader time, so calculate delta here
|
||||||
M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
|
M.stats.autoload.time = M.stats.autoload.time + uv.hrtime() - start
|
||||||
-- only autoload when plugins have been loaded
|
|
||||||
if not vim.tbl_isempty(require("lazy.core.config").plugins) then
|
|
||||||
if not plugin._.loaded then
|
if not plugin._.loaded then
|
||||||
if plugin.module == false then
|
if plugin.module == false then
|
||||||
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
|
error("Plugin " .. plugin.name .. " is not loaded and is configured with module=false")
|
||||||
end
|
end
|
||||||
require("lazy.core.loader").load(plugin, { require = modname })
|
require("lazy.core.loader").load(plugin, { require = modname })
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ local Cache = require("lazy.core.cache")
|
||||||
|
|
||||||
---@class LazyCorePlugin
|
---@class LazyCorePlugin
|
||||||
local M = {}
|
local M = {}
|
||||||
|
M.loading = false
|
||||||
|
|
||||||
local list_merge = { "dependencies" }
|
local list_merge = { "dependencies" }
|
||||||
vim.list_extend(list_merge, vim.tbl_values(Handler.types))
|
vim.list_extend(list_merge, vim.tbl_values(Handler.types))
|
||||||
|
@ -330,6 +331,7 @@ function M.update_state()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.load()
|
function M.load()
|
||||||
|
M.loading = true
|
||||||
-- load specs
|
-- load specs
|
||||||
Util.track("spec")
|
Util.track("spec")
|
||||||
Config.spec = Spec.new()
|
Config.spec = Spec.new()
|
||||||
|
@ -363,6 +365,7 @@ function M.load()
|
||||||
M.update_state()
|
M.update_state()
|
||||||
Util.track()
|
Util.track()
|
||||||
require("lazy.core.cache").indexed_unloaded = false
|
require("lazy.core.cache").indexed_unloaded = false
|
||||||
|
M.loading = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Finds the plugin that has this path
|
-- Finds the plugin that has this path
|
||||||
|
|
Loading…
Reference in New Issue