fetch correct lsp name while existing multi actived lsp clients

This commit is contained in:
kiyon 2022-06-13 12:39:47 +08:00 committed by siduck
parent 5b37cb5875
commit d42ffe1ac7

View file

@ -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