181 lines
6.4 KiB
VimL
181 lines
6.4 KiB
VimL
set statusline=%!GetStatus(1)
|
|
|
|
" 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
|
|
"}}}
|
|
|
|
" functions
|
|
|
|
function! GetStatus(isactive) "{{{
|
|
" let l:linter = ale#statusline#Count(bufnr(''))
|
|
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
|
|
let l:separator = '%#StatusLineSeparator# '
|
|
let l:normal = '%#StatusLineNormal#'
|
|
let l:active = '%#StatusLineActive#'
|
|
let l:statusline = ''
|
|
|
|
" file percentage
|
|
let l:statusline .= '%#FoldColumn#┼ ' "{{{
|
|
if a:isactive
|
|
let l:statusline .= '%#StatusLinePercentActive#'
|
|
else
|
|
let l:statusline .= '%#StatusLinePercent#'
|
|
endif
|
|
let l:statusline .= '%P %* '
|
|
"}}}
|
|
|
|
" non-empty buftype (help, quickfix, etc)
|
|
if a:isactive "{{{
|
|
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"
|
|
"}}}
|
|
|
|
" 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
|
|
"}}}
|
|
|
|
" right/left divider
|
|
let l:statusline.=l:separator "{{{
|
|
" modified version
|
|
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
|
|
|
|
let l:statusline.= l:separator . '%*%='
|
|
|
|
if !a:isactive
|
|
let l:statusline .= ' '
|
|
endif
|
|
"}}}
|
|
|
|
|
|
" path/filename.extension
|
|
if a:isactive "{{{
|
|
let l:statusline.='%#StatusLineDirActive# '
|
|
let l:statusline.="%{expand('%:p:h:t')}/"
|
|
let l:statusline.='%#StatusLineFileActive#'
|
|
|
|
let l:statusline.="%{expand('%:t:r')}"
|
|
|
|
let l:statusline.='%#StatusLineDotActive#'
|
|
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
|
let l:statusline.='%#StatusLineExtActive#'
|
|
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
|
|
let l:statusline .= '%#InterfaceSignWarning# %R '
|
|
else
|
|
let l:statusline.='%#StatusLineDir# '
|
|
let l:statusline.="%{fnamemodify(expand('%:p:h'),':~')}/"
|
|
let l:statusline.='%#StatusLineFile#'
|
|
|
|
let l:statusline.="%{expand('%:t:r')}"
|
|
|
|
let l:statusline.='%#StatusLineDot#'
|
|
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
|
|
let l:statusline.='%#StatusLineExt#'
|
|
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
|
|
let l:statusline .= '%#LinterWarningInactive# %R '
|
|
endif
|
|
let l:statusline.='%*'
|
|
"}}}
|
|
|
|
" linter status "
|
|
if a:isactive "{{{
|
|
" errors
|
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('error') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
|
" 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'))} "
|
|
|
|
" warnings
|
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
|
" 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'))} "
|
|
|
|
" info
|
|
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('info') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterInfo#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
|
|
else
|
|
" errors
|
|
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('error') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterErrorInactive#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
|
" style errors
|
|
let l:statusline .= '%#LinterDash#|'
|
|
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterErrorStyleInactive#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
|
|
|
" warnings
|
|
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterWarningInactive#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
|
" style warnings
|
|
let l:statusline .= '%#LinterDash#|'
|
|
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
|
let l:statusline .= "%#LinterWarningStyleInactive#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
|
|
|
" info
|
|
let l:statusline .= "%#LinterDash#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
|
|
endif
|
|
"}}}
|
|
|
|
return l:statusline
|
|
|
|
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
|
|
"}}}
|
|
|
|
|
|
" augroups
|
|
|
|
augroup statuscursorlines
|
|
au!
|
|
au InsertEnter * call DoInsertEnter()
|
|
au InsertLeave * call DoInsertLeave()
|
|
augroup END
|
|
|
|
" vim: foldmethod=marker
|