From 0966b693d9611598e2d915ca3cdae006d0f310c9 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 3 Dec 2013 05:32:54 +0000 Subject: [PATCH] expose cleaner api to determine empty head. --- autoload/airline/extensions/branch.vim | 9 ++++++++- autoload/airline/extensions/hunks.vim | 9 ++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 87a7069..2177f64 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -14,7 +14,7 @@ let s:empty_message = get(g:, 'airline#extensions#branch#empty_message', \ get(g:, 'airline_branch_empty_message', '')) let s:symbol = get(g:, 'airline#extensions#branch#symbol', g:airline_symbols.branch) -function! airline#extensions#branch#get_head() +function! airline#extensions#branch#head() let head = '' if s:has_fugitive && !exists('b:mercurial_dir') @@ -42,6 +42,13 @@ function! airline#extensions#branch#get_head() endif return empty(head) || !s:check_in_path() + \ ? '' + \ : head +endfunction + +function! airline#extensions#branch#get_head() + let head = airline#extensions#branch#head() + return empty(head) \ ? s:empty_message \ : printf('%s%s', empty(s:symbol) ? '' : s:symbol.(g:airline_symbols.space), head) endfunction diff --git a/autoload/airline/extensions/hunks.vim b/autoload/airline/extensions/hunks.vim index 644b817..9da481d 100644 --- a/autoload/airline/extensions/hunks.vim +++ b/autoload/airline/extensions/hunks.vim @@ -16,10 +16,13 @@ function! s:get_hunks_signify() return [] endfunction +function! s:is_branch_empty() + return get(g:, 'airline#extensions#branch#enabled', 1) && empty(airline#extensions#branch#head()) +endfunction + function! s:get_hunks_gitgutter() - if !get(g:, 'gitgutter_enabled', 0) || airline#extensions#branch#get_head() == - \ get(g:, 'airline#extensions#branch#empty_message', get(g:, 'airline_branch_empty_message', '')) - return '' + if !get(g:, 'gitgutter_enabled', 0) || s:is_branch_empty() + return '' endif return GitGutterGetHunkSummary() endfunction