mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 09:58:29 +08:00
support display only tail end of a branch; as well as custom format
functions. resolves #710.
This commit is contained in:
parent
f0492b5aea
commit
ca44fd467c
|
@ -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
|
||||
|
||||
|
|
|
@ -296,13 +296,27 @@ vcscommand <http://www.vim.org/scripts/script.php?script_id=90>
|
|||
<
|
||||
* change the text for when no branch is detected >
|
||||
let g:airline#extensions#branch#empty_message = ''
|
||||
|
||||
<
|
||||
* use vcscommand.vim if available >
|
||||
let g:airline#extensions#branch#use_vcscommand = 0
|
||||
|
||||
<
|
||||
* truncate long branch names to a fixed length >
|
||||
let g:airline#extensions#branch#displayed_head_limit = 10
|
||||
<
|
||||
* customize formatting of branch name >
|
||||
" default value leaves the name unmodifed
|
||||
let g:airline#extensions#branch#format = 0
|
||||
|
||||
" to only show the tail, e.g. a branch 'feature/foo' show 'foo'
|
||||
let g:airline#extensions#branch#format = 1
|
||||
|
||||
" if a string is provided, it should be the name of a function that
|
||||
" takes a string and returns the desired value
|
||||
let g:airline#extensions#branch#format = 'CustomBranchName'
|
||||
function! CustomBranchName(name)
|
||||
return '[' . a:name . ']'
|
||||
endfunction
|
||||
<
|
||||
------------------------------------- *airline-syntastic*
|
||||
syntastic <https://github.com/scrooloose/syntastic>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user