From b84e13f1d7354c52fee2b0f2ebb4da76634f0a01 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Fri, 11 May 2018 22:22:46 +0200 Subject: [PATCH] Blacklist startify for [noperm] Startify unfortunately does not set the buftype option, so the `[noperm]` would be shown, since the buffer is not really a file. (see mhinz/vim-startify#324) So allow to blacklist startify from this setting. To do so, the logic from the tabline extension was refactored out into a separate function that returns true, if the buffer matches `g:airline#extensions#tabline#ignore_bufadd_pat` and that function is then reused for the readonly() function as well. --- autoload/airline/extensions/tabline.vim | 5 ++--- autoload/airline/parts.vim | 2 +- autoload/airline/util.vim | 7 +++++++ doc/airline.txt | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/autoload/airline/extensions/tabline.vim b/autoload/airline/extensions/tabline.vim index 52cf19b..5f1d794 100644 --- a/autoload/airline/extensions/tabline.vim +++ b/autoload/airline/extensions/tabline.vim @@ -49,14 +49,13 @@ function! s:update_tabline() endif let match = expand('') let ignore_bufadd_pat = get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', - \ '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree') + \ '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree|startify') if pumvisible() return elseif !get(g:, 'airline#extensions#tabline#enabled', 0) return " return, if buffer matches ignore pattern or is directory (netrw) - elseif empty(match) - \ || match(match, ignore_bufadd_pat) > -1 + elseif empty(match) || airline#util#ignore_buf(match) \ || isdirectory(expand("")) return endif diff --git a/autoload/airline/parts.vim b/autoload/airline/parts.vim index e6146ce..94d5eff 100644 --- a/autoload/airline/parts.vim +++ b/autoload/airline/parts.vim @@ -88,7 +88,7 @@ endfunction function! airline#parts#readonly() " only consider regular buffers (e.g. ones that represent actual files, " but not special ones like e.g. NERDTree) - if !empty(&buftype) + if !empty(&buftype) || airline#util#ignore_buf(bufname('%')) return '' endif if &readonly && !filereadable(bufname('%')) diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index 23c44c4..b8f39b0 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -96,3 +96,10 @@ function! airline#util#strchars(str) return strlen(substitute(a:str, '.', 'a', 'g')) endif endfunction + +function! airline#util#ignore_buf(name) + let pat = '\c\v'. get(g:, 'airline#ignore_bufadd_pat', ''). + \ get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', + \ 'gundo|undotree|vimfiler|tagbar|nerd_tree|startify') + return match(a:name, pat) > -1 +endfunction diff --git a/doc/airline.txt b/doc/airline.txt index da9feb1..2cd8af2 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -324,6 +324,12 @@ section. let g:airline_section_b = '%-0.10{getcwd()}' let g:airline_section_c = '%t' < + |airline#ignore_bufadd_pat| +Determines a pattern to ignore a buffer name for various things (e.g. the +tabline extension) or the read-only check. Default is +`g:airline#extensions#tabline#ignore_bufadd_pat` (see below) or +`'gundo|undotree|vimfiler|tagbar|nerd_tree|startify'` if it is unset. + ============================================================================== EXTENSIONS *airline-extensions*