local status_ok, el = pcall(require, "el") if not status_ok then return end el.reset_windows() local builtin = require "el.builtin" local sections = require "el.sections" local c = require "components" -- color setup local hl_statusline = "StatusLine" --diagnostic colors local hl_hint = "DiagnosticHint" local hl_info = "DiagnosticInfo" local hl_warn = "DiagnosticWarn" local hl_err = "DiagnosticError" -- git colors local hl_red = "ErrorMsg" local hl_green = "diffAdded" local hl_yellow = "WarningMsg" local highlights = { -- diagnostic colors diag_err = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_err] = "fg" }, bold = true, }), diag_warn = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_warn] = "fg" }, bold = true, }), diag_info = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_info] = "fg" }, bold = true, }), diag_hint = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_hint] = "fg" }, bold = true, }), -- git colors red_fg = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_red] = "fg" }, bold = true, }), green_fg = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_green] = "fg" }, bold = true, }), yellow_fg = c.extract_hl({ bg = { [hl_statusline] = "bg" }, fg = { [hl_yellow] = "fg" }, bold = true, }), } -- modes local modes = { -- display name, mode, highlight group n = { "Normal", "N" }, niI = { "Normal", "N" }, niR = { "Normal", "N" }, niV = { "Normal", "N" }, no = { "N·OpPd", "?" }, v = { "Visual", "V" }, V = { "V·Line", "Vl" }, [""] = { "V·Block", "Vb" }, s = { "Select", "S" }, S = { "S·Line", "Sl" }, [""] = { "S·Block", "Sb" }, i = { "Insert", "I" }, ic = { "ICompl", "Ic" }, R = { "Replace", "R" }, Rv = { "VReplace", "Rv" }, c = { "Command", "C" }, cv = { "Vim Ex", "E" }, ce = { "Ex (r)", "E" }, r = { "Prompt", "P" }, rm = { "More ", "M" }, ["r?"] = { "Confirm", "Cn" }, ["!"] = { "Shell ", "S" }, nt = { "Term ", "T" }, t = { "Term ", "T" }, } el.setup { generator = function() local items = { { c.mode { modes = modes, fmt = " %s %s ", icon = "", hl_icon_only = false } }, { sections.split, required = true }, { sections.collapse_builtin { { builtin.filetype }, { " " } } }, { sections.maximum_width(builtin.tail_file, 0.50), required = true }, { sections.collapse_builtin { { " " }, { builtin.modified_flag } } }, { sections.split, required = true }, { c.diagnostics { fmt = "[%s]", lsp = true, hl_err = highlights.diag_err, hl_warn = highlights.diag_warn, hl_info = highlights.diag_info, hl_hint = highlights.diag_hint, icon_err = 'x', icon_warn = '!', icon_info = 'i', icon_hint = 'h' } }, { c.git_branch { fmt = "%s *%s", icon = "" } }, { c.git_changes_buf { fmt = "[%s]", icon_insert = "+", icon_change = "~", icon_delete = "-", hl_insert = highlights.green_fg, hl_change = highlights.yellow_fg, hl_delete = highlights.red_fg, } }, } local add_item = function(result, item) table.insert(result, item) end local result = {} for _, item in ipairs(items) do add_item(result, item) end return result end, }