mirror of
https://github.com/neovim/neovim.git
synced 2026-05-03 12:35:00 +00:00
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:
@@ -79,9 +79,14 @@ local function ex_lsp_enable(config_names)
|
|||||||
if #config_names == 0 then
|
if #config_names == 0 then
|
||||||
local filetype = vim.bo.filetype
|
local filetype = vim.bo.filetype
|
||||||
for _, name in ipairs(get_config_names()) do
|
for _, name in ipairs(get_config_names()) do
|
||||||
local filetypes = lsp.config[name].filetypes
|
local config = lsp.config[name]
|
||||||
if filetypes == nil or vim.list_contains(filetypes, filetype) then
|
if config then
|
||||||
table.insert(config_names, name)
|
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
|
||||||
end
|
end
|
||||||
if #config_names == 0 then
|
if #config_names == 0 then
|
||||||
|
|||||||
Reference in New Issue
Block a user