From c6912fb80f4e58a9af2d00afcab0c63e874bcf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Fri, 23 Feb 2024 01:07:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20add=20lsp=20client=20?= =?UTF-8?q?module=20for=20lualine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/plugins/lualine.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index a10b9def..72567f07 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,3 +1,24 @@ +local lsp = function() + local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 }) + if #buf_clients == 0 then + return "LSP Inactive" + end + + local buf_client_names = {} + + -- add client + for _, client in pairs(buf_clients) do + if client.name ~= "null-ls" and client.name ~= "copilot" then + table.insert(buf_client_names, client.name) + end + end + + local unique_client_names = table.concat(buf_client_names, ", ") + local language_servers = string.format(" %s", unique_client_names) + + return language_servers +end + return { "nvim-lualine/lualine.nvim", opts = function(_, opts) @@ -5,6 +26,7 @@ return { opts.options.section_separators = { left = "", right = "" } table.remove(opts.sections.lualine_x, 1) + table.insert(opts.sections.lualine_x, 2, lsp) opts.sections.lualine_a = { { "mode", icon = "" } } opts.sections.lualine_y = { { "progress", icon = "", separator = " ", padding = { left = 1, right = 1 } } } opts.sections.lualine_z = { { "location", icon = "", padding = { left = 1, right = 1 } } }