From 5086c47287b3f37e3938e145ee51af0967bce2ea Mon Sep 17 00:00:00 2001 From: Final <14924875+JulyFinal@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:33:26 +0800 Subject: [PATCH] Update evil_lualine.lua Optimize the method for obtaining the LSP server name and fix the issue where the LSP server name is incomplete when there are multiple names. --- examples/evil_lualine.lua | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/evil_lualine.lua b/examples/evil_lualine.lua index 1331132b9..80f571b69 100644 --- a/examples/evil_lualine.lua +++ b/examples/evil_lualine.lua @@ -158,19 +158,17 @@ ins_left { ins_left { -- Lsp server name . function() - local msg = 'No Active Lsp' - local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') - local clients = vim.lsp.get_active_clients() - if next(clients) == nil then - return msg - end - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return client.name - end - end - return msg + local msg = "No Active Lsp" + local clients = vim.lsp.get_clients({ bufnr = 0 }) + + return #clients > 0 + and table.concat( + vim.tbl_map(function(client) + return client.name + end, clients), + "," + ) + or msg end, icon = ' LSP:', color = { fg = '#ffffff', gui = 'bold' },