From d2c069b971b80f1da915f9f1f50cc1a8194d3d2c Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 6 Aug 2013 21:42:32 -0400 Subject: [PATCH] make syntastic use the warning section --- autoload/airline.vim | 4 ++-- autoload/airline/extensions/syntastic.vim | 10 +++++++--- autoload/airline/extensions/whitespace.vim | 2 +- doc/airline.txt | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 72d78ad4..23997af6 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -2,7 +2,7 @@ " vim: ts=2 sts=2 sw=2 fdm=indent let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') -let s:sections = ['a','b','c','gutter','x','y','z'] +let s:sections = ['a','b','c','gutter','x','y','z','warning'] let s:airline_highlight_map = { \ 'mode' : 'Al2', @@ -105,7 +105,7 @@ function! s:get_statusline(winnr, active) let sl.=a:active ? g:airline_right_sep : g:airline_right_alt_sep let sl.=l:mode_color let sl.=s:get_section(a:winnr, 'z') - let sl.='%#Al3#'.s:getwinvar(a:winnr, 'airline_section_warning', '') + let sl.='%(%#warningmsg#'.s:getwinvar(a:winnr, 'airline_section_warning', '').'%)' endif return sl endfunction diff --git a/autoload/airline/extensions/syntastic.vim b/autoload/airline/extensions/syntastic.vim index d6b386db..85069032 100644 --- a/autoload/airline/extensions/syntastic.vim +++ b/autoload/airline/extensions/syntastic.vim @@ -1,8 +1,12 @@ " MIT license. Copyright (c) 2013 Bailey Ling. " vim: ts=2 sts=2 sw=2 fdm=indent -function! airline#extensions#syntastic#init(ext) - if g:airline_section_gutter == '' - let g:airline_section_gutter = '%#warningmsg#%{SyntasticStatuslineFlag()}' +function! airline#extensions#syntastic#apply() + if exists('w:airline_active') && w:airline_active + let w:airline_section_warning = ' %#warningmsg#%{SyntasticStatuslineFlag()}' endif endfunction + +function! airline#extensions#syntastic#init(ext) + call a:ext.add_statusline_funcref(function('airline#extensions#syntastic#apply')) +endfunction diff --git a/autoload/airline/extensions/whitespace.vim b/autoload/airline/extensions/whitespace.vim index fe842c27..0f0f751e 100644 --- a/autoload/airline/extensions/whitespace.vim +++ b/autoload/airline/extensions/whitespace.vim @@ -10,7 +10,7 @@ function! airline#extensions#whitespace#check() let mixed = search('^ ', 'nw') != 0 && search('^\t', 'nw') != 0 if trailing || mixed - let text = " ".g:airline_whitespace_symbol." " + let text = g:airline_whitespace_symbol." " if g:airline_detect_whitespace == 1 if trailing let text .= 'trailing ' diff --git a/doc/airline.txt b/doc/airline.txt index df003e64..82e0b5f8 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -168,11 +168,11 @@ with the usual statusline syntax. let g:airline_section_a (the mode/paste indicator) let g:airline_section_b (the fugitive/lawrencium branch indicator) let g:airline_section_c (bufferline or filename) - let g:airline_section_gutter (syntastic, readonly flag) + let g:airline_section_gutter let g:airline_section_x (tagbar, filetype) let g:airline_section_y (fileencoding, fileformat) let g:airline_section_z (percentage, line number, column number) - let g:airline_section_warning (special section that only appears sometimes) + let g:airline_section_warning (syntastic, whitespace) " here is an example of how you could replace the branch indicator with " the current working directory, followed by the filename.