mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(lsp): warn on missing config in :checkhealth #33087
Problem When calling `:checkhealth vim.lsp` after the user has enabled a language server with `vim.lsp.enable` that has no configuration a runtime error is hit because the code expects for a configuration to exist. Solution: Check if a configuration was returned before parsing it, if it isn't returned then warn the user that the server has been enabled but a configuration was not found.
This commit is contained in:
@@ -187,6 +187,11 @@ local function check_enabled_configs()
|
|||||||
local config = vim.lsp.config[name]
|
local config = vim.lsp.config[name]
|
||||||
local text = {} --- @type string[]
|
local text = {} --- @type string[]
|
||||||
text[#text + 1] = ('%s:'):format(name)
|
text[#text + 1] = ('%s:'):format(name)
|
||||||
|
if not config then
|
||||||
|
report_warn(
|
||||||
|
("'%s' config not found. Ensure that vim.lsp.config('%s') was called."):format(name, name)
|
||||||
|
)
|
||||||
|
else
|
||||||
for k, v in
|
for k, v in
|
||||||
vim.spairs(config --[[@as table<string,any>]])
|
vim.spairs(config --[[@as table<string,any>]])
|
||||||
do
|
do
|
||||||
@@ -209,6 +214,7 @@ local function check_enabled_configs()
|
|||||||
text[#text + 1] = ('- %s: %s'):format(k, v_str)
|
text[#text + 1] = ('- %s: %s'):format(k, v_str)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
text[#text + 1] = ''
|
text[#text + 1] = ''
|
||||||
report_info(table.concat(text, '\n'))
|
report_info(table.concat(text, '\n'))
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user