Skip to content

Commit

Permalink
fix(loader): add proper error message when trying to load a plugin th…
Browse files Browse the repository at this point in the history
…at doesn't exist. Fixes #160
  • Loading branch information
folke committed Dec 25, 2022
1 parent e632eb4 commit 9095223
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lua/lazy/core/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,20 @@ function M.load(plugins, reason)
---@cast plugins (string|LazyPlugin)[]

for _, plugin in pairs(plugins) do
plugin = type(plugin) == "string" and Config.plugins[plugin] or plugin
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
plugin = Config.plugins[plugin]
end
end

---@cast plugin LazyPlugin

if not plugin._.loaded then
if try_load and not plugin._.loaded then
---@diagnostic disable-next-line: assign-type-mismatch
plugin._.loaded = {}
for k, v in pairs(reason) do
Expand All @@ -137,7 +147,9 @@ function M.load(plugins, reason)
end

if plugin.dependencies then
M.load(plugin.dependencies, {})
Util.try(function()
M.load(plugin.dependencies, {})
end, "Failed to load deps for " .. plugin.name)
end

M.packadd(plugin.dir)
Expand Down

0 comments on commit 9095223

Please sign in to comment.