status line linter status
This commit is contained in:
parent
288e131ed9
commit
2d14eb62bc
|
@ -9,7 +9,7 @@ endif
|
|||
|
||||
set fillchars=stl:\ ,stlnc:\ ,vert:\|
|
||||
|
||||
let colors_name = 'customred256'
|
||||
let g:colors_name = 'customred256'
|
||||
|
||||
if has('gui_running')
|
||||
hi Normal ctermfg=246 guifg=#949494 ctermbg=none guibg=#000000
|
||||
|
@ -53,7 +53,9 @@ hi def link InterfaceFlagDark CRNormalDark
|
|||
|
||||
|
||||
hi InterfaceSignError ctermfg=196 guifg=#ff0000 gui=bold
|
||||
hi InterfaceSignErrorDark ctermfg=196 guifg=#aa0000 gui=bold
|
||||
hi InterfaceSignWarning ctermfg=88 guifg=#870000 gui=bold
|
||||
hi InterfaceSignWarningDark ctermfg=88 guifg=#660000 gui=bold
|
||||
|
||||
hi InterfaceSignAdd ctermfg=22 guifg=#395239
|
||||
hi InterfaceSignModified ctermfg=178 guifg=#4e4e33
|
||||
|
@ -90,6 +92,8 @@ hi CRSpecialDark ctermfg=53 guifg=#bd6e00
|
|||
hi CRNoiseBright ctermfg=243 guifg=#707070
|
||||
hi CRNoise ctermfg=240 guifg=#444444
|
||||
hi CRNoiseDark ctermfg=238 guifg=#333333
|
||||
hi CRNoiseDarker ctermfg=233 guifg=#222222
|
||||
hi CRNoiseRed ctermfg=52 guifg=#440000
|
||||
|
||||
hi CRCommentBright ctermfg=244 guifg=#808080 gui=italic cterm=italic term=italic
|
||||
hi CRComment ctermfg=240 guifg=#585858 gui=italic cterm=italic term=italic
|
||||
|
|
104
vimrc
104
vimrc
|
@ -255,15 +255,16 @@ iabbrev tehn then
|
|||
|
||||
" get status line{{{
|
||||
function! GetStatus(isactive)
|
||||
let l:divider='- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
|
||||
let l:separator='%#StatusLineSeparator# '
|
||||
let l:normal='%#StatusLineNormal#'
|
||||
let l:active='%#StatusLineActive#'
|
||||
let l:statusline=''
|
||||
" 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 = ''
|
||||
|
||||
|
||||
" linter status{{{
|
||||
let l:statusline.='%#InterfaceH2# %{LinterStatus()} %*'
|
||||
"}}}
|
||||
|
||||
" file info{{{
|
||||
|
@ -296,21 +297,21 @@ function! GetStatus(isactive)
|
|||
"}}}
|
||||
|
||||
" right/left divider{{{
|
||||
|
||||
|
||||
" modified version
|
||||
let l:color='StatusLineDivMod' . (a:isactive?'Active':'')
|
||||
let l:statusline.=GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
|
||||
|
||||
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)
|
||||
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)
|
||||
let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
|
||||
endif
|
||||
|
||||
let l:statusline.=l:separator . '%*%='
|
||||
|
||||
let l:statusline.= l:separator . '%*%='
|
||||
|
||||
"}}}
|
||||
|
||||
|
@ -348,6 +349,51 @@ endif
|
|||
|
||||
"}}}
|
||||
|
||||
" linter status "{{{
|
||||
" let l:statusline.= "%{LinterStatus()} "
|
||||
|
||||
if a:isactive
|
||||
" errors
|
||||
let l:statusline .= " %#CRNoiseDark#%{(GetLinterStatus('error') == 0?'-':'')}"
|
||||
let l:statusline .= "%#InterfaceSignError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
||||
" style errors
|
||||
let l:statusline .= '%#CRNoiseDarker#|'
|
||||
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
||||
let l:statusline .= "%#InterfaceSignErrorDark#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
||||
|
||||
" warnings
|
||||
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
||||
let l:statusline .= "%#InterfaceSignWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
||||
" style warnings
|
||||
let l:statusline .= '%#CRNoiseDarker#|'
|
||||
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
||||
let l:statusline .= "%#InterfaceSignWarningDark#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
||||
|
||||
" info
|
||||
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('info') == 0?'-':'')}"
|
||||
let l:statusline .= "%#CRNoiseRed#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
|
||||
else
|
||||
" errors
|
||||
let l:statusline .= " %#CRNoiseDarker#%{(GetLinterStatus('error') == 0?'-':'')}"
|
||||
let l:statusline .= "%#CRNoiseBright#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
|
||||
" style errors
|
||||
let l:statusline .= '%#CRNoiseDarker#|'
|
||||
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
|
||||
let l:statusline .= "%#CRNoiseBright#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
|
||||
|
||||
" warnings
|
||||
let l:statusline .= "%#CRNoiseDarker#%{(GetLinterStatus('warning') == 0?'-':'')}"
|
||||
let l:statusline .= "%#CRNoise#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
|
||||
" style warnings
|
||||
let l:statusline .= '%#CRNoiseDarker#|'
|
||||
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
|
||||
let l:statusline .= "%#CRNoise#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
|
||||
|
||||
" info
|
||||
let l:statusline .= "%#CRNoiseDarker#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
|
||||
endif
|
||||
|
||||
"}}}
|
||||
" file percentage{{{
|
||||
let l:statusline.=l:separator . '%#InterfaceNormalDark#%P%*'
|
||||
return l:statusline
|
||||
|
@ -412,14 +458,14 @@ augroup END
|
|||
" #functions{{{
|
||||
|
||||
" TODO better name
|
||||
function! GetStatusFrag(condition, colorname, conditionprefix, text) "{{{
|
||||
function! GetStatusFrag(condition, colorname, conditionprefix, text) abort "{{{
|
||||
let l:frag='%#' . a:colorname . '#'
|
||||
let l:frag.=a:conditionprefix
|
||||
let l:frag.='%{(' . a:condition . ")?'" . a:text . "':''}"
|
||||
return l:frag
|
||||
endfunction"}}}
|
||||
|
||||
function! CheckLineEnding() "{{{
|
||||
function! CheckLineEnding() abort "{{{
|
||||
:normal $
|
||||
if getline('.')[col('.')-1] == ';' || getline('.')[col('.')-1] == ','
|
||||
:startinsert
|
||||
|
@ -429,7 +475,7 @@ function! CheckLineEnding() "{{{
|
|||
endfunction"}}}
|
||||
|
||||
" get name of syntax item
|
||||
function! SyntaxItem() "{{{
|
||||
function! SyntaxItem() abort "{{{
|
||||
return synIDattr(synID(line('.'),col('.'),1),'name') . ' -> ' . synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name' )
|
||||
endfunction
|
||||
nnoremap <leader>p :echom SyntaxItem()<CR>"}}}
|
||||
|
@ -455,8 +501,8 @@ command! -nargs=* DD silent! call system(len(split(<q-args>, ' ')) == 0 ?
|
|||
"}}}
|
||||
|
||||
" use ranger as file manager
|
||||
if !exists('*RangerExplorer')" {{{
|
||||
function RangerExplorer()
|
||||
if !exists('*RangerExplorer') "{{{
|
||||
function RangerExplorer() abort
|
||||
exec 'silent !ranger --choosefile=/tmp/vim_ranger_current_file ' . expand('%:p:h')
|
||||
if filereadable('/tmp/vim_ranger_current_file')
|
||||
exec 'edit ' . system('cat /tmp/vim_ranger_current_file')
|
||||
|
@ -468,15 +514,23 @@ if !exists('*RangerExplorer')" {{{
|
|||
endif"}}}
|
||||
|
||||
function! LinterStatus() abort "{{{
|
||||
let l:counts = ale#statusline#Count(bufnr(''))
|
||||
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
|
||||
let l:all_errors = l:counts.error + l:counts.style_error
|
||||
let l:all_non_errors = l:counts.total - l:all_errors
|
||||
|
||||
return l:counts.total == 0 ? 'OK' : printf('%dW %dE', l:all_non_errors, l:all_errors)
|
||||
return l:counts.total == 0 ? 'OK' : printf('%dW %dE', l:all_non_errors, l:all_errors)
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
function! GetLinterStatus(key) abort "{{{
|
||||
let l:linter = ale#statusline#Count(bufnr(''))
|
||||
|
||||
return l:linter[a:key]
|
||||
endfunction
|
||||
|
||||
"}}}
|
||||
|
||||
"}}}
|
||||
|
||||
" #plugin settings{{{
|
||||
|
|
Loading…
Reference in New Issue