From 34116bbd9b61ec78233b86dcadec6eb5eaf1571d Mon Sep 17 00:00:00 2001 From: Olivia Kinnear Date: Thu, 22 Jan 2026 14:27:03 -0600 Subject: [PATCH] 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`. --- runtime/lua/vim/_core/ex_cmd.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/lua/vim/_core/ex_cmd.lua b/runtime/lua/vim/_core/ex_cmd.lua index 0b5189cae8..75cd253801 100644 --- a/runtime/lua/vim/_core/ex_cmd.lua +++ b/runtime/lua/vim/_core/ex_cmd.lua @@ -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