From 261dafca9dde0a85ae5cb58d07e68117c77f7939 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Thu, 22 Aug 2013 03:25:22 +0000 Subject: [PATCH] fold exclude funcrefs into the default one. --- autoload/airline.vim | 11 ++++------- autoload/airline/extensions.vim | 14 +++++--------- autoload/airline/extensions/ctrlp.vim | 7 ++++--- doc/airline.txt | 14 +++++++------- plugin/airline.vim | 3 +-- 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index b0480de1..0f91dbed 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -73,11 +73,6 @@ function! airline#get_statusline(winnr, active) endfunction function! airline#update_statusline() - if airline#util#exec_funcrefs(g:airline_exclude_funcrefs) - call setwinvar(winnr(), '&statusline', '') - return - endif - for nr in filter(range(1, winnr('$')), 'v:val != winnr()') call setwinvar(nr, 'airline_active', 0) call setwinvar(nr, '&statusline', airline#get_statusline(nr, 0)) @@ -90,9 +85,11 @@ function! airline#update_statusline() for section in s:sections unlet! w:airline_section_{section} endfor - call airline#util#exec_funcrefs(g:airline_statusline_funcrefs) - call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1)) + let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs) + if err == 0 + call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1)) + endif endfunction function! airline#check_mode() diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 52f8de3f..89b38764 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -2,13 +2,9 @@ " vim: et ts=2 sts=2 sw=2 let s:ext = {} -let s:ext._cursormove_funcrefs = [] function! s:ext.add_statusline_funcref(funcref) dict call add(g:airline_statusline_funcrefs, a:funcref) endfunction -function! s:ext.add_cursormove_funcref(funcref) dict - call add(self._cursormove_funcrefs, a:funcref) -endfunction let s:script_path = expand(':p:h') @@ -35,6 +31,10 @@ endfunction let s:active_winnr = -1 function! airline#extensions#update_statusline(...) + if s:is_excluded_window(a:000) + return -1 + endif + let s:active_winnr = winnr() if &buftype == 'quickfix' @@ -67,7 +67,7 @@ function! airline#extensions#update_statusline(...) endfor endfunction -function! airline#extensions#is_excluded_window(...) +function! s:is_excluded_window(...) for matchft in g:airline_exclude_filetypes if matchft ==# &ft return 1 @@ -95,9 +95,6 @@ endfunction function! s:sync_active_winnr() if exists('#airline') && winnr() != s:active_winnr - if airline#util#exec_funcrefs(s:ext._cursormove_funcrefs) - return - endif call airline#update_statusline() endif endfunction @@ -107,7 +104,6 @@ function! airline#extensions#load() autocmd CursorMoved * call sync_active_winnr() " load core funcrefs - call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window')) call add(g:airline_statusline_funcrefs, function('airline#extensions#update_statusline')) if get(g:, 'loaded_unite', 0) diff --git a/autoload/airline/extensions/ctrlp.vim b/autoload/airline/extensions/ctrlp.vim index 8f30e2d0..fe70a896 100644 --- a/autoload/airline/extensions/ctrlp.vim +++ b/autoload/airline/extensions/ctrlp.vim @@ -49,8 +49,9 @@ function! airline#extensions#ctrlp#ctrlp_airline_status(...) return len.dir endfunction -function! airline#extensions#ctrlp#is_statusline_overwritten(...) - return match(&statusline, 'CtrlPlight') >= 0 +function! airline#extensions#ctrlp#apply(...) + " disable statusline overwrite if ctrlp already did it + return match(&statusline, 'CtrlPlight') >= 0 ? -1 : 0 endfunction function! airline#extensions#ctrlp#init(ext) @@ -58,6 +59,6 @@ function! airline#extensions#ctrlp#init(ext) \ 'main': 'airline#extensions#ctrlp#ctrlp_airline', \ 'prog': 'airline#extensions#ctrlp#ctrlp_airline_status', \ } - call a:ext.add_cursormove_funcref(function('airline#extensions#ctrlp#is_statusline_overwritten')) + call a:ext.add_statusline_funcref(function('airline#extensions#ctrlp#apply')) endfunction diff --git a/doc/airline.txt b/doc/airline.txt index 995f0538..98015554 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -259,15 +259,15 @@ is an example of how you can extend vim-airline to support a new plugin. endfunction call add(g:airline_statusline_funcrefs, function('MyPlugin')) < - *g:airline_exclude_funcrefs* -The g:airline_exclude_funcrefs variable is an array that's returns 1 or 0 to -determine whether that particular window should be excluded from having its -statusline modified. Here is an example: + +You can also control what happens by returning an error code. Note that +returning a value other than 0 will prevent any remaining extensions from +having their funcrefs invoked. > - function! ExcludeFoo() - return &filetype == 'FooType' + function! MyPlugin(...) + return 0 " the default action, modify the statusline + return -1 " do not update the statusline endfunction - call add(g:airline_exclude_funcrefs, function('ExcludeFoo')) < ============================================================================== diff --git a/plugin/airline.vim b/plugin/airline.vim index 9cafbe99..4a1b87db 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -25,7 +25,6 @@ call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerSt call s:check_defined('g:airline_exclude_filetypes', []) call s:check_defined('g:airline_exclude_preview', 0) call s:check_defined('g:airline_statusline_funcrefs', []) -call s:check_defined('g:airline_exclude_funcrefs', []) call s:check_defined('g:airline_mode_map', { \ '__' : '------', @@ -90,7 +89,7 @@ function! s:on_colorscheme_changed() call airline#load_theme() endfunction -function airline#cmdwinenter() +function airline#cmdwinenter(...) call airline#extensions#apply_left_override('Command Line', '') endfunction