From 9c3daae2b8221ccfb2e336a5d6e6066139003690 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 2 Mar 2022 13:50:32 +0100 Subject: [PATCH] home: vim: add function to list LSP client names --- home/vim/lua/ambroisie/utils.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/home/vim/lua/ambroisie/utils.lua b/home/vim/lua/ambroisie/utils.lua index 7b1322b..e3833cc 100644 --- a/home/vim/lua/ambroisie/utils.lua +++ b/home/vim/lua/ambroisie/utils.lua @@ -14,6 +14,20 @@ M.is_executable_condition = function(cmd) return function() return M.is_executable(cmd) end end +-- list all active LSP clients for current buffer +-- @param bufnr int? buffer number +-- @return table all active LSP client names +M.list_lsp_clients = function(bufnr) + local clients = vim.lsp.buf_get_clients(bufnr) + local names = {} + + for _, client in ipairs(clients) do + table.insert(names, client.name) + end + + return names +end + -- shared LSP configuration callback -- @param client native client configuration -- @param bufnr int? buffer number of the attched client