From 213d698d565c22e83e932dd20153acbe28e9f9c1 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