status line linter status

This commit is contained in:
ManjaroOne666 2018-03-17 00:58:49 +00:00
parent 288e131ed9
commit 2d14eb62bc
2 changed files with 84 additions and 26 deletions

View File

@ -9,7 +9,7 @@ endif
set fillchars=stl:\ ,stlnc:\ ,vert:\| set fillchars=stl:\ ,stlnc:\ ,vert:\|
let colors_name = 'customred256' let g:colors_name = 'customred256'
if has('gui_running') if has('gui_running')
hi Normal ctermfg=246 guifg=#949494 ctermbg=none guibg=#000000 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 InterfaceSignError ctermfg=196 guifg=#ff0000 gui=bold
hi InterfaceSignErrorDark ctermfg=196 guifg=#aa0000 gui=bold
hi InterfaceSignWarning ctermfg=88 guifg=#870000 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 InterfaceSignAdd ctermfg=22 guifg=#395239
hi InterfaceSignModified ctermfg=178 guifg=#4e4e33 hi InterfaceSignModified ctermfg=178 guifg=#4e4e33
@ -90,6 +92,8 @@ hi CRSpecialDark ctermfg=53 guifg=#bd6e00
hi CRNoiseBright ctermfg=243 guifg=#707070 hi CRNoiseBright ctermfg=243 guifg=#707070
hi CRNoise ctermfg=240 guifg=#444444 hi CRNoise ctermfg=240 guifg=#444444
hi CRNoiseDark ctermfg=238 guifg=#333333 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 CRCommentBright ctermfg=244 guifg=#808080 gui=italic cterm=italic term=italic
hi CRComment ctermfg=240 guifg=#585858 gui=italic cterm=italic term=italic hi CRComment ctermfg=240 guifg=#585858 gui=italic cterm=italic term=italic

90
vimrc
View File

@ -255,15 +255,16 @@ iabbrev tehn then
" get status line{{{ " get status line{{{
function! GetStatus(isactive) function! GetStatus(isactive)
let l:divider='- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >' " let l:linter = ale#statusline#Count(bufnr(''))
let l:separator='%#StatusLineSeparator# ' let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
let l:normal='%#StatusLineNormal#' let l:separator = '%#StatusLineSeparator# '
let l:active='%#StatusLineActive#' let l:normal = '%#StatusLineNormal#'
let l:statusline='' 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{{{ " file info{{{
@ -298,19 +299,19 @@ function! GetStatus(isactive)
" right/left divider{{{ " right/left divider{{{
" modified version " modified version
let l:color='StatusLineDivMod' . (a:isactive?'Active':'') let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'')
let l:statusline.=GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider) let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
" unmodified version " unmodified version
let l:color='StatusLineDiv' . (a:isactive?'Active':'') let l:color = 'StatusLineDiv' . (a:isactive?'Active':'')
let l:statusline.=GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider) let l:statusline .= GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider)
" input mode version " input mode version
if a:isactive if a:isactive
let l:statusline.=GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider) let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
endif 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{{{ " file percentage{{{
let l:statusline.=l:separator . '%#InterfaceNormalDark#%P%*' let l:statusline.=l:separator . '%#InterfaceNormalDark#%P%*'
return l:statusline return l:statusline
@ -412,14 +458,14 @@ augroup END
" #functions{{{ " #functions{{{
" TODO better name " 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:colorname . '#'
let l:frag.=a:conditionprefix let l:frag.=a:conditionprefix
let l:frag.='%{(' . a:condition . ")?'" . a:text . "':''}" let l:frag.='%{(' . a:condition . ")?'" . a:text . "':''}"
return l:frag return l:frag
endfunction"}}} endfunction"}}}
function! CheckLineEnding() "{{{ function! CheckLineEnding() abort "{{{
:normal $ :normal $
if getline('.')[col('.')-1] == ';' || getline('.')[col('.')-1] == ',' if getline('.')[col('.')-1] == ';' || getline('.')[col('.')-1] == ','
:startinsert :startinsert
@ -429,7 +475,7 @@ function! CheckLineEnding() "{{{
endfunction"}}} endfunction"}}}
" get name of syntax item " get name of syntax item
function! SyntaxItem() "{{{ function! SyntaxItem() abort "{{{
return synIDattr(synID(line('.'),col('.'),1),'name') . ' -> ' . synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name' ) return synIDattr(synID(line('.'),col('.'),1),'name') . ' -> ' . synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name' )
endfunction endfunction
nnoremap <leader>p :echom SyntaxItem()<CR>"}}} 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 " use ranger as file manager
if !exists('*RangerExplorer')" {{{ if !exists('*RangerExplorer') "{{{
function RangerExplorer() function RangerExplorer() abort
exec 'silent !ranger --choosefile=/tmp/vim_ranger_current_file ' . expand('%:p:h') exec 'silent !ranger --choosefile=/tmp/vim_ranger_current_file ' . expand('%:p:h')
if filereadable('/tmp/vim_ranger_current_file') if filereadable('/tmp/vim_ranger_current_file')
exec 'edit ' . system('cat /tmp/vim_ranger_current_file') exec 'edit ' . system('cat /tmp/vim_ranger_current_file')
@ -477,6 +523,14 @@ function! LinterStatus() abort "{{{
endfunction endfunction
"}}} "}}}
function! GetLinterStatus(key) abort "{{{
let l:linter = ale#statusline#Count(bufnr(''))
return l:linter[a:key]
endfunction
"}}}
"}}} "}}}
" #plugin settings{{{ " #plugin settings{{{