From a26a46069825ec391b342481b2d45be66887b8a2 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Thu, 2 May 2019 08:14:57 +0200 Subject: [PATCH] branch: configure what additional checks to run Allow to customize, whether to check the untracked status of a file or whether the current repository is clean. fixes #1910 --- autoload/airline/extensions/branch.vim | 9 +++++++-- doc/airline.txt | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 23a0bdb8..2da059f1 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -180,6 +180,7 @@ function! s:update_untracked() endif let needs_update = 1 + let vcs_checks = get(g:, "airline#extensions#branch#vcs_checks", ["untracked", "dirty"]) for vcs in keys(s:vcs_config) if file =~ s:vcs_config[vcs].exclude " Skip check for files that live in the exclude directory @@ -202,9 +203,13 @@ function! s:update_untracked() " invalidated again before s:update_untracked is called, then we lose the " result of the previous call, i.e. the head string is not updated. It " doesn't happen often in practice, so we let it be. - call airline#async#vcs_untracked(config, file, vcs) + if index(vcs_checks, 'untracked') > -1 + call airline#async#vcs_untracked(config, file, vcs) + endif " Check clean state of repo - call airline#async#vcs_clean(config.dirty, file, vcs) + if index(vcs_checks, 'dirty') > -1 + call airline#async#vcs_clean(config.dirty, file, vcs) + endif endfor endfunction diff --git a/doc/airline.txt b/doc/airline.txt index 590e7e3a..dd0bad92 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -514,6 +514,16 @@ characters. endif return b:perforce_client endfunction +> +* configure additional vcs checks to run + By default, vim-airline will check if the current edited file is untracked + in the repository. If so, it will append the `g:airline_symbols.notexists` + symbol to the branch name. + In addition, it will check if the repository is clean, else it will append + the `g:airline_symbols.dirty` symbol to the branch name (if the current file + is not untracked). Configure, by setting the following variable: > + + let g:airline#extensions#branch#vcs_checks = ['untracked', 'dirty'] < ------------------------------------- *airline-bufferline* vim-bufferline