fix(lsp): fix nil-index error for :lsp enable (#37411)

Problem:
`:lsp enable` with no arguments will fail if there is a invalid config
in `lsp/`, or if `vim.lsp.config[...]` returns nil for any other reason.

Solution:
Add a nil-check to `:lsp enable`.
This commit is contained in:
Olivia Kinnear
2026-01-22 14:27:03 -06:00
committed by GitHub
parent e2bc84e315
commit 34116bbd9b

View File

@@ -79,9 +79,14 @@ 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 filetypes = lsp.config[name].filetypes
if filetypes == nil or vim.list_contains(filetypes, filetype) then
table.insert(config_names, name)
local config = lsp.config[name]
if config then
local filetypes = config.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))
end
end
if #config_names == 0 then