mirror of
https://github.com/neovim/neovim.git
synced 2026-02-17 18:01:16 +10:00
fix(lsp): support workspace/configuation with no section #27510
The [spec for `workspace/configuration`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration) marks the `section` property of each item in `items` optional. Therefore, I believe it violates the spec to skip over items without a section, because then the length of the results won't match the length of a valid `items` input. The spec does not elaborate on _what_ to return in this case, but I don't think it would be controversial to say that returning the full configuration, as done for an empty string, is the most natural interpretation. That empty string case, by the way, was initially [added in response](5da124fc82) to a real world implementation requesting it. I don't have a similar real world implementation to point to for the omitted `section`, but I would note that `getConfiguration()` from `vscode-languageserver-node` [defaults to a request with no section](d859bb14d1/server/src/common/configuration.ts (L24-L26)) when called with no arguments. I surmise that this is intended as a way to retrieve the full configuration.
This commit is contained in:
@@ -230,6 +230,9 @@ RSC['workspace/configuration'] = function(_, params, ctx)
|
||||
value = vim.NIL
|
||||
end
|
||||
table.insert(response, value)
|
||||
else
|
||||
-- If no section is provided, return settings as is
|
||||
table.insert(response, client.settings)
|
||||
end
|
||||
end
|
||||
return response
|
||||
|
||||
@@ -150,9 +150,16 @@ function tests.check_workspace_configuration()
|
||||
{ section = 'testSetting2' },
|
||||
{ section = 'test.Setting3' },
|
||||
{ section = 'test.Setting4' },
|
||||
{},
|
||||
{ section = '' },
|
||||
},
|
||||
})
|
||||
expect_notification('workspace/configuration', { true, false, 'nested', vim.NIL })
|
||||
local all = {
|
||||
testSetting1 = true,
|
||||
testSetting2 = false,
|
||||
test = { Setting3 = 'nested' },
|
||||
}
|
||||
expect_notification('workspace/configuration', { true, false, 'nested', vim.NIL, all, all })
|
||||
notify('shutdown')
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -681,6 +681,8 @@ describe('LSP', function()
|
||||
{ section = 'testSetting2' },
|
||||
{ section = 'test.Setting3' },
|
||||
{ section = 'test.Setting4' },
|
||||
{},
|
||||
{ section = '' },
|
||||
},
|
||||
},
|
||||
{ method = 'workspace/configuration', client_id = 1 },
|
||||
|
||||
Reference in New Issue
Block a user