diff --git a/vimrc.d/statusline.vim b/vimrc.d/statusline.vim index 32c4e2a..fa6f2ef 100644 --- a/vimrc.d/statusline.vim +++ b/vimrc.d/statusline.vim @@ -1,8 +1,6 @@ " #statusline format -" isactive = 0 when inactive, 1 otherwise -" get status line -function! GetStatus(isactive) +function! GetStatus(isactive) "{{{ " let l:linter = ale#statusline#Count(bufnr('')) let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >' let l:separator = '%#StatusLineSeparator# ' @@ -11,26 +9,28 @@ function! GetStatus(isactive) let l:bracket_open = '%#CRNoiseDark#(' let l:bracket_close = '%#CRNoiseDark#) ' let l:statusline = '' - " let l:statusline = '%#CRNoise#b%#CRNoiseDark#:%#CRNoiseBright#%n ' - - " let l:curbuf = bufnr('') - " let l:statusline .= '%#CRNormal#' . l:curbuf . ': ' . &buftype . ' ' " file percentage - let l:statusline.='%#FoldColumn#: %#InterfaceNormal# %P%* ' - - + let l:statusline .= '%#FoldColumn#: ' if a:isactive + let l:statusline .= '%#StatusLineNormal#' + else + let l:statusline .= '%#StatusLineDir#' + 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 + if a:isactive == 1 "{{{ let l:statusline.=l:active let l:statusline.=" %{strlen(&ft)?&ft:'none'} " let l:statusline.=l:separator . l:active @@ -42,26 +42,25 @@ function! GetStatus(isactive) else let l:statusline.=l:separator endif - +"}}} " current register - if a:isactive + 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 + 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 - +"}}} " right/left divider - - " modified version + " modified version {{{ let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'') let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider) @@ -75,49 +74,39 @@ function! GetStatus(isactive) endif let l:statusline.= l:separator . '%*%=' +"}}} + " 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')}" -" modified flag -" let l:statusline.='%#StatusLineMod#%M' . l:separator . '%*' + 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.=' %*' + else + let l:statusline.='%#StatusLineDir# ' + let l:statusline.="%{expand('%:p:h')}/" + let l:statusline.='%#StatusLineFile#' + let l:statusline.="%{expand('%:t:r')}" -" 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.=' %*' -else - let l:statusline.='%#StatusLineDir# ' - let l:statusline.="%{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.=' %*' -endif + 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.=' %*' + endif let l:statusline .= '%#CRNormal#%r' " TODO color - - + "}}} " linter status " - " let l:statusline.= "%{LinterStatus()} " - - if a:isactive + if a:isactive "{{{ " errors let l:statusline .= " %#CRNoiseDark#%{(GetLinterStatus('error') == 0?'-':'')}" let l:statusline .= "%#InterfaceSignError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}" @@ -157,23 +146,19 @@ endif " info let l:statusline .= "%#CRNoiseDarker#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}" endif - - +"}}} return l:statusline -endfunction +endfunction "}}} -" status line autocommands -augroup status +augroup status "{{{ autocmd! autocmd 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 - - +augroup END"}}} function! LinterStatus() abort "{{{ let l:counts = ale#statusline#Count(bufnr(''))