summaryrefslogtreecommitdiffstats
path: root/after/plugin/statusline.lua
blob: e1a27de59487ad215176254340332e589bd7d036 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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("core.statusbar.components")

local function hl(fg, b)
  b = b or false
  return c.extract_hl({
    bg = { ["StatusLine"] = "bg" },
    fg = { [fg] = "fg" },
    bold = b,
  })
end

local modes = {
  --     display name, mode, highlight group
  n      = { "Normal", "N", hl("@neorg.headings.1.title") },
  niI    = { "Normal", "N", hl("@neorg.headings.1.title") },
  niR    = { "Normal", "N", hl("@neorg.headings.1.title") },
  niV    = { "Normal", "N", hl("@neorg.headings.1.title") },
  no     = { "N·OpPd", "?" },
  v      = { "Visual", "V", hl("@neorg.headings.2.title") },
  V      = { "V·Line", "Vl", hl("@neorg.headings.2.title") },
  [""]   = { "V·Block", "Vb", hl("@neorg.headings.2.title") },
  s      = { "Select", "S" },
  S      = { "S·Line", "Sl" },
  [""]   = { "S·Block", "Sb" },
  i      = { "Insert", "I", hl("@neorg.headings.4.title") },
  ic     = { "ICompl", "Ic" },
  R      = { "Replace", "R", hl("@neorg.headings.5.title") },
  Rv     = { "VReplace", "Rv", hl("@neorg.headings.5.title") },
  c      = { "Command", "C", hl("@neorg.headings.3.title") },
  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()
    return {
      { { " " }, c.mode { modes = modes, hl_icon_only = false } },
      { sections.split, required = true },
      { sections.collapse_builtin { { builtin.filetype }, { " " } } },
      { sections.maximum_width(c.fn_tail, 0.50), required = true },
      { sections.collapse_builtin { { " " }, { builtin.modified_flag } } },
      { sections.split, required = true },
      { c.lsp_srvname },
      { c.diagnostics {
        fmt = "[%s]",
        hl_err  = hl("DiagnosticError", true),
        hl_warn = hl("DiagnosticWarn", true),
        hl_info = hl("DiagnosticInfo", true),
        hl_hint = hl("DiagnosticHint", true)
      }},
      { c.git_branch { icon = "*", fmt = " %s%s" } },
      { c.git_changes_buf {
        fmt = "[%s]",
        hl_insert = hl("GitSignsAdd", true),
        hl_change = hl("GitSignsChange", true),
        hl_delete = hl("GitSignsDelete", true),
      }},
      { { " " }, c.line {
        fmt = "[%s]",
      }, required = true },
    }
  end
}