feat(spec): show spec warnings in checkhealth only

This commit is contained in:
Folke Lemaitre 2023-01-02 12:53:35 +01:00
parent d992387912
commit bc4133cb3e
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 9 additions and 6 deletions

View File

@ -93,11 +93,14 @@ function Spec:log(msg, level)
self.notifs[#self.notifs + 1] = { msg = msg, level = level, file = self.importing } self.notifs[#self.notifs + 1] = { msg = msg, level = level, file = self.importing }
end end
function Spec:report() function Spec:report(level)
level = level or vim.log.levels.ERROR
for _, notif in ipairs(self.notifs) do for _, notif in ipairs(self.notifs) do
if notif.level >= level then
Util.notify(notif.msg, notif.level) Util.notify(notif.msg, notif.level)
end end
end end
end
---@param spec LazySpec|LazySpecImport ---@param spec LazySpec|LazySpecImport
---@param results? string[] ---@param results? string[]
@ -145,6 +148,7 @@ function Spec:import(spec)
end end
Cache.indexed_unloaded = false Cache.indexed_unloaded = false
self.modules[#self.modules + 1] = spec.import
local imported = 0 local imported = 0
Util.lsmod(spec.import, function(modname) Util.lsmod(spec.import, function(modname)
@ -155,8 +159,7 @@ function Spec:import(spec)
---@diagnostic disable-next-line: no-unknown ---@diagnostic disable-next-line: no-unknown
package.loaded[modname] = nil package.loaded[modname] = nil
Util.try(function() Util.try(function()
self:normalize(Cache.require(modname)) self:normalize(require(modname))
self.modules[#self.modules + 1] = modname
self.importing = nil self.importing = nil
Util.track() Util.track()
end, { end, {
@ -198,7 +201,7 @@ function Spec:merge(old, new)
end end
else else
old[k] = v old[k] = v
self:error("Merging plugins is not supported for key `" .. k .. "`\n" .. vim.inspect({ old = old, new = new })) self:warn("Overwriting key `" .. k .. "`\n" .. vim.inspect({ old = old, new = new }))
end end
else else
---@diagnostic disable-next-line: no-unknown ---@diagnostic disable-next-line: no-unknown
@ -295,7 +298,7 @@ function M.find(path)
local slash = name:reverse():find("/", 1, true) local slash = name:reverse():find("/", 1, true)
if slash then if slash then
name = name:sub(#name - slash + 2) name = name:sub(#name - slash + 2)
return name and Config.plugins[name] or nil return name and Config.spec.plugins[name] or nil
end end
end end
end end