Skip to content

Commit 9095223

Browse files
committedDec 25, 2022
fix(loader): add proper error message when trying to load a plugin that doesn't exist. Fixes #160
1 parent e632eb4 commit 9095223

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎lua/lazy/core/loader.lua

+15-3
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,20 @@ function M.load(plugins, reason)
110110
---@cast plugins (string|LazyPlugin)[]
111111

112112
for _, plugin in pairs(plugins) do
113-
plugin = type(plugin) == "string" and Config.plugins[plugin] or plugin
113+
local try_load = true
114+
115+
if type(plugin) == "string" then
116+
if not Config.plugins[plugin] then
117+
Util.error("Plugin " .. plugin .. " not found")
118+
try_load = false
119+
else
120+
plugin = Config.plugins[plugin]
121+
end
122+
end
123+
114124
---@cast plugin LazyPlugin
115125

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

139149
if plugin.dependencies then
140-
M.load(plugin.dependencies, {})
150+
Util.try(function()
151+
M.load(plugin.dependencies, {})
152+
end, "Failed to load deps for " .. plugin.name)
141153
end
142154

143155
M.packadd(plugin.dir)

0 commit comments

Comments
 (0)
Please sign in to comment.