all repos — dotfiles @ e65e20a60c921ac0aac0549996082a5c61be3b1d

my *nix dotfiles

config/nvim/lua/statusline.lua (view raw)

 1-- set highlights for statusline sections
 2vim.api.nvim_exec(
 3[[
 4	hi PrimaryBlock ctermfg=06 ctermbg=00
 5	hi SecondaryBlock   ctermfg=07 ctermbg=00
 6	hi Blanks   ctermfg=08 ctermbg=00
 7]], false)
 8
 9local function clean_or_dirty()
10  local handle = io.popen('git status --porcelain 2> /dev/null')
11  local status = handle:read('*a')
12
13  if status ~= '' then return '*' end
14  return status
15end
16
17local function git_branch()
18  local handle = io.popen('git branch --show-current 2> /dev/null')
19  local branch = handle:read('*a'):gsub('\n', '')
20  local rc = { handle:close() }
21  if rc[1] then
22    local out = ' ' .. branch .. clean_or_dirty()
23    return out
24  else
25    return ''
26  end
27end
28
29local stl = {
30  '%#PrimaryBlock#',
31  '%f',
32  '%#Blanks#',
33  '%m',
34  '%#SecondaryBlock#',
35  git_branch(),
36  '%=',
37  '%#SecondaryBlock#',
38  '%l,%c ',
39  '%#PrimaryBlock#',
40  '%{&filetype}',
41}
42
43vim.o.statusline = table.concat(stl)