support display only tail end of a branch; as well as custom format

functions. resolves #710.
This commit is contained in:
Bailey Ling
2015-02-27 22:04:13 -05:00
parent f0492b5aea
commit ca44fd467c
2 changed files with 32 additions and 2 deletions

View File

@@ -9,6 +9,21 @@ if !s:has_fugitive && !s:has_lawrencium && !s:has_vcscommand
finish
endif
let s:head_format = get(g:, 'airline#extensions#branch#format', 0)
if s:head_format == 1
function! s:format_name(name)
return fnamemodify(a:name, ':t')
endfunction
elseif type(s:head_format) == type('')
function! s:format_name(name)
return call(s:head_format, [a:name])
endfunction
else
function! s:format_name(name)
return a:name
endfunction
endif
let s:git_dirs = {}
function! s:get_git_branch(path)
if has_key(s:git_dirs, a:path)
@@ -79,6 +94,7 @@ function! airline#extensions#branch#head()
endif
endif
let b:airline_head = s:format_name(b:airline_head)
return b:airline_head
endfunction