my nix dotfiles

nvim: add diagnostic counts to statusline

+45 -20
+13 -5
nvim/colors/plain.lua
··· 138 138 WinSeparator = { fg = border }, 139 139 Visual = { bg = light_grey }, 140 140 WarningMsg = { fg = dark_yellow, bold = true }, 141 - Whitespace = { fg = border }, 141 + Whitespace = { fg = light_grey }, 142 142 WildMenu = { link = 'PmenuSel' }, 143 143 -- ALE 144 144 ALEError = { fg = red, bold = true }, ··· 252 252 DiagnosticFloatingHint = { fg = black, bold = true }, 253 253 DiagnosticFloatingInfo = { fg = blue, bold = true }, 254 254 DiagnosticFloatingWarn = { fg = dark_yellow, bold = true }, 255 - DiagnosticError = { fg = red, bold = true }, 256 - DiagnosticHint = { fg = grey, bold = true }, 257 - DiagnosticInfo = { fg = blue, bold = true }, 258 - DiagnosticWarn = { fg = dark_yellow, bold = true }, 255 + DiagnosticError = { fg = red }, 256 + DiagnosticHint = { fg = grey }, 257 + DiagnosticInfo = { fg = blue }, 258 + DiagnosticWarn = { fg = dark_yellow }, 259 259 -- Make 260 260 makeTarget = { link = 'Function' }, 261 261 -- Markdown ··· 441 441 442 442 -- custom highlight groups 443 443 ['@variable'] = { fg = black }, 444 + 445 + -- statusline 446 + LinePrimaryBlock = { fg = black, bg = background }, 447 + LineSecondaryBlock = { fg = blue, bg = background }, 448 + LineError = { link = 'DiagnosticError' }, 449 + LineHint = { link = 'DiagnosticHint' }, 450 + LineInfo = { link = 'DiagnosticInfo' }, 451 + LineWarning = { link = 'DiagnosticWarn' }, 444 452 } 445 453 446 454 for group, opts in pairs(highlights) do
+32 -15
nvim/lua/statusline/line.lua
··· 1 1 local git = require('statusline.git') 2 + local vd = require('vim.diagnostic') 2 3 local M = {} 3 4 4 - -- set highlights for statusline sections 5 - vim.api.nvim_exec( 6 - [[ 7 - hi PrimaryBlock ctermfg=06 ctermbg=00 8 - hi SecondaryBlock ctermfg=07 ctermbg=00 9 - hi Blanks ctermfg=08 ctermbg=00 10 - hi GitClean ctermfg=02 ctermbg=00 11 - hi GitDirty ctermfg=01 ctermbg=00 12 - ]], false) 5 + local 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) 25 + end 13 26 14 27 function M.statusline() 15 28 local stl = {} ··· 17 30 stl = {''} 18 31 end 19 32 33 + local diagnostics = vd.count(0) 34 + 20 35 stl = { 21 - '%#PrimaryBlock#', 36 + '%#LinePrimaryBlock#', 22 37 '%f', 23 - '%#Blanks#', 38 + '%#LineBlanks#', 24 39 '%m', 25 - '%#SecondaryBlock#', 26 - ' '..git.git_branch, 40 + --'%#LineSecondaryBlock#', 41 + --' '..git.git_branch, 27 42 '%=', 28 - '%#SecondaryBlock#', 43 + diagnostic_highlight(diagnostics)..' ', 44 + '%#LineBlanks#', 45 + '%#LineSecondaryBlock#', 29 46 '%l,%c ', 30 - '%#PrimaryBlock#', 47 + '%#LinePrimaryBlock#', 31 48 '%{&filetype}', 32 49 } 33 50 return table.concat(stl)