aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Ekre <ekrefredrik@gmail.com>2022-04-15 11:12:41 +0200
committerGitHub <noreply@github.com>2022-04-15 11:12:41 +0200
commit6160973f36b532b6f9ff2cd7c20958fd791f2e2a (patch)
tree51d29fa69c082a596f32bad154451e938e8000b2
parent8486c87e58beb4c88957398db1890e0836a0c75e (diff)
downloadrneovim-6160973f36b532b6f9ff2cd7c20958fd791f2e2a.tar.gz
rneovim-6160973f36b532b6f9ff2cd7c20958fd791f2e2a.tar.bz2
rneovim-6160973f36b532b6f9ff2cd7c20958fd791f2e2a.zip
fix(lsp): fix lookup of boolean values in workspace/configuration (#18026)
-rw-r--r--runtime/lua/vim/lsp/handlers.lua2
-rw-r--r--runtime/lua/vim/lsp/util.lua4
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua4
-rw-r--r--test/functional/plugin/lsp_spec.lua3
4 files changed, 9 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index f5aefd4402..9871f00677 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -141,7 +141,7 @@ M['workspace/configuration'] = function(_, result, ctx)
local response = {}
for _, item in ipairs(result.items) do
if item.section then
- local value = util.lookup_section(client.config.settings, item.section) or vim.NIL
+ local value = util.lookup_section(client.config.settings, item.section)
-- For empty sections with no explicit '' key, return settings as is
if value == vim.NIL and item.section == '' then
value = client.config.settings or vim.NIL
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 401dac9acd..30587afb38 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1950,8 +1950,8 @@ end
function M.lookup_section(settings, section)
for part in vim.gsplit(section, '.', true) do
settings = settings[part]
- if not settings then
- return
+ if settings == nil then
+ return vim.NIL
end
end
return settings
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index 5c0de50731..7ff3713d41 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -119,8 +119,10 @@ function tests.check_workspace_configuration()
notify('workspace/configuration', { items = {
{ section = "testSetting1" };
{ section = "testSetting2" };
+ { section = "test.Setting3" };
+ { section = "test.Setting4" };
} })
- expect_notification('workspace/configuration', { true; vim.NIL})
+ expect_notification('workspace/configuration', { true; false; 'nested'; vim.NIL})
notify('shutdown')
end;
}
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 6cda9af0f4..436b431e38 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -347,6 +347,8 @@ describe('LSP', function()
{NIL, { items = {
{ section = "testSetting1" };
{ section = "testSetting2" };
+ { section = "test.Setting3" };
+ { section = "test.Setting4" };
}}, { method="workspace/configuration", client_id=1}};
{NIL, {}, {method="start", client_id=1}};
}
@@ -368,6 +370,7 @@ describe('LSP', function()
client.config.settings = {
testSetting1 = true;
testSetting2 = false;
+ test = {Setting3 = 'nested' };
}]=])
end
if ctx.method == 'workspace/configuration' then