2021-01-07 08:09:41 +00:00
|
|
|
" -----------------------------------------------------------------------------
|
|
|
|
" - Statusline setup -
|
|
|
|
" -----------------------------------------------------------------------------
|
|
|
|
|
2021-01-16 18:24:47 +00:00
|
|
|
function s:UpdateColors()
|
|
|
|
let ctermbg = synIDattr(synIDtrans(hlID('StatusLine')), 'bg', 'cterm')
|
|
|
|
let guibg = synIDattr(synIDtrans(hlID('StatusLine')), 'bg', 'gui')
|
|
|
|
let idguifg1 = synIDattr(synIDtrans(hlID('Function')), 'fg', 'gui')
|
|
|
|
let idctermfg1 = synIDattr(synIDtrans(hlID('Function')), 'fg', 'cterm')
|
|
|
|
" Green in gruvbox
|
|
|
|
exec 'hi User1 guifg=' . l:idguifg1 .
|
|
|
|
\' ctermfg=' . l:idctermfg1 .
|
|
|
|
\' cterm=bold,reverse gui=bold,reverse'
|
|
|
|
let idguifg2 = synIDattr(synIDtrans(hlID('WarningMsg')), 'fg', 'gui')
|
|
|
|
let idctermfg2 = synIDattr(synIDtrans(hlID('WarningMsg')), 'fg', 'cterm')
|
|
|
|
" Red in gruvbox
|
|
|
|
exec 'hi User2 guifg=' . l:idguifg2 .
|
|
|
|
\' ctermfg=' . l:idctermfg2 .
|
|
|
|
\' cterm=bold,reverse gui=bold,reverse'
|
|
|
|
let idguifg3 = synIDattr(synIDtrans(hlID('MoreMsg')), 'fg', 'gui')
|
|
|
|
let idctermfg3 = synIDattr(synIDtrans(hlID('MoreMsg')), 'fg', 'cterm')
|
|
|
|
" Yellow in gruvbox
|
|
|
|
exec 'hi User3 guifg=' . l:idguifg3 .
|
|
|
|
\' ctermfg=' . l:idctermfg3 .
|
|
|
|
\' cterm=bold,reverse gui=bold,reverse'
|
|
|
|
let idguifg4 = synIDattr(synIDtrans(hlID('Identifier')), 'fg', 'gui')
|
|
|
|
let idctermfg4 = synIDattr(synIDtrans(hlID('Identifier')), 'fg', 'cterm')
|
|
|
|
" Blue in gruvbox
|
|
|
|
exec 'hi User4 guifg=' . l:idguifg4 .
|
|
|
|
\' ctermfg=' . l:idctermfg4 .
|
|
|
|
\' cterm=bold,reverse gui=bold,reverse'
|
|
|
|
let idguifg5 = synIDattr(synIDtrans(hlID('Number')), 'fg', 'gui')
|
|
|
|
let idctermfg5 = synIDattr(synIDtrans(hlID('Number')), 'fg', 'cterm')
|
|
|
|
" Blue in gruvbox
|
|
|
|
exec 'hi User5 guifg=' . l:idguifg5 .
|
|
|
|
\' ctermfg=' . l:idctermfg5 .
|
|
|
|
\' cterm=bold,reverse gui=bold,reverse'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
augroup statuslineconf
|
|
|
|
autocmd!
|
|
|
|
autocmd ColorScheme * call s:UpdateColors()
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
call s:UpdateColors()
|
|
|
|
|
2021-01-07 08:09:41 +00:00
|
|
|
|
|
|
|
" Checks file type to add a pretty glyph if available
|
|
|
|
function s:GetFileType()
|
|
|
|
if &filetype ==# "rust"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%2* %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "c"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%4* %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "python"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%3* %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "javascript"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "typescript"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%4* %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "vim"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%1* %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "clojure"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "html"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "haskell"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "markdown"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "org"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "scss"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "scala"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "elixir"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%5* %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "kotlin"
|
2021-01-16 18:24:47 +00:00
|
|
|
return "%2* 洞 %*"
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "yml"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "toml"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
elseif &filetype ==# "json"
|
2021-01-16 18:24:47 +00:00
|
|
|
return " "
|
2021-01-07 08:09:41 +00:00
|
|
|
else
|
|
|
|
return "%y"
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Check current mode to add colorized mode
|
|
|
|
function s:GetMode()
|
|
|
|
if mode() == "n"
|
|
|
|
return " N "
|
|
|
|
elseif mode() == "i"
|
|
|
|
return "%3* I %*"
|
|
|
|
elseif mode() == "v"
|
|
|
|
return "%1* V %*"
|
|
|
|
elseif mode() == "V"
|
|
|
|
return "%1* V. %*"
|
|
|
|
elseif mode() == "\<C-V>"
|
|
|
|
return "%1* VB %*"
|
|
|
|
elseif mode() == "c"
|
|
|
|
return "%4* C %*"
|
|
|
|
else
|
|
|
|
return "[mode: " . mode() . "]"
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
" Add basic [paste] if paste mode is enabled
|
|
|
|
function! s:PasteForStatusline()
|
|
|
|
let paste_status = &paste
|
|
|
|
if paste_status == 1
|
|
|
|
return " [paste] "
|
|
|
|
else
|
|
|
|
return ""
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:LinterStatus() abort
|
|
|
|
let l:counts = ale#statusline#Count(bufnr(''))
|
|
|
|
|
|
|
|
let l:all_errors = l:counts.error + l:counts.style_error
|
|
|
|
let l:all_non_errors = l:counts.total - l:all_errors
|
|
|
|
|
2021-01-16 18:24:47 +00:00
|
|
|
return l:counts.total == 0 ? '%1* OK %*' : printf(
|
|
|
|
\ '%%3* %dW %%* %%2* %dE %%*',
|
2021-01-07 08:09:41 +00:00
|
|
|
\ all_non_errors,
|
|
|
|
\ all_errors
|
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function GetStatusLine()
|
|
|
|
let l:status_line_left = s:GetMode()
|
|
|
|
if exists('g:loaded_fugitive')
|
2021-01-16 18:24:47 +00:00
|
|
|
let l:fugitive_head = FugitiveHead()
|
|
|
|
if strlen(l:fugitive_head)
|
|
|
|
let l:status_line_left .= "%4* " . l:fugitive_head . " %*"
|
|
|
|
endif
|
2021-01-07 08:09:41 +00:00
|
|
|
endif
|
|
|
|
let l:status_line_left .= " %f" " Filename
|
|
|
|
let l:status_line_left .= " %1*%M%*" " Modified
|
|
|
|
let l:status_line_left .= " %2*%r%*" " Read only
|
|
|
|
let l:status_line_left .= s:PasteForStatusline()
|
|
|
|
if exists('g:did_coc_loaded')
|
2021-01-16 18:24:47 +00:00
|
|
|
let l:coc_status = coc#status()
|
|
|
|
if strlen(l:coc_status)
|
|
|
|
let l:status_line_left .= "%2* " . l:coc_status . " %*"
|
|
|
|
endif
|
2021-01-07 08:09:41 +00:00
|
|
|
endif
|
|
|
|
let l:status_line_right = "%= " " Align right statusline
|
|
|
|
if exists('g:loaded_ale')
|
|
|
|
let l:status_line_right .= s:LinterStatus() " ALE status
|
|
|
|
endif
|
2021-01-17 21:53:39 +00:00
|
|
|
let l:status_line_right .= " %2c:%3l/%3L (%3p%%) " " col, line, tot. lines
|
2021-01-07 08:09:41 +00:00
|
|
|
let l:status_line_right .= s:GetFileType() . " " " File type
|
|
|
|
return l:status_line_left . l:status_line_right
|
|
|
|
endfunction
|
|
|
|
set statusline=%!GetStatusLine()
|