aboutsummaryrefslogtreecommitdiff
path: root/modules/neovim/nvim/lua/config/statusline.lua
blob: 3f29aa274f48d79499989b0878e627bd08423a8d (plain)
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
local modes = {
  ["n"] = "",
  ["no"] = "",
  ["nt"] = "",
  ["v"] = "VISUAL",
  ["V"] = "VISUAL-LINE",
  [""] = "VISUAL-BLOCK",
  ["s"] = "SELECT",
  ["S"] = "SELECT-LINE",
  [""] = "SELECT-BLOCK",
  ["i"] = "INSERT",
  ["ic"] = "INSERT",
  ["R"] = "REPLACE",
  ["Rv"] = "VISUAL-REPLACE",
  ["c"] = "COMMAND",
  ["cv"] = "VIM-EX",
  ["ce"] = "EX",
  ["r"] = "PROMPT",
  ["rm"] = "MOAR",
  ["r?"] = "CONFIRM",
  ["!"] = "SHELL",
  ["t"] = "TERMINAL",
}

local function mode()
  local m = vim.api.nvim_get_mode().mode
  local s = modes[m]
  return s == "" and "" or string.format("%s » ", s)
end

M = {}

M.statusline = function()
  return table.concat {
    " ",
    mode(),
    "%f%=%p%% « %l, %c "
  }
end

M.termStatus = function()
  return table.concat {
    " ",
    mode(),
    "%{b:term_title}%=%p%% « %l, %c "
  }
end

M.setup = function(config)
  vim.api.nvim_exec([[
    set statusline=%!v:lua.M.statusline()
    augroup Statusline
    au!
    au TermOpen * setlocal statusline=%!v:lua.M.termStatus()
    augroup END
  ]], false)
end

M.setup()