feat(nvim): add icons in the lualine for attached formatters, lsps and linters

This commit is contained in:
Sergio Laín 2024-02-23 10:20:18 +01:00
parent 734bebdb8b
commit 336a131636
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
2 changed files with 21 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -1,22 +1,28 @@
local lsp = function()
local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 })
local buf_clients = vim.lsp.get_clients({ bufnr = 0 })
if #buf_clients == 0 then
return "LSP Inactive"
return ""
else
return ""
end
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
local formatter = function()
local formatters = require("conform").list_formatters(0)
if #formatters == 0 then
return ""
else
return "󰛖 "
end
end
local unique_client_names = table.concat(buf_client_names, ", ")
local language_servers = string.format(" %s", unique_client_names)
return language_servers
local linter = function()
local linters = require("lint").linters_by_ft[vim.bo.filetype]
if #linters == 0 then
return ""
else
return "󱉶 "
end
end
return {
@ -27,6 +33,8 @@ return {
table.remove(opts.sections.lualine_x, 1)
table.insert(opts.sections.lualine_x, 2, lsp)
table.insert(opts.sections.lualine_x, 2, formatter)
table.insert(opts.sections.lualine_x, 2, linter)
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 } } }