fix(lsp): raise error when lsp config is invalid type (#37508)

This commit is contained in:
Olivia Kinnear
2026-01-22 17:44:04 -06:00
committed by GitHub
parent 34116bbd9b
commit c39d18ee93
2 changed files with 7 additions and 5 deletions

View File

@@ -79,14 +79,16 @@ local function ex_lsp_enable(config_names)
if #config_names == 0 then
local filetype = vim.bo.filetype
for _, name in ipairs(get_config_names()) do
local config = lsp.config[name]
if config then
local filetypes = config.filetypes
local success, result = pcall(function()
return lsp.config[name]
end)
if success then
local filetypes = result.filetypes
if filetypes == nil or vim.list_contains(filetypes, filetype) then
table.insert(config_names, name)
end
else
echo_err(("Unable to check filetype for '%s': Broken config"):format(name))
echo_err(result --[[@as string]])
end
end
if #config_names == 0 then

View File

@@ -364,7 +364,7 @@ lsp.config = setmetatable({ _configs = {} }, {
--- @type vim.lsp.Config?
rtp_config = vim.tbl_deep_extend('force', rtp_config or {}, config)
else
log.warn(('%s does not return a table, ignoring'):format(v))
error(('%s: not a table'):format(v))
end
end