mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
feat(lsp): add method filter to get_active_clients (#24319)
This commit is contained in:
committed by
GitHub
parent
ef94fb69c6
commit
317c80f460
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user