From ecf36ee938d8aa253f329d42e47e70e505d5b474 Mon Sep 17 00:00:00 2001 From: Matt Leong Date: Sun, 7 Nov 2021 11:52:32 -0800 Subject: [PATCH] feat(statusline): show active lsp clients --- lua/cosmic/core/file-explorer/init.lua | 2 -- lua/cosmic/core/statusline/init.lua | 27 ++++++++++++++++++++++++++ lua/cosmic/core/theme/highlights.lua | 2 ++ lua/cosmic/utils.lua | 10 ++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lua/cosmic/core/file-explorer/init.lua b/lua/cosmic/core/file-explorer/init.lua index bce0369..f1e7b01 100644 --- a/lua/cosmic/core/file-explorer/init.lua +++ b/lua/cosmic/core/file-explorer/init.lua @@ -35,10 +35,8 @@ local args = { diagnostics = { enable = true, }, - update_cwd = true, update_focused_file = { enable = true, - update_cwd = true, }, } diff --git a/lua/cosmic/core/statusline/init.lua b/lua/cosmic/core/statusline/init.lua index 8221685..ef3bd57 100644 --- a/lua/cosmic/core/statusline/init.lua +++ b/lua/cosmic/core/statusline/init.lua @@ -106,6 +106,32 @@ galaxy.short_line_list = { 'fugitiveblame', } +gls.mid = { + { + LSPStatus = { + provider = function() + local clients = utils.get_active_lsp_client_names() + local client_str = '' + + if #clients < 1 then + return client_str + end + + table.sort(clients) + for i, client in ipairs(clients) do + client_str = client_str .. client + if i < #clients then + client_str = client_str .. ', ' + end + end + + return 'LSP: [' .. client_str .. ']' + end, + highlight = 'GalaxyText', + }, + }, +} + gls.left = { { GhostLeftBracket = { @@ -139,6 +165,7 @@ gls.left = { highlight('GalaxyViModeNested', mode_nested, colors.bg) highlight('GalaxyViModeNestedInv', colors.bg, mode_nested) highlight('GalaxyPercentBracket', colors.bg, mode_color) + highlight('GalaxyText', colors.bg, mode_color) highlight('GalaxyGitLCBracket', mode_nested, mode_color) diff --git a/lua/cosmic/core/theme/highlights.lua b/lua/cosmic/core/theme/highlights.lua index 5fbeb89..b1b86fa 100644 --- a/lua/cosmic/core/theme/highlights.lua +++ b/lua/cosmic/core/theme/highlights.lua @@ -57,6 +57,8 @@ highlight('NotifyTRACEIcon', nil, colors.trace) -- terminal highlight highlight('FloatermBorder', 'None', colors.floatBorder) +highlight('StatusLine', 'Normal', 'Normal') + vim.cmd([[ highlight clear NormalFloat highlight link NormalFloat Normal diff --git a/lua/cosmic/utils.lua b/lua/cosmic/utils.lua index 5041f28..4ee7a85 100644 --- a/lua/cosmic/utils.lua +++ b/lua/cosmic/utils.lua @@ -36,4 +36,14 @@ function M.get_relative_path(file_path) return './' .. relative_path end +function M.get_active_lsp_client_names() + local active_clients = vim.lsp.get_active_clients() + local client_names = {} + for i, client in pairs(active_clients) do + table.insert(client_names, i, client.name) + end + + return client_names +end + return M