vim/vimrc.d/statusline.vim

245 lines
9.8 KiB
VimL
Raw Normal View History

set statusline=%!GetStatus(1)
2018-04-01 15:07:11 +00:00
" augroups
augroup status "{{{
autocmd!
autocmd WinNew,WinEnter * setlocal statusline=%!GetStatus(1)
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
" autocmd WinNew * setlocal statusline=%!GetStatus(1)
" autocmd InsertChange * setlocal statusline=%!GetStatus(1)
augroup END
"}}}
" colors
hi clear StatusLine"{{{
hi StatusLine ctermfg=239 guifg=#555555 ctermbg=232 guibg=NONE gui=NONE
hi StatusLineNC ctermfg=238 guifg=#444444 ctermbg=232 guibg=NONE term=none cterm=none gui=NONE
hi StatusLineNormal ctermfg=243 guifg=#777777 ctermbg=234 guibg=#1c1c1c term=none cterm=none
hi StatusLineNormalNoText ctermfg=234 guifg=#1c1c1c ctermbg=234 guibg=#1c1c1c term=none cterm=none
hi StatusLineActive ctermfg=255 guifg=#ffffff ctermbg=239 guibg=#4e4e4e term=none cterm=none
hi StatusLineActiveNoText ctermfg=239 guifg=#4e4e4e ctermbg=239 guibg=#4e4e4e term=none cterm=none
hi StatusLineActiveQuotes ctermfg=244 guifg=#888888 ctermbg=239 guibg=#4e4e4e term=none cterm=none
hi StatusLineSeparator ctermfg=255 guifg=#ffffff ctermbg=232 guibg=NONE
hi StatusLineDir ctermfg=241 guifg=#666666 ctermbg=234 guibg=#1c1c1c
hi StatusLineDirActive ctermfg=243 guifg=#777777 ctermbg=237 guibg=#3a3a3a
hi StatusLineFile ctermfg=250 guifg=#cccccc ctermbg=234 guibg=#1c1c1c
hi StatusLineFileActive ctermfg=255 guifg=#eeeeee ctermbg=237 guibg=#3a3a3a
hi StatusLineDot ctermfg=241 guifg=#606060 ctermbg=234 guibg=#1c1c1c
hi StatusLineDotActive ctermfg=244 guifg=#808080 ctermbg=237 guibg=#3a3a3a
hi StatusLineExt ctermfg=243 guifg=#777777 ctermbg=234 guibg=#1c1c1c
hi StatusLineExtActive ctermfg=249 guifg=#bbbbbb ctermbg=239 guibg=#3a3a3a
hi StatusLinePercent ctermfg=241 guifg=#555555 ctermbg=233 guibg=#111111
hi StatusLinePercentActive ctermfg=243 guifg=#777777 ctermbg=233 guibg=#111111
" hi StatusLineMod ctermfg=255 guifg=#ffffff ctermbg=88 guibg=#490000
" TODO get cterm colors same as gui ones for all the following highlights
hi StatusLineDiv ctermfg=233 guifg=#111111 ctermbg=233 guibg=#111111 term=none cterm=none
hi StatusLineDivActive ctermfg=234 guifg=#1c1c1c ctermbg=234 guibg=#1c1c1c term=none cterm=none
hi StatusLineDivMod ctermfg=234 guifg=#290000 ctermbg=234 guibg=#290000 term=none cterm=none
hi StatusLineDivModActive ctermfg=233 guifg=#450000 ctermbg=233 guibg=#450000 term=none cterm=none
hi StatusLineDivInput ctermfg=234 guifg=#cccccc ctermbg=234 guibg=#cccccc term=none cterm=none
hi LinterDash ctermfg=233 guifg=#222222
hi LinterDashActive ctermfg=238 guifg=#333333
hi LinterError ctermfg=196 guifg=#ff0000 gui=bold
hi LinterErrorInactive ctermfg=196 guifg=#999999 gui=bold
hi LinterErrorStyle ctermfg=196 guifg=#aa0000 gui=bold
hi LinterErrorStyleInactive ctermfg=196 guifg=#858585 gui=bold
hi LinterWarning ctermfg=88 guifg=#870000 gui=bold
hi LinterWarningInactive ctermfg=88 guifg=#717171 gui=bold
hi LinterWarningStyle ctermfg=88 guifg=#660000 gui=bold
hi LinterWarningStyleInactive ctermfg=88 guifg=#585858 gui=bold
hi LinterInfo ctermfg=52 guifg=#440000
"}}}
" functions
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
function! GetStatus(isactive) "{{{
2018-03-17 23:42:49 +00:00
" let l:linter = ale#statusline#Count(bufnr(''))
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
let l:separator = '%#StatusLineSeparator# '
let l:normal = '%#StatusLineNormal#'
let l:active = '%#StatusLineActive#'
let l:bracket_open = '%#CRNoiseDark#('
let l:bracket_close = '%#CRNoiseDark#) '
let l:statusline = ''
" file percentage
let l:statusline .= '%#FoldColumn#┼ ' "{{{
2018-03-18 00:24:20 +00:00
if a:isactive
2018-03-18 12:00:37 +00:00
let l:statusline .= '%#StatusLinePercentActive#'
2018-03-18 00:24:20 +00:00
else
2018-03-18 12:00:37 +00:00
let l:statusline .= '%#StatusLinePercent#'
2018-03-18 00:24:20 +00:00
endif
2018-03-28 20:02:37 +00:00
let l:statusline .= '%P %* '
"}}}
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
" non-empty buftype (help, quickfix, etc)
if a:isactive "{{{
2018-03-17 23:42:49 +00:00
let l:statusline .= l:active . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineActiveNoText#"
else
let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#"
endif
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s"
2018-03-18 00:24:20 +00:00
"}}}
2018-03-17 23:42:49 +00:00
" right/left divider
2018-03-28 20:02:37 +00:00
let l:statusline.=l:separator "{{{
" modified version
2018-03-17 23:42:49 +00:00
let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'')
let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
" unmodified version
let l:color = 'StatusLineDiv' . (a:isactive?'Active':'')
let l:statusline .= GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider)
" input mode version
if a:isactive
let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
endif
2018-03-18 00:55:19 +00:00
2018-03-17 23:42:49 +00:00
let l:statusline.= l:separator . '%*%='
2018-03-18 00:55:19 +00:00
if !a:isactive
let l:statusline .= ' '
endif
2018-03-28 20:02:37 +00:00
"}}}
" current register
if a:isactive "{{{
let l:statusline.=l:separator . l:active
let l:statusline.=' %#StatusLineActiveQuotes#"' . l:active . '%{v:register}%#StatusLineActiveQuotes#" '
endif
"}}}
" session status
if a:isactive "{{{
let l:statusline.=l:separator . l:active
let l:statusline.=" %{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')} %*"
let l:statusline.=l:separator . l:active
endif
"}}}
" file info
if a:isactive == 1 "{{{
let l:statusline.=l:active
let l:statusline.=" %{strlen(&ft)?&ft:'none'} "
" let l:statusline.=l:separator . l:active
" let l:statusline.=' %{strlen(&fenc)?&fenc:&enc} '
" let l:statusline.=l:separator . l:active
" let l:statusline.=' %{&fileformat} '
" let l:statusline.=l:separator . l:active
" let l:statusline.=' %{&spelllang} '
let l:statusline.=l:separator
endif
2018-03-18 00:24:20 +00:00
"}}}
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
" path/filename.extension
if a:isactive "{{{
let l:statusline.='%#StatusLineDirActive# '
let l:statusline.="%{expand('%:p:h:t')}/"
let l:statusline.='%#StatusLineFileActive#'
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
let l:statusline.="%{expand('%:t:r')}"
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
let l:statusline.='%#StatusLineDotActive#'
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
let l:statusline.='%#StatusLineExtActive#'
2018-03-18 00:55:19 +00:00
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
2018-03-28 20:30:44 +00:00
let l:statusline .= '%#InterfaceSignWarning# %R '
2018-03-18 00:24:20 +00:00
else
let l:statusline.='%#StatusLineDir# '
let l:statusline.="%{expand('%:p:h')}/"
let l:statusline.='%#StatusLineFile#'
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
let l:statusline.="%{expand('%:t:r')}"
2018-03-17 23:42:49 +00:00
2018-03-18 00:24:20 +00:00
let l:statusline.='%#StatusLineDot#'
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
let l:statusline.='%#StatusLineExt#'
2018-03-18 00:55:19 +00:00
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
2018-03-28 20:30:44 +00:00
let l:statusline .= '%#LinterWarningInactive# %R '
2018-03-18 00:24:20 +00:00
endif
2018-03-28 20:02:37 +00:00
let l:statusline.='%*'
2018-03-18 00:24:20 +00:00
"}}}
2018-03-17 23:42:49 +00:00
" linter status "
2018-03-18 00:24:20 +00:00
if a:isactive "{{{
2018-03-17 23:42:49 +00:00
" errors
2018-03-21 22:32:36 +00:00
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('error') == 0?'-':'')}"
let l:statusline .= "%#LinterError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
2018-03-17 23:42:49 +00:00
" style errors
let l:statusline .= '%#LinterDash#|'
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_error') == 0?'-':'')}"
let l:statusline .= "%#LinterErrorStyle#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
2018-03-17 23:42:49 +00:00
" warnings
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
2018-03-17 23:42:49 +00:00
" style warnings
let l:statusline .= '%#LinterDash#|'
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarningStyle#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
2018-03-17 23:42:49 +00:00
" info
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('info') == 0?'-':'')}"
let l:statusline .= "%#LinterInfo#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
2018-03-17 23:42:49 +00:00
else
" errors
2018-03-21 22:32:36 +00:00
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('error') == 0?'-':'')}"
let l:statusline .= "%#LinterErrorInactive#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
2018-03-17 23:42:49 +00:00
" style errors
let l:statusline .= '%#LinterDash#|'
2018-03-17 23:42:49 +00:00
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
let l:statusline .= "%#LinterErrorStyleInactive#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
2018-03-17 23:42:49 +00:00
" warnings
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarningInactive#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
2018-03-17 23:42:49 +00:00
" style warnings
let l:statusline .= '%#LinterDash#|'
2018-03-17 23:42:49 +00:00
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarningStyleInactive#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
2018-03-17 23:42:49 +00:00
" info
2018-03-18 17:13:21 +00:00
let l:statusline .= "%#LinterDash#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
2018-03-17 23:42:49 +00:00
endif
2018-03-18 00:24:20 +00:00
"}}}
2018-03-17 23:42:49 +00:00
return l:statusline
2018-04-01 15:07:11 +00:00
endfunction
"}}}
function! DoInsertEnter()
set cursorline"{{{
hi LineNr ctermfg=235 guifg=#262626
hi CursorLineNr ctermfg=250 guifg=#bcbcbc
endfunction
"}}}
function! DoInsertLeave()
set nocursorline"{{{
hi LineNr ctermfg=237 guifg=#3a3a3a
hi CursorLineNr ctermfg=243 guifg=#767676
endfunction
"}}}
2018-03-17 23:42:49 +00:00
2018-04-01 15:07:11 +00:00
" augroups
2018-03-17 23:42:49 +00:00
2018-04-01 15:07:11 +00:00
augroup statuscursorlines
au!
au InsertEnter * call DoInsertEnter()
au InsertLeave * call DoInsertLeave()
augroup END
2018-03-17 23:42:49 +00:00
" vim: foldmethod=marker