From 11fd24b3efa122592085995aabaa37a0b7da9584 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 6 Aug 2013 02:56:30 +0000 Subject: [PATCH] extract syntastic --- autoload/airline/extensions.vim | 10 ++++++---- autoload/airline/extensions/bufferline.vim | 4 +--- autoload/airline/extensions/commandt.vim | 6 +++++- autoload/airline/extensions/syntastic.vim | 12 ++++++++++++ plugin/airline.vim | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 autoload/airline/extensions/syntastic.vim diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 38414d4d..d2534cb3 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -19,8 +19,6 @@ function! airline#extensions#apply_left_override(section1, section2) endfunction function! airline#extensions#update_external_values() - let g:airline_externals_syntastic = g:airline_enable_syntastic && exists('*SyntasticStatuslineFlag') - \ ? '%#warningmsg#%{SyntasticStatuslineFlag()}' : '' let g:airline_externals_branch = g:airline_enable_branch \ ? (exists('*fugitive#head') && strlen(fugitive#head()) > 0 \ ? g:airline_branch_prefix.fugitive#head() @@ -120,10 +118,14 @@ function! airline#extensions#load() endif if get(g:, 'command_t_loaded', 0) - call add(g:airline_statusline_funcrefs, function('airline#extensions#commandt#apply_window_override')) + call airline#extensions#commandt#init(s:ext) endif - if g:airline_enable_bufferline && get(g:, 'loaded_bufferline', 0) + if g:airline_enable_syntastic && get(g:, 'loaded_syntastic_plugin') + call airline#extensions#syntastic#init(s:ext) + endif + + if g:airline_enable_bufferline && exists('*bufferline#get_status_string') call airline#extensions#bufferline#init(s:ext) endif diff --git a/autoload/airline/extensions/bufferline.vim b/autoload/airline/extensions/bufferline.vim index 84c8a33f..6bed4160 100644 --- a/autoload/airline/extensions/bufferline.vim +++ b/autoload/airline/extensions/bufferline.vim @@ -14,7 +14,5 @@ function! airline#extensions#bufferline#init(ext) let g:bufferline_active_buffer_right = '' let g:bufferline_separator = ' ' - if g:airline_enable_bufferline && exists('*bufferline#get_status_string') - call a:ext.add_statusline_funcref(function('airline#extensions#bufferline#apply')) - endif + call a:ext.add_statusline_funcref(function('airline#extensions#bufferline#apply')) endfunction diff --git a/autoload/airline/extensions/commandt.vim b/autoload/airline/extensions/commandt.vim index 6ade0329..2c55675f 100644 --- a/autoload/airline/extensions/commandt.vim +++ b/autoload/airline/extensions/commandt.vim @@ -1,8 +1,12 @@ " MIT license. Copyright (c) 2013 Bailey Ling. " vim: ts=2 sts=2 sw=2 fdm=indent -function! airline#extensions#commandt#apply_window_override() +function! airline#extensions#commandt#apply() if bufname('%') ==# 'GoToFile' call airline#extensions#apply_left_override('CommandT', '') endif endfunction + +function! airline#extensions#commandt#init(ext) + call ext.add_statusline_funcref(function('airline#extensions#commandt#apply')) +endfunction diff --git a/autoload/airline/extensions/syntastic.vim b/autoload/airline/extensions/syntastic.vim new file mode 100644 index 00000000..f77cfd6b --- /dev/null +++ b/autoload/airline/extensions/syntastic.vim @@ -0,0 +1,12 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#extensions#syntastic#apply() + let w:airline_section_gutter = '%#warningmsg#%{SyntasticStatuslineFlag()}' +endfunction + +function! airline#extensions#syntastic#init(ext) + if g:airline_enable_syntastic && exists('*SyntasticStatuslineFlag') + call a:ext.add_statusline_funcref(function('airline#extensions#syntastic#apply')) + endif +endfunction diff --git a/plugin/airline.vim b/plugin/airline.vim index 704ebb2d..537b2b13 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -58,7 +58,7 @@ function! s:on_window_changed() call s:check_defined('g:airline_section_a', '%{g:airline_current_mode_text}') call s:check_defined('g:airline_section_b', '%{g:airline_externals_branch}') call s:check_defined('g:airline_section_c', '%f%m') - call s:check_defined('g:airline_section_gutter', g:airline_externals_syntastic) + call s:check_defined('g:airline_section_gutter', '') call s:check_defined('g:airline_section_x', g:airline_externals_tagbar."%{strlen(&filetype)>0?&filetype:''}") call s:check_defined('g:airline_section_y', "%{strlen(&fenc)>0?&fenc:''}%{strlen(&ff)>0?'['.&ff.']':''}") call s:check_defined('g:airline_section_z', '%3p%% '.g:airline_linecolumn_prefix.'%3l:%3c')