From 8436a197cc76f33fc2dc26145272c66cf5ee193d Mon Sep 17 00:00:00 2001 From: ranjithshegde Date: Mon, 29 Nov 2021 15:05:53 +0100 Subject: chore: use client.request instead of buf_request (#1503) * Use client.request directly instead of vim.lsp.buf_request to call methods that are outside the official LSP specification, such as clangd's "textDocument/switchSourceHeader". * This avoids sending an inapplicable request to all servers, as we cannot ahead of time validate the methods a given server supports. --- lua/lspconfig/util.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lua/lspconfig/util.lua') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index b6780aa9..c7f4eb53 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -414,4 +414,12 @@ function M.get_clients_from_cmd_args(arg) return vim.tbl_values(result) end +function M.get_active_client_by_name(bufnr, servername) + for _, client in pairs(vim.lsp.buf_get_clients(bufnr)) do + if client.name == servername then + return client + end + end +end + return M -- cgit v1.2.3-70-g09d2