summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/plugin
diff options
context:
space:
mode:
authortris203 <admin@snappeh.com>2026-02-23 23:03:40 +0000
committertris203 <admin@snappeh.com>2026-03-19 17:51:21 +0000
commitc8d9ade16a7df060798ce431d08594e411c87d59 (patch)
tree717bfff01a3aa9f132aee6f460fbb1bdfc157e36 /test/functional/plugin
parent06befe1e348bf540bb04a8c0cafe116616e71715 (diff)
refactor(lsp): replace _provider_value_get with _provider_foreach
Introduce _provider_foreach to iterate over all matching provider capabilities for a given LSP method, handling both static and dynamic registrations. Update diagnostic logic and tests to use the new iteration approach, simplifying capability access and improving consistency across features.
Diffstat (limited to 'test/functional/plugin')
-rw-r--r--test/functional/plugin/lsp/diagnostic_spec.lua6
-rw-r--r--test/functional/plugin/lsp_spec.lua15
2 files changed, 18 insertions, 3 deletions
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
index 12726bc2c6..b8300574b0 100644
--- a/test/functional/plugin/lsp/diagnostic_spec.lua
+++ b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -862,7 +862,11 @@ describe('vim.lsp.diagnostic', function()
exec_lua(function()
local client = vim.lsp.get_client_by_id(client_id)
assert(client)
- return client:_provider_value_get('workspace/diagnostic', 'identifier')
+ local result = {}
+ client:_provider_foreach('workspace/diagnostic', function(cap)
+ table.insert(result, cap.identifier or vim.NIL)
+ end)
+ return result
end)
)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 5e8d7e9fa6..7249ac2d47 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -5694,11 +5694,18 @@ describe('LSP', function()
local function check(method, fname, ...)
local bufnr = fname and vim.fn.bufadd(fname) or nil
local client = assert(vim.lsp.get_client_by_id(client_id))
+ local keys = { ... }
+ local caps = {}
+ if #keys > 0 then
+ client:_provider_foreach(method, function(cap)
+ table.insert(caps, vim.tbl_get(cap, unpack(keys)) or vim.NIL)
+ end)
+ end
result[#result + 1] = {
method = method,
fname = fname,
supported = client:supports_method(method, bufnr),
- cap = select('#', ...) > 0 and client:_provider_value_get(method, ...) or nil,
+ cap = #keys > 0 and caps or nil,
}
end
@@ -5978,7 +5985,11 @@ describe('LSP', function()
{ 'diag-ident-static' },
exec_lua(function()
local client = assert(vim.lsp.get_client_by_id(client_id))
- return client:_provider_value_get('textDocument/diagnostic', 'identifier')
+ local result = {}
+ client:_provider_foreach('textDocument/diagnostic', function(cap)
+ table.insert(result, cap.identifier)
+ end)
+ return result
end)
)
end)