+/config
my dotfiles and nix configuration
git clone https://git.julia.blue/+/config
0a0d15f
main
1local icons ={ Hint ="" , Info ="" , Warn ="" , Error ="" } 2local ls =vim . diagnostic . severity 3local sev ={ Hint =ls . HINT , Info =ls . INFO , Warn =ls . WARN , Error =ls . ERROR } 4 5for k , v in pairs ( icons ) do 6vim . fn . sign_define ( "DiagnosticSign" .. k , { text =v , texthl ="DiagnosticSign" .. k } ) 7end 8 9local function readonly () return ( vim . o . readonly or not vim . o . modifiable ) and "🔒" or "" end 10 11local function diagnostics () 12local levels ={ 13Hint ="%%#DiagnosticSignHint#" , 14Info ="%%#DiagnosticSignInfo#" , 15Warn ="%%#DiagnosticSignWarn#" , 16Error ="%%#DiagnosticSignError#" , 17} 18local t ={} 19for l , s in pairs ( levels ) do 20local n =# vim . diagnostic . get ( 0 , { severity =sev [ l ] } ) 21if n > 0 then t [ # t + 1 ] =string . format ( s .. " %s %s " , icons [ l ], n ) end 22end 23return table . concat ( t ) 24end 25 26local function git () 27local status =vim . b . gitsigns_status_dict ---@diagnostic disable-line: undefined-field 28if not status then return "" end 29local t , add , change , del ={} , status . added , status . changed , status . removed 30if add and add > 0 then t [ # t + 1 ] ="%#GitSignsAdd#+" .. add end 31if change and change > 0 then t [ # t + 1 ] ="%#GitSignsChange#+" .. change end 32if del and del > 0 then t [ # t + 1 ] ="%#GitSignsDelete#+" .. del end 33if not t then return "" end 34return "%#SignColumn# " .. table . concat ( t , " " ) .. " " 35end 36 37local function modified () return vim . o . modified and "%#StatusLineModified#" or "%#MoreMsg#" end 38 39vim . opt . showmode =false 40-- stylua: ignore 41local modes ={ 42i ="Insert" , s ="Select" , c ="Command" , t ="Terminal" , 43v ="Visual" , V ="Visual (line)" , [ "" ] ="Visual (block)" , 44} 45local function mode () 46local m =vim . api . nvim_get_mode (). mode 47if m == "n" then return "" end 48return " " .. ( modes [ m ] ~= nil and modes [ m ] or m ) 49end 50 51local line_col =" %l:%-2c " 52local file =" %f " 53local fill ="%=" 54local reset ="%*" 55 56StatusLine ={ 57active =function () 58-- stylua: ignore 59return table . concat { 60readonly (), file , git (), modified (), mode (), 61fill , diagnostics (), reset , line_col , 62} 63end , 64inactive =function () return table . concat { file , fill , line_col } end , 65} 66 67local status =vim . api . nvim_create_augroup ( "StatusLine" , {} ) 68vim . api . nvim_create_autocmd ( { "WinEnter" , "BufEnter" } , { 69group =status , 70command ="setlocal statusline=%!v:lua.StatusLine.active()" , 71} ) 72vim . api . nvim_create_autocmd ( { "WinLeave" , "BufLeave" } , { 73group =status , 74command ="setlocal statusline=%!v:lua.StatusLine.inactive()" , 75} )