From d42ffe1ac71938d42213ec78fda50ab1e61d012b Mon Sep 17 00:00:00 2001 From: kiyon Date: Mon, 13 Jun 2022 12:39:47 +0800 Subject: [PATCH] fetch correct lsp name while existing multi actived lsp clients --- lua/ui/statusline.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/ui/statusline.lua b/lua/ui/statusline.lua index cdde087..3caf27a 100644 --- a/lua/ui/statusline.lua +++ b/lua/ui/statusline.lua @@ -150,8 +150,15 @@ M.LSP_Diagnostics = function() end M.LSP_status = function() - local lsp_attached = next(vim.lsp.buf_get_clients()) ~= nil - local content = lsp_attached and "  LSP ~ " .. vim.lsp.get_active_clients()[1].name .. " " or false + local clients = vim.lsp.get_active_clients() + local name = false + for _, client in ipairs(clients) do + if client.attached_buffers[vim.api.nvim_get_current_buf()] then + name = client.name + break + end + end + local content = name and "  LSP ~ " .. name .. " " or false return content and ("%#St_LspStatus#" .. content) or "" end