rename window_override_funcrefs to statusline_funcrefs

This commit is contained in:
Bailey Ling 2013-08-03 11:14:02 -04:00
parent 257a9f2ed9
commit 94895de8e2
4 changed files with 24 additions and 12 deletions

View File

@ -117,7 +117,7 @@ function! airline#update_statusline()
for section in s:sections for section in s:sections
unlet! w:airline_section_{section} unlet! w:airline_section_{section}
endfor endfor
for Fn in g:airline_window_override_funcrefs for Fn in g:airline_statusline_funcrefs
call Fn() call Fn()
endfor endfor

View File

@ -111,7 +111,7 @@ function! airline#extensions#load()
endif endif
if get(g:, 'command_t_loaded', 0) if get(g:, 'command_t_loaded', 0)
call add(g:airline_window_override_funcrefs, function('airline#extensions#commandt#apply_window_override')) call add(g:airline_statusline_funcrefs, function('airline#extensions#commandt#apply_window_override'))
endif endif
if g:airline_enable_bufferline && get(g:, 'loaded_bufferline', 0) if g:airline_enable_bufferline && get(g:, 'loaded_bufferline', 0)
@ -124,8 +124,8 @@ function! airline#extensions#load()
let g:bufferline_separator = ' ' let g:bufferline_separator = ' '
endif endif
call add(g:airline_window_override_funcrefs, function('airline#extensions#update_external_values')) call add(g:airline_statusline_funcrefs, function('airline#extensions#update_external_values'))
call add(g:airline_window_override_funcrefs, function('airline#extensions#apply_window_overrides')) call add(g:airline_statusline_funcrefs, function('airline#extensions#apply_window_overrides'))
call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window')) call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window'))
call airline#extensions#update_external_values() call airline#extensions#update_external_values()

View File

@ -169,22 +169,31 @@ with the usual statusline syntax.
let g:airline_section_c = '%t' let g:airline_section_c = '%t'
< <
If there is a particular plugin or filetype that is not supported, you can ==============================================================================
extend it by adding a function reference to the global array. Here is an FUNCREFS *airline-funcrefs*
example that you could add to your vimrc:
vim-airline internally uses funcrefs to integrate with third party plugins,
and you can tap into this functionality to extend it for you needs.
*g:airline_statusline_funcrefs*
The g:airline_statusline_funcrefs variable is an array of funcrefs that get
invoked before the statusline gets overwritten for each window. The following
is an example of how you can extend vim-airline to support a new plugin.
> >
function! MyPlugin() function! MyPlugin()
if &filetype == 'MyPluginFileType' if &filetype == 'MyPluginFileType'
let w:airline_section_a = 'MyPlugin' let w:airline_section_a = 'MyPlugin'
let w:airline_section_b = '%f' let w:airline_section_b = '%f'
let w:airline_section_c = '%{MyPlugin#function()}' let w:airline_section_c = '%{MyPlugin#function()}'
let g:airline_variable_referenced_in_statusline = 'foo'
endif endif
endfunction endfunction
call add(g:airline_window_override_funcrefs, function('MyPlugin')) call add(g:airline_statusline_funcrefs, function('MyPlugin'))
< <
*g:airline_exclude_funcrefs*
In a similar fashion, you can define a function to exclude a window from The g:airline_exclude_funcrefs variable is an array that's returns 1 or 0 to
having its statusline modified. determine whether that particular window should be excluded from having its
statusline modified. Here is an example:
> >
function! ExcludeFoo() function! ExcludeFoo()
return &filetype == 'FooType' return &filetype == 'FooType'

View File

@ -13,6 +13,9 @@ endfunction
if exists('g:airline_enable_fugitive') || exists('g:airline_fugitive_prefix') if exists('g:airline_enable_fugitive') || exists('g:airline_fugitive_prefix')
echom 'The g:airline_enable_fugitive and g:airline_fugitive_prefix variables have been deprecated and renamed to g:airline_enable_branch and g:airline_branch_prefix respectively. Please update your vimrc.' echom 'The g:airline_enable_fugitive and g:airline_fugitive_prefix variables have been deprecated and renamed to g:airline_enable_branch and g:airline_branch_prefix respectively. Please update your vimrc.'
endif endif
if exists('g:airline_window_override_funcrefs')
echom 'The g:airline_window_override_funcrefs variable has been deprecated. Please use g:airline_statusline_funcrefs instead.'
endif
call s:check_defined('g:airline_left_sep', exists('g:airline_powerline_fonts')?"":">") call s:check_defined('g:airline_left_sep', exists('g:airline_powerline_fonts')?"":">")
call s:check_defined('g:airline_left_alt_sep', exists('g:airline_powerline_fonts')?"":">") call s:check_defined('g:airline_left_alt_sep', exists('g:airline_powerline_fonts')?"":">")
call s:check_defined('g:airline_right_sep', exists('g:airline_powerline_fonts')?"":"<") call s:check_defined('g:airline_right_sep', exists('g:airline_powerline_fonts')?"":"<")
@ -32,7 +35,7 @@ call s:check_defined('g:airline_theme', 'dark')
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus']) call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
call s:check_defined('g:airline_exclude_filetypes', []) call s:check_defined('g:airline_exclude_filetypes', [])
call s:check_defined('g:airline_exclude_preview', 0) call s:check_defined('g:airline_exclude_preview', 0)
call s:check_defined('g:airline_window_override_funcrefs', []) call s:check_defined('g:airline_statusline_funcrefs', [])
call s:check_defined('g:airline_exclude_funcrefs', []) call s:check_defined('g:airline_exclude_funcrefs', [])
call s:check_defined('g:airline_mode_map', { call s:check_defined('g:airline_mode_map', {