aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2023-07-12 14:48:21 +0200
committerGitHub <noreply@github.com>2023-07-12 14:48:21 +0200
commit317c80f460a7826421f40f57ee8bdbd736b0f225 (patch)
tree06bb41ef6332fbd0cd4585969e7b3c12c76b444b /runtime/lua/vim/lsp.lua
parentef94fb69c65bc2e4c67826de6373c202b55b7d5a (diff)
downloadrneovim-317c80f460a7826421f40f57ee8bdbd736b0f225.tar.gz
rneovim-317c80f460a7826421f40f57ee8bdbd736b0f225.tar.bz2
rneovim-317c80f460a7826421f40f57ee8bdbd736b0f225.zip
feat(lsp): add method filter to get_active_clients (#24319)
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index ed431e080e..1f9b6c4360 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -1995,6 +1995,7 @@ end
---@field id integer|nil Match clients by id
---@field bufnr integer|nil match clients attached to the given buffer
---@field name string|nil match clients by name
+---@field method string|nil match client by supported method name
--- Get active clients.
---
@@ -2004,6 +2005,7 @@ end
--- - id (number): Only return clients with the given id
--- - bufnr (number): Only return clients attached to this buffer
--- - name (string): Only return clients with the given name
+--- - method (string): Only return clients supporting the given method
---@return lsp.Client[]: List of |vim.lsp.client| objects
function lsp.get_active_clients(filter)
validate({ filter = { filter, 't', true } })
@@ -2020,6 +2022,7 @@ function lsp.get_active_clients(filter)
client
and (filter.id == nil or client.id == filter.id)
and (filter.name == nil or client.name == filter.name)
+ and (filter.method == nil or client.supports_method(filter.method, { bufnr = filter.bufnr }))
then
clients[#clients + 1] = client
end