diff options
| author | pml68 <contact@pml68.me> | 2024-08-26 00:20:22 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.me> | 2024-08-26 00:20:22 +0200 |
| commit | f493ff443c4f1a7bfc1e61ff0132975c4495ca35 (patch) | |
| tree | cdd5474ce5650328c076f1eda9663b845f69b142 /lua/pml68/settings.lua | |
| parent | refactor: use the "official" configuration for termux ls instead of whatever ... (diff) | |
| download | nvim-f493ff443c4f1a7bfc1e61ff0132975c4495ca35.tar.gz | |
feat: add list of LSPs to statusline (thanks u/Lamarcke)
Diffstat (limited to 'lua/pml68/settings.lua')
| -rw-r--r-- | lua/pml68/settings.lua | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lua/pml68/settings.lua b/lua/pml68/settings.lua index 33e7fd5..f862d85 100644 --- a/lua/pml68/settings.lua +++ b/lua/pml68/settings.lua @@ -14,6 +14,39 @@ local function branch_name() end end + +local function get_attached_clients() + local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 }) + if #buf_clients == 0 then + return "LSP Inactive" + end + + local buf_ft = vim.bo.filetype + local buf_client_names = {} + + for _, client in pairs(buf_clients) do + table.insert(buf_client_names, client.name) + end + + local unique_client_names = {} + for _, client_name_target in ipairs(buf_client_names) do + local is_duplicate = false + for _, client_name_compare in ipairs(unique_client_names) do + if client_name_target == client_name_compare then + is_duplicate = true + end + end + if not is_duplicate then + table.insert(unique_client_names, client_name_target) + end + end + + local client_names_str = table.concat(unique_client_names, ", ") + local language_servers = string.format("[%s]", client_names_str) + + return language_servers +end + vim.api.nvim_create_autocmd({ "FileType", "BufEnter", "FocusGained" }, { callback = function() vim.b.branch_name = branch_name() @@ -26,7 +59,8 @@ function Status_Line() .. " %f " .. vim.b.branch_name .. " %m" - .. " %=" + .. " %= " + .. get_attached_clients() .. " [%{&filetype}]" .. " %l:%c " end |
