all repos — dotfiles @ 0a867ad2e58c21d31f0ce106ab5812a152c6b83f

my *nix dotfiles

nvim/lua/statusline/line.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
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
local git = require('statusline.git')
local vd = require('vim.diagnostic')
local M = {}

local function diagnostic_highlight(diagnostics)
  local severity = {
    E = diagnostics[vd.severity.E],
    W = diagnostics[vd.severity.W],
    I = diagnostics[vd.severity.I],
    H = diagnostics[vd.severity.N],
  }
  local highlight = {
    E = '%#LineError#',
    W = '%#LineWarning#',
    I = '%#LineInfo#',
    H = '%#LineHint#',
  }
  local stl = {}
  for k, v in pairs(severity) do
    if v > 0 then
      table.insert(stl, ' '..highlight[k]..k..v)
    end
  end
  return table.concat(stl)
end

function M.statusline()
  local stl = {}
  if vim.bo.filetype ~= 'NvimTree' then
    stl = {''}
  end

  local diagnostics = vd.count(0)

  stl = {
    '%#LinePrimaryBlock#',
    '%f',
    '%#LineBlanks#',
    '%m',
    --'%#LineSecondaryBlock#',
    --' '..git.git_branch,
    '%=',
    diagnostic_highlight(diagnostics)..' ',
    '%#LineBlanks#',
    '%#LineSecondaryBlock#',
    '%l,%c ',
    '%#LinePrimaryBlock#',
    '%{&filetype}',
  }
  return table.concat(stl)
end

return M