extract fugitive/lawrencium

This commit is contained in:
Bailey Ling 2013-08-06 03:07:01 +00:00
parent 11fd24b3ef
commit 9c960875fe
3 changed files with 21 additions and 8 deletions

View File

@ -19,13 +19,6 @@ function! airline#extensions#apply_left_override(section1, section2)
endfunction
function! airline#extensions#update_external_values()
let g:airline_externals_branch = g:airline_enable_branch
\ ? (exists('*fugitive#head') && strlen(fugitive#head()) > 0
\ ? g:airline_branch_prefix.fugitive#head()
\ : exists('*lawrencium#statusline') && strlen(lawrencium#statusline()) > 0
\ ? g:airline_branch_prefix.lawrencium#statusline()
\ : '')
\ : ''
let g:airline_externals_tagbar = g:airline_enable_tagbar && exists(':Tagbar')
\ ? '%(%{tagbar#currenttag("%s","")} '.g:airline_right_alt_sep.' %)' : ''
endfunction
@ -121,6 +114,10 @@ function! airline#extensions#load()
call airline#extensions#commandt#init(s:ext)
endif
if g:airline_enable_branch && (get(g:, 'loaded_fugitive', 0) || get(g:, 'loaded_lawrencium', 0))
call airline#extensions#branch#init(s:ext)
endif
if g:airline_enable_syntastic && get(g:, 'loaded_syntastic_plugin')
call airline#extensions#syntastic#init(s:ext)
endif

View File

@ -0,0 +1,16 @@
" MIT license. Copyright (c) 2013 Bailey Ling.
" vim: ts=2 sts=2 sw=2 fdm=indent
function! airline#extensions#branch#apply()
let w:airline_section_b =
\ exists('*fugitive#head') && strlen(fugitive#head()) > 0
\ ? g:airline_branch_prefix.fugitive#head()
\ : exists('*lawrencium#statusline') && strlen(lawrencium#statusline()) > 0
\ ? g:airline_branch_prefix.lawrencium#statusline()
\ : ''
endfunction
function! airline#extensions#branch#init(ext)
call a:ext.add_statusline_funcref(function('airline#extensions#branch#apply'))
endfunction

View File

@ -56,7 +56,7 @@ function! s:on_window_changed()
call airline#extensions#load()
call airline#load_theme(g:airline_theme)
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_b', '')
call s:check_defined('g:airline_section_c', '%f%m')
call s:check_defined('g:airline_section_gutter', '')
call s:check_defined('g:airline_section_x', g:airline_externals_tagbar."%{strlen(&filetype)>0?&filetype:''}")