From 56a0690be464f55c94648e9d18d8c0bc53dce5bd Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Tue, 17 Jan 2023 19:02:52 -0600 Subject: [PATCH] refactor(nvim): better lualine lsp names --- .../config/lua/plugins/configs/statusline.lua | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/dots/.nvim-environments/primary/config/lua/plugins/configs/statusline.lua b/dots/.nvim-environments/primary/config/lua/plugins/configs/statusline.lua index 1e6ba37e..153ede9f 100755 --- a/dots/.nvim-environments/primary/config/lua/plugins/configs/statusline.lua +++ b/dots/.nvim-environments/primary/config/lua/plugins/configs/statusline.lua @@ -38,6 +38,32 @@ local function show_macro_recording() end end +local show_lsp_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 + else + msg = "" + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + if msg == "" then + msg = client.name + else + msg = msg .. ", " .. client.name + end + end + end + end + return msg + end, + icon = " LSP:", + color = { fg = "#957fb8" }, +} + lualine.setup({ options = { icons_enabled = true, @@ -60,29 +86,7 @@ lualine.setup({ "macro-recording", fmt = show_macro_recording, }, - { - 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 - else - msg = "" - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if msg == "" then - msg = client.name - else - msg = msg .. ", " .. client.name - end - end - end - return msg - end, - icon = " LSP:", - color = { fg = "#957fb8" }, - }, + show_lsp_name, }, lualine_c = {}, lualine_x = { @@ -105,7 +109,7 @@ lualine.setup({ }, inactive_winbar = { lualine_a = { { "filename", path = 1 } }, - lualine_b = {}, + lualine_b = { show_lsp_name }, lualine_c = {}, lualine_x = { "filetype",