feat(init): validate provider config eagerly in setup (#16)

This commit is contained in:
Barrett Ruth 2026-03-03 15:04:03 -05:00 committed by GitHub
parent 7ed4b61c98
commit 4c22f84b31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -85,6 +85,20 @@ function M.setup(opts)
end
end
for ft, provider in pairs(providers) do
local prefix = 'providers.' .. ft
vim.validate(prefix .. '.cmd', provider.cmd, 'table')
vim.validate(prefix .. '.cmd[1]', provider.cmd[1], 'string')
vim.validate(prefix .. '.args', provider.args, { 'table', 'function' }, true)
vim.validate(prefix .. '.cwd', provider.cwd, { 'string', 'function' }, true)
vim.validate(prefix .. '.output', provider.output, { 'string', 'function' }, true)
vim.validate(prefix .. '.error_parser', provider.error_parser, 'function', true)
vim.validate(prefix .. '.errors', provider.errors, function(x)
return x == nil or x == false or x == 'diagnostic' or x == 'quickfix'
end, 'false, "diagnostic", or "quickfix"')
vim.validate(prefix .. '.open', provider.open, { 'boolean', 'table' }, true)
end
config = vim.tbl_deep_extend('force', default_config, {
debug = debug,
providers = providers,