mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
runtime: Add vim.lsp.get_client_by_name (#11603)
Since the client name is more obvious than the client id for the user, add an API to get the lsp client by the client name.
This commit is contained in:
committed by
Ashkan Kiani
parent
4f4c06a7a4
commit
680693e263
@@ -697,6 +697,16 @@ function lsp.get_client_by_id(client_id)
|
||||
return active_clients[client_id]
|
||||
end
|
||||
|
||||
-- Look up an active client by its name, returns nil if it is not yet initialized
|
||||
-- or is not a valid name.
|
||||
-- @param client_name string the client name.
|
||||
function lsp.get_client_by_name(client_name)
|
||||
for _, client in pairs(active_clients) do
|
||||
if client.name == client_name then return client end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Stop a client by its id, optionally with force.
|
||||
-- You can also use the `stop()` function on a client if you already have
|
||||
-- access to it.
|
||||
|
||||
Reference in New Issue
Block a user