mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-01-09 04:52:20 +08:00
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.
This commit is contained in:
@@ -49,14 +49,13 @@ function! s:update_tabline()
|
||||
endif
|
||||
let match = expand('<afile>')
|
||||
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("<afile>"))
|
||||
return
|
||||
endif
|
||||
|
||||
@@ -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('%'))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user