feat(lualine): highlight file encoding & format when not "unix utf-8"

This commit is contained in:
Michel 2023-10-27 19:27:37 +02:00
parent 71af65996a
commit 10e898aa81
1 changed files with 19 additions and 3 deletions

View File

@ -39,13 +39,15 @@ return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
opts = function(_, opts) opts = function(_, opts)
local icons = require("lazyvim.config").icons local icons = require("lazyvim.config").icons
local warning_col = { fg = "#bf7b00" }
opts.options.theme = "horizon" opts.options.theme = "horizon"
opts.sections = { opts.sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { lualine_b = {
Util.lualine.root_dir({ color = { fg = "#bf7b00" } }), -- Show "root dir" of current file when different from CWD
Util.lualine.root_dir({ color = warning_col }),
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ Util.lualine.pretty_path() }, { Util.lualine.pretty_path() },
}, },
@ -63,8 +65,22 @@ return {
lualine_x = opts.sections.lualine_x, lualine_x = opts.sections.lualine_x,
lualine_z = opts.sections.lualine_y, lualine_z = opts.sections.lualine_y,
lualine_y = { lualine_y = {
{ "fileformat", separator = "", padding = { left = 1, right = 0 } }, {
"encoding", "fileformat",
color = function()
return (vim.bo.fileformat ~= "unix") and warning_col or nil
end,
separator = "",
padding = { left = 1, right = 0 },
},
{
function()
return vim.o.fileencoding
end,
color = function()
return (vim.o.fileencoding ~= "utf-8") and warning_col or nil
end,
},
}, },
} }
end, end,