aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria José Solano <majosolano99@gmail.com>2024-02-25 12:45:39 -0800
committerLewis Russell <me@lewisr.dev>2024-02-28 20:20:02 +0000
commit853f647da618d2891e4ac513fb96d3c8a42fa131 (patch)
tree510e957f1d40ec8d5925cb1376c3471e793e4519
parentd981670bc9acd4cfd7b0768b8bc64390b026bf98 (diff)
downloadrneovim-853f647da618d2891e4ac513fb96d3c8a42fa131.tar.gz
rneovim-853f647da618d2891e4ac513fb96d3c8a42fa131.tar.bz2
rneovim-853f647da618d2891e4ac513fb96d3c8a42fa131.zip
fix(lsp): handle reverse lookup in capabilities
-rw-r--r--runtime/lua/vim/lsp/protocol.lua52
1 files changed, 15 insertions, 37 deletions
diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua
index 4a5ab1a73d..fa614780c2 100644
--- a/runtime/lua/vim/lsp/protocol.lua
+++ b/runtime/lua/vim/lsp/protocol.lua
@@ -1,5 +1,11 @@
--- @diagnostic disable: duplicate-doc-alias
+local function get_value_set(t)
+ return vim.iter.filter(function(i)
+ return type(i) == 'number'
+ end, ipairs(t))
+end
+
-- Protocol for the Microsoft Language Server Protocol (mslsp)
local protocol = {
@@ -295,6 +301,7 @@ local protocol = {
},
}
+-- TODO(mariasolos): Remove this reverse lookup.
for k, v in pairs(protocol) do
local tbl = vim.deepcopy(v, true)
vim.tbl_add_reverse_lookup(tbl)
@@ -705,7 +712,10 @@ function protocol.make_client_capabilities()
codeActionLiteralSupport = {
codeActionKind = {
valueSet = (function()
- local res = vim.tbl_values(protocol.CodeActionKind)
+ local res = vim.iter.filter(function(value)
+ -- Filter out the keys that were added by the reverse lookup.
+ return value:match('^%l')
+ end, vim.tbl_values(protocol.CodeActionKind))
table.sort(res)
return res
end)(),
@@ -736,15 +746,7 @@ function protocol.make_client_capabilities()
documentationFormat = { protocol.MarkupKind.Markdown, protocol.MarkupKind.PlainText },
},
completionItemKind = {
- valueSet = (function()
- local res = {}
- for k in ipairs(protocol.CompletionItemKind) do
- if type(k) == 'number' then
- table.insert(res, k)
- end
- end
- return res
- end)(),
+ valueSet = get_value_set(protocol.CompletionItemKind),
},
completionList = {
itemDefaults = {
@@ -794,15 +796,7 @@ function protocol.make_client_capabilities()
documentSymbol = {
dynamicRegistration = false,
symbolKind = {
- valueSet = (function()
- local res = {}
- for k in ipairs(protocol.SymbolKind) do
- if type(k) == 'number' then
- table.insert(res, k)
- end
- end
- return res
- end)(),
+ valueSet = get_value_set(protocol.SymbolKind),
},
hierarchicalDocumentSymbolSupport = true,
},
@@ -813,15 +807,7 @@ function protocol.make_client_capabilities()
publishDiagnostics = {
relatedInformation = true,
tagSupport = {
- valueSet = (function()
- local res = {}
- for k in ipairs(protocol.DiagnosticTag) do
- if type(k) == 'number' then
- table.insert(res, k)
- end
- end
- return res
- end)(),
+ valueSet = get_value_set(protocol.DiagnosticTag),
},
dataSupport = true,
},
@@ -833,15 +819,7 @@ function protocol.make_client_capabilities()
symbol = {
dynamicRegistration = false,
symbolKind = {
- valueSet = (function()
- local res = {}
- for k in ipairs(protocol.SymbolKind) do
- if type(k) == 'number' then
- table.insert(res, k)
- end
- end
- return res
- end)(),
+ valueSet = get_value_set(protocol.SymbolKind),
},
},
configuration = true,