place syntastic and whitespace into parts.
This commit is contained in:
parent
f9718e6b65
commit
6fc8c00ef1
|
@ -185,14 +185,12 @@ function! airline#extensions#load()
|
|||
call airline#extensions#virtualenv#init(s:ext)
|
||||
endif
|
||||
|
||||
if g:airline_section_warning == '__'
|
||||
if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1))
|
||||
call airline#extensions#whitespace#init(s:ext)
|
||||
endif
|
||||
if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1))
|
||||
\ && exists(':SyntasticCheck')
|
||||
call airline#extensions#syntastic#init(s:ext)
|
||||
endif
|
||||
if (get(g:, 'airline#extensions#whitespace#enabled', 1) && get(g:, 'airline_detect_whitespace', 1))
|
||||
call airline#extensions#whitespace#init(s:ext)
|
||||
endif
|
||||
if (get(g:, 'airline#extensions#syntastic#enabled', 1) && get(g:, 'airline_enable_syntastic', 1))
|
||||
\ && exists(':SyntasticCheck')
|
||||
call airline#extensions#syntastic#init(s:ext)
|
||||
endif
|
||||
|
||||
" load all other extensions not part of the default distribution
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
function! airline#extensions#syntastic#apply(...)
|
||||
call airline#extensions#append_to_section('warning', '%{SyntasticStatuslineFlag()}')
|
||||
function! airline#extensions#syntastic#get_warnings()
|
||||
let errors = SyntasticStatuslineFlag()
|
||||
if strlen(errors) > 0
|
||||
return ' '.errors
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#syntastic#init(ext)
|
||||
call a:ext.add_statusline_func('airline#extensions#syntastic#apply')
|
||||
let g:airline_parts.syntastic = '%{airline#extensions#syntastic#get_warnings()}'
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ let s:checks = get(g:, 'airline#extensions#whitespace#checks', ['indent', 'trail
|
|||
let s:trailing_format = get(g:, 'airline#extensions#whitespace#trailing_format', 'trailing[%s]')
|
||||
let s:mixed_indent_format = get(g:, 'airline#extensions#whitespace#mixed_indent_format', 'mixed-indent[%s]')
|
||||
|
||||
let s:initialized = 0
|
||||
let s:enabled = 1
|
||||
|
||||
function! airline#extensions#whitespace#check()
|
||||
|
@ -39,14 +38,14 @@ function! airline#extensions#whitespace#check()
|
|||
endif
|
||||
|
||||
if trailing != 0 || mixed
|
||||
let b:airline_whitespace_check = s:symbol." "
|
||||
let b:airline_whitespace_check = s:symbol.' '
|
||||
if s:show_message
|
||||
if trailing != 0
|
||||
let b:airline_whitespace_check .= printf(s:trailing_format, trailing).' '
|
||||
let b:airline_whitespace_check .= printf(s:trailing_format, trailing)
|
||||
endif
|
||||
if mixed
|
||||
let mixnr = indents[0] == indents[1] ? indents[0] : indents[2]
|
||||
let b:airline_whitespace_check .= printf(s:mixed_indent_format, mixnr).' '
|
||||
let b:airline_whitespace_check .= printf(s:mixed_indent_format, mixnr)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -54,10 +53,6 @@ function! airline#extensions#whitespace#check()
|
|||
return b:airline_whitespace_check
|
||||
endfunction!
|
||||
|
||||
function! airline#extensions#whitespace#apply(...)
|
||||
call airline#extensions#append_to_section('warning', ' %{airline#extensions#whitespace#check()}')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#whitespace#toggle()
|
||||
if s:enabled
|
||||
autocmd! airline_whitespace CursorHold,BufWritePost
|
||||
|
@ -69,10 +64,7 @@ function! airline#extensions#whitespace#toggle()
|
|||
endfunction
|
||||
|
||||
function! airline#extensions#whitespace#init(...)
|
||||
if !s:initialized
|
||||
let s:initialized = 1
|
||||
call airline#add_statusline_func('airline#extensions#whitespace#apply')
|
||||
endif
|
||||
let g:airline_parts.whitespace = '%{airline#extensions#whitespace#check()}'
|
||||
|
||||
unlet! b:airline_whitespace_check
|
||||
augroup airline_whitespace
|
||||
|
|
|
@ -48,6 +48,8 @@ call extend(g:airline_parts, {
|
|||
\ 'hunks': '',
|
||||
\ 'branch': '',
|
||||
\ 'tagbar': '',
|
||||
\ 'syntastic': '',
|
||||
\ 'whitespace': '',
|
||||
\ }, 'keep')
|
||||
|
||||
call s:check_defined('g:airline_mode_map', {})
|
||||
|
@ -87,7 +89,7 @@ function! s:init()
|
|||
call s:check_defined('g:airline_section_x', (g:airline_parts.tagbar).'%{&filetype}')
|
||||
call s:check_defined('g:airline_section_y', g:airline_parts.ffenc)
|
||||
call s:check_defined('g:airline_section_z', '%3p%% %{g:airline_symbols.linenr} %3l:%3c')
|
||||
call s:check_defined('g:airline_section_warning', '__')
|
||||
call s:check_defined('g:airline_section_warning', (g:airline_parts.syntastic).' '.(g:airline_parts.whitespace))
|
||||
|
||||
let s:airline_theme_defined = exists('g:airline_theme')
|
||||
if s:airline_theme_defined || !airline#switch_matching_theme()
|
||||
|
|
Loading…
Reference in New Issue