all repos — dotfiles @ 670e041e0b48ee13a416021949f9550350776197

my *nix dotfiles

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

 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
-- set highlights for statusline sections
vim.api.nvim_exec(
[[
	hi PrimaryBlock ctermfg=06 ctermbg=00
	hi SecondaryBlock   ctermfg=07 ctermbg=00
	hi Blanks   ctermfg=08 ctermbg=00
]], false)

local function clean_or_dirty()
  local handle = io.popen('git status --porcelain 2> /dev/null')
  local status = handle:read('*a')

  if status ~= '' then return '*' end
  return status
end

local function git_branch()
  local handle = io.popen('git branch --show-current 2> /dev/null')
  local branch = handle:read('*a'):gsub('\n', '')
  local rc = { handle:close() }
  if rc[1] then
    local out = ' ' .. branch .. clean_or_dirty()
    return out
  else
    return ''
  end
end

local stl = {
  '%#PrimaryBlock#',
  '%f',
  '%#Blanks#',
  '%m',
  '%#SecondaryBlock#',
  git_branch(),
  '%=',
  '%#SecondaryBlock#',
  '%l,%c ',
  '%#PrimaryBlock#',
  '%{&filetype}',
}

vim.o.statusline = table.concat(stl)