feat(health): added spec parsing errors to :checkhealth

This commit is contained in:
Folke Lemaitre 2022-12-30 11:52:09 +01:00
commit 32511a1214
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 41 additions and 10 deletions

View file

@ -1,5 +1,6 @@
local Util = require("lazy.util")
local Config = require("lazy.core.config")
local Plugin = require("lazy.core.plugin")
local M = {}
@ -48,7 +49,8 @@ function M.check()
"cond",
"_",
}
for _, plugin in pairs(Config.plugins) do
local spec = Plugin.spec({ show_errors = false })
for _, plugin in pairs(spec.plugins) do
for key in pairs(plugin) do
if not vim.tbl_contains(valid, key) then
if key ~= "module" or type(plugin.module) ~= "boolean" then
@ -57,6 +59,15 @@ function M.check()
end
end
end
if #spec.errors > 0 then
vim.health.report_error("Errors were reported when loading your specs:")
for _, error in ipairs(spec.errors) do
local lines = vim.split(error, "\n")
for _, line in ipairs(lines) do
vim.health.report_error(line)
end
end
end
end
return M