From 3f63100d5bc3bcaddccef4e5f95af9ea5cff1cc3 Mon Sep 17 00:00:00 2001 From: Mathias Fußenegger Date: Mon, 18 Jan 2021 19:33:10 +0100 Subject: 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. --- runtime/lua/vim/lsp.lua | 2 ++ runtime/lua/vim/lsp/handlers.lua | 1 + 2 files changed, 3 insertions(+) (limited to 'runtime/lua') diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 9e05eeae89..27fc4a2ab5 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -229,6 +229,7 @@ local function validate_client_config(config) before_init = { config.before_init, "f", true }; offset_encoding = { config.offset_encoding, "s", true }; flags = { config.flags, "t", true }; + settings = { config.settings, "t", true }; } -- TODO(remove-callbacks) @@ -458,6 +459,7 @@ function lsp.start_client(config) local cmd, cmd_args, offset_encoding = cleaned_config.cmd, cleaned_config.cmd_args, cleaned_config.offset_encoding config.flags = config.flags or {} + config.settings = config.settings or {} local client_id = next_client_id() diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index b4a1eff316..7eac3febd9 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -162,6 +162,7 @@ M['workspace/configuration'] = function(err, _, params, client_id) local client = vim.lsp.get_client_by_id(client_id) if not client then err_message("LSP[id=", client_id, "] client has shut down after sending the message") + return end if err then error(vim.inspect(err)) end if not params.items then -- cgit