my nix dotfiles
at master 53 lines 1.1 kB view raw
1local git = require('statusline.git') 2local vd = require('vim.diagnostic') 3local M = {} 4 5local function diagnostic_highlight(diagnostics) 6 local severity = { 7 E = diagnostics[vd.severity.E], 8 W = diagnostics[vd.severity.W], 9 I = diagnostics[vd.severity.I], 10 H = diagnostics[vd.severity.N], 11 } 12 local highlight = { 13 E = '%#LineError#', 14 W = '%#LineWarning#', 15 I = '%#LineInfo#', 16 H = '%#LineHint#', 17 } 18 local stl = {} 19 for k, v in pairs(severity) do 20 if v > 0 then 21 table.insert(stl, ' '..highlight[k]..k..v) 22 end 23 end 24 return table.concat(stl) 25end 26 27function M.statusline() 28 local stl = {} 29 if vim.bo.filetype ~= 'NvimTree' then 30 stl = {''} 31 end 32 33 local diagnostics = vd.count(0) 34 35 stl = { 36 '%#LinePrimaryBlock#', 37 '%f', 38 '%#LineBlanks#', 39 '%m', 40 --'%#LineSecondaryBlock#', 41 --' '..git.git_branch, 42 '%=', 43 diagnostic_highlight(diagnostics)..' ', 44 '%#LineBlanks#', 45 '%#LineSecondaryBlock#', 46 '%l,%c ', 47 '%#LinePrimaryBlock#', 48 '%{&filetype}', 49 } 50 return table.concat(stl) 51end 52 53return M