syntastic: distinguis errors and warnings
Currently the syntastic results are simply dumped into the error section, however syntastic does internally distinguish between error and warning sections. Therefore change the syntastic extension to dump errors into the error section and warnings into the warning section. closes #1480
This commit is contained in:
parent
d2b697d27b
commit
2e3055541e
|
@ -7,15 +7,38 @@ if !exists(':SyntasticCheck')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! airline#extensions#syntastic#get_warnings()
|
let s:error_symbol = get(g:, 'airline#extensions#syntastic#error_symbol', 'E:')
|
||||||
let errors = SyntasticStatuslineFlag()
|
let s:warning_symbol = get(g:, 'airline#extensions#syntastic#warning_symbol', 'W:')
|
||||||
if strlen(errors) > 0
|
|
||||||
return errors.(g:airline_symbols.space)
|
function! airline#extensions#syntastic#get_warning()
|
||||||
|
return airline#extensions#syntastic#get('warning')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#extensions#syntastic#get_error()
|
||||||
|
return airline#extensions#syntastic#get('error')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#extensions#syntastic#get(type)
|
||||||
|
let _backup = get(g:, 'syntastic_stl_format', '')
|
||||||
|
let is_err = (a:type is# 'error')
|
||||||
|
let res = ''
|
||||||
|
if is_err
|
||||||
|
let g:syntastic_stl_format = '%E{%e}'
|
||||||
|
else
|
||||||
|
let g:syntastic_stl_format = '%W{%w}'
|
||||||
|
endif
|
||||||
|
let cnt = SyntasticStatuslineFlag()
|
||||||
|
if !empty(_backup)
|
||||||
|
let g:syntastic_stl_format = _backup
|
||||||
|
endif
|
||||||
|
if cnt == 0
|
||||||
|
return ''
|
||||||
|
else
|
||||||
|
return (is_err ? s:error_symbol : s:warning_symbol).cnt
|
||||||
endif
|
endif
|
||||||
return ''
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#syntastic#init(ext)
|
function! airline#extensions#syntastic#init(ext)
|
||||||
call airline#parts#define_function('syntastic', 'airline#extensions#syntastic#get_warnings')
|
call airline#parts#define_function('syntastic-warn', 'airline#extensions#syntastic#get_warning')
|
||||||
|
call airline#parts#define_function('syntastic-err', 'airline#extensions#syntastic#get_error')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -142,9 +142,10 @@ function! airline#init#bootstrap()
|
||||||
\ 'raw': '/%L%{g:airline_symbols.maxlinenr}',
|
\ 'raw': '/%L%{g:airline_symbols.maxlinenr}',
|
||||||
\ 'accent': 'bold'})
|
\ 'accent': 'bold'})
|
||||||
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
|
call airline#parts#define_function('ffenc', 'airline#parts#ffenc')
|
||||||
call airline#parts#define_empty(['hunks', 'branch', 'obsession', 'tagbar', 'syntastic',
|
call airline#parts#define_empty(['hunks', 'branch', 'obsession', 'tagbar',
|
||||||
\ 'eclim', 'whitespace','windowswap', 'ycm_error_count', 'ycm_warning_count',
|
\ 'syntastic-warn', 'syntastic-err', 'eclim', 'whitespace','windowswap',
|
||||||
\ 'neomake_error_count', 'neomake_warning_count', 'ale_error_count', 'ale_warning_count'])
|
\ 'ycm_error_count', 'ycm_warning_count', 'neomake_error_count',
|
||||||
|
\ 'neomake_warning_count', 'ale_error_count', 'ale_warning_count'])
|
||||||
call airline#parts#define_text('capslock', '')
|
call airline#parts#define_text('capslock', '')
|
||||||
call airline#parts#define_text('xkblayout', '')
|
call airline#parts#define_text('xkblayout', '')
|
||||||
|
|
||||||
|
@ -189,9 +190,9 @@ function! airline#init#sections()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if !exists('g:airline_section_error')
|
if !exists('g:airline_section_error')
|
||||||
let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic', 'eclim', 'neomake_error_count', 'ale_error_count'])
|
let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic-err', 'eclim', 'neomake_error_count', 'ale_error_count'])
|
||||||
endif
|
endif
|
||||||
if !exists('g:airline_section_warning')
|
if !exists('g:airline_section_warning')
|
||||||
let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'neomake_warning_count', 'ale_warning_count', 'whitespace'])
|
let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'syntastic-warn', 'neomake_warning_count', 'ale_warning_count', 'whitespace'])
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in New Issue