LSP: Fix nil settings handling in workspace/configuration (#13708)

The `workspace/configuration` handler could fail with the following
error if `config.settings` is nil:

    runtime/lua/vim/lsp/util.lua:1432: attempt to index local 'settings' (a nil value)"

This ensures that `config.settings` is always initialized to an empty
table.
This commit is contained in:
Mathias Fußenegger
2021-01-18 19:33:10 +01:00
committed by GitHub
parent 51936126d3
commit 3f63100d5b
3 changed files with 18 additions and 0 deletions

View File

@@ -303,6 +303,21 @@ describe('LSP', function()
end;
}
end)
it('workspace/configuration returns NIL per section if client was started without config.settings', function()
fake_lsp_server_setup('workspace/configuration no settings')
eq({
NIL,
NIL,
}, exec_lua [[
local params = {
items = {
{section = 'foo'},
{section = 'bar'},
}
}
return vim.lsp.handlers['workspace/configuration'](nil, nil, params, TEST_RPC_CLIENT_ID)
]])
end)
it('should verify capabilities sent', function()
local expected_callbacks = {