commit c39d18ee939cba5f905416fcc97661b1836f4de4
parent 34116bbd9b61ec78233b86dcadec6eb5eaf1571d
Author: Olivia Kinnear <git@superatomic.dev>
Date: Thu, 22 Jan 2026 17:44:04 -0600
fix(lsp): raise error when lsp config is invalid type (#37508)
Diffstat:
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/runtime/lua/vim/_core/ex_cmd.lua b/runtime/lua/vim/_core/ex_cmd.lua
@@ -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
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
@@ -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