fix(lsp): handle non-existent configs in lsp.config/enable

This commit is contained in:
Lewis Russell
2025-03-08 10:15:43 +00:00
committed by Lewis Russell
parent c63e794b10
commit ed07167261
3 changed files with 92 additions and 31 deletions

View File

@@ -6370,5 +6370,35 @@ describe('LSP', function()
)
end)
end)
it('validates config on attach', function()
local tmp1 = t.tmpname(true)
exec_lua(function()
vim.lsp.log._set_filename(fake_lsp_logfile)
end)
local function test_cfg(cfg, err)
exec_lua(function()
vim.lsp.config['foo'] = {}
vim.lsp.config('foo', cfg)
vim.lsp.enable('foo')
vim.cmd.edit(assert(tmp1))
vim.bo.filetype = 'foo'
end)
retry(nil, 1000, function()
assert_log(err, fake_lsp_logfile)
end)
end
test_cfg({
cmd = { 'lolling' },
}, 'cannot start foo due to config error: .* lolling is not executable')
test_cfg({
cmd = { 'cat' },
filetypes = true,
}, 'cannot start foo due to config error: .* filetypes: expected table, got boolean')
end)
end)
end)