diff --git a/lua/weeheavy/plugins/lualine.lua b/lua/weeheavy/plugins/lualine.lua index c24416b..cf0e3dc 100644 --- a/lua/weeheavy/plugins/lualine.lua +++ b/lua/weeheavy/plugins/lualine.lua @@ -1,20 +1,21 @@ -- status line like vim-airline -- Display attached LSP client -local function lsp_clients() - local clients = vim.lsp.get_active_clients() - local client_names = {} - local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") - 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 +local function lsp_client_name() + local bufnr = vim.api.nvim_get_current_buf() + + -- local clients = vim.lsp.buf_get_clients(bufnr) + local clients = vim.lsp.get_clients({ bufnr = 0 }) + if next(clients) == nil then + return "n/a" end - if next(client_names) == nil then - return "no LS" + + local c = {} + for _, client in pairs(clients) do + table.insert(c, client.name) + -- table.insert(c, string.sub(client.name, 0, 8) .. "...") end - --return "[" .. table.concat(client_names, ", ") .. "]" + return "\u{f085} " .. table.concat(c, ",") end -- hide content on narrow windows @@ -69,8 +70,8 @@ return { -- specify full list of elements when adding custom things { "encoding", cond = hide_in_width }, { "fileformat" }, - { "filetype" }, - { lsp_clients, cond = hide_in_width }, + { "filetype", cond = hide_in_width }, + { lsp_client_name, cond = hide_in_width }, --{ clock, cond = hide_in_width }, }, },