From 317c80f460a7826421f40f57ee8bdbd736b0f225 Mon Sep 17 00:00:00 2001 From: Mathias Fußenegger Date: Wed, 12 Jul 2023 14:48:21 +0200 Subject: feat(lsp): add method filter to get_active_clients (#24319) --- runtime/lua/vim/lsp.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/lua/vim/lsp.lua') 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 -- cgit