get lsp server name more consistently for the statusbar

This commit is contained in:
2024-03-09 00:21:19 -05:00
parent 40fea1a44d
commit 649918dc24

View File

@ -239,15 +239,11 @@ end
function M.lsp_srvname(opts)
local fmt = opts.fmt or "%s"
local icon = opts.icon or ""
local buf_clients = vim.lsp.buf_get_clients(0)
if not buf_clients or #buf_clients == 0 then
return ""
end
local names = ""
for i, c in ipairs(buf_clients) do
if i > 1 then names = names .. ", " end
names = names .. c.name
end
vim.lsp.for_each_buffer_client(0, function(client)
if names ~= "" then names = names..", " end
names = names..client.name
end)
return icon..fmt:format(names)
end