✨ feat(nvim): add icons in the lualine for attached formatters, lsps and linters
This commit is contained in:
parent
734bebdb8b
commit
336a131636
2 changed files with 21 additions and 13 deletions
BIN
.config/nvim/.github/overview-images/lualine.png
vendored
BIN
.config/nvim/.github/overview-images/lualine.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
|
@ -1,22 +1,28 @@
|
||||||
local lsp = function()
|
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
|
if #buf_clients == 0 then
|
||||||
return "LSP Inactive"
|
return ""
|
||||||
|
else
|
||||||
|
return " "
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local buf_client_names = {}
|
local formatter = function()
|
||||||
|
local formatters = require("conform").list_formatters(0)
|
||||||
-- add client
|
if #formatters == 0 then
|
||||||
for _, client in pairs(buf_clients) do
|
return ""
|
||||||
if client.name ~= "null-ls" and client.name ~= "copilot" then
|
else
|
||||||
table.insert(buf_client_names, client.name)
|
return " "
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local unique_client_names = table.concat(buf_client_names, ", ")
|
local linter = function()
|
||||||
local language_servers = string.format(" %s", unique_client_names)
|
local linters = require("lint").linters_by_ft[vim.bo.filetype]
|
||||||
|
if #linters == 0 then
|
||||||
return language_servers
|
return ""
|
||||||
|
else
|
||||||
|
return " "
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -27,6 +33,8 @@ return {
|
||||||
|
|
||||||
table.remove(opts.sections.lualine_x, 1)
|
table.remove(opts.sections.lualine_x, 1)
|
||||||
table.insert(opts.sections.lualine_x, 2, lsp)
|
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_a = { { "mode", icon = "" } }
|
||||||
opts.sections.lualine_y = { { "progress", icon = "", separator = " ", padding = { left = 1, right = 1 } } }
|
opts.sections.lualine_y = { { "progress", icon = "", separator = " ", padding = { left = 1, right = 1 } } }
|
||||||
opts.sections.lualine_z = { { "location", icon = "", padding = { left = 1, right = 1 } } }
|
opts.sections.lualine_z = { { "location", icon = "", padding = { left = 1, right = 1 } } }
|
||||||
|
|
Loading…
Add table
Reference in a new issue