mirror of https://github.com/folke/lazy.nvim.git
fix(loader): show proper error message when trying to load a plugin that is not installed. Fixes #201. Fixes #202
This commit is contained in:
parent
5f423b29c6
commit
956164d27d
|
@ -131,25 +131,34 @@ function M.load(plugins, reason)
|
|||
---@cast plugins (string|LazyPlugin)[]
|
||||
|
||||
for _, plugin in pairs(plugins) do
|
||||
local try_load = true
|
||||
|
||||
if type(plugin) == "string" then
|
||||
if not Config.plugins[plugin] then
|
||||
Util.error("Plugin " .. plugin .. " not found")
|
||||
try_load = false
|
||||
else
|
||||
if Config.plugins[plugin] then
|
||||
plugin = Config.plugins[plugin]
|
||||
else
|
||||
Util.error("Plugin " .. plugin .. " not found")
|
||||
plugin = nil
|
||||
end
|
||||
end
|
||||
if plugin and not plugin._.loaded then
|
||||
M._load(plugin, reason)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param plugin LazyPlugin
|
||||
---@param reason {[string]:string}
|
||||
function M._load(plugin, reason)
|
||||
if not plugin._.installed then
|
||||
return Util.error("Plugin " .. plugin.name .. " is not installed")
|
||||
end
|
||||
|
||||
if plugin.cond ~= nil then
|
||||
if plugin.cond == false or (type(plugin.cond) == "function" and not plugin.cond()) then
|
||||
plugin._.cond = false
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if try_load and plugin.cond then
|
||||
try_load = plugin.cond == true or (type(plugin.cond) == "function" and plugin.cond()) or false
|
||||
plugin._.cond = try_load
|
||||
end
|
||||
|
||||
---@cast plugin LazyPlugin
|
||||
|
||||
if try_load and not plugin._.loaded then
|
||||
---@diagnostic disable-next-line: assign-type-mismatch
|
||||
plugin._.loaded = {}
|
||||
for k, v in pairs(reason) do
|
||||
|
@ -188,8 +197,6 @@ function M.load(plugins, reason)
|
|||
vim.schedule(function()
|
||||
vim.cmd("do User LazyRender")
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- runs plugin config
|
||||
|
|
Loading…
Reference in New Issue