tabline: remove static caching of s:vars

rather let them be defined whenever they are needed. They were only used
inside a single function anyhow, so it does not make sense to cache
them. In addition, having the user later change the variable won't work
as expected.
This commit is contained in:
Christian Brabandt 2018-01-04 14:09:49 +01:00
parent 2e3cdeb808
commit 72e457d8c2
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -3,10 +3,6 @@
scriptencoding utf-8 scriptencoding utf-8
let s:formatter = get(g:, 'airline#extensions#tabline#formatter', 'default')
let s:show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let s:show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1)
let s:ignore_bufadd_pat = get(g:, 'airline#extensions#tabline#ignore_bufadd_pat', '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree')
let s:taboo = get(g:, 'airline#extensions#taboo#enabled', 1) && get(g:, 'loaded_taboo', 0) let s:taboo = get(g:, 'airline#extensions#taboo#enabled', 1) && get(g:, 'loaded_taboo', 0)
if s:taboo if s:taboo
@ -52,13 +48,15 @@ function! s:update_tabline()
return return
endif endif
let match = expand('<afile>') let match = expand('<afile>')
let ignore_bufadd_pat = get(g:, 'airline#extensions#tabline#ignore_bufadd_pat',
\ '\c\vgundo|undotree|vimfiler|tagbar|nerd_tree')
if pumvisible() if pumvisible()
return return
elseif !get(g:, 'airline#extensions#tabline#enabled', 0) elseif !get(g:, 'airline#extensions#tabline#enabled', 0)
return return
" return, if buffer matches ignore pattern or is directory (netrw) " return, if buffer matches ignore pattern or is directory (netrw)
elseif empty(match) elseif empty(match)
\ || match(match, s:ignore_bufadd_pat) > -1 \ || match(match, ignore_bufadd_pat) > -1
\ || isdirectory(expand("<afile>")) \ || isdirectory(expand("<afile>"))
return return
endif endif
@ -113,7 +111,11 @@ function! airline#extensions#tabline#load_theme(palette)
endfunction endfunction
let s:current_tabcnt = -1 let s:current_tabcnt = -1
function! airline#extensions#tabline#get() function! airline#extensions#tabline#get()
let show_buffers = get(g:, 'airline#extensions#tabline#show_buffers', 1)
let show_tabs = get(g:, 'airline#extensions#tabline#show_tabs', 1)
let curtabcnt = tabpagenr('$') let curtabcnt = tabpagenr('$')
if curtabcnt != s:current_tabcnt if curtabcnt != s:current_tabcnt
let s:current_tabcnt = curtabcnt let s:current_tabcnt = curtabcnt
@ -127,7 +129,7 @@ function! airline#extensions#tabline#get()
endif endif
if s:ctrlspace if s:ctrlspace
return airline#extensions#tabline#ctrlspace#get() return airline#extensions#tabline#ctrlspace#get()
elseif s:show_buffers && curtabcnt == 1 || !s:show_tabs elseif show_buffers && curtabcnt == 1 || !show_tabs
return airline#extensions#tabline#buffers#get() return airline#extensions#tabline#buffers#get()
else else
return airline#extensions#tabline#tabs#get() return airline#extensions#tabline#tabs#get()
@ -158,7 +160,8 @@ endfunction
function! airline#extensions#tabline#get_buffer_name(nr, ...) function! airline#extensions#tabline#get_buffer_name(nr, ...)
let buffers = a:0 ? a:1 : airline#extensions#tabline#buflist#list() let buffers = a:0 ? a:1 : airline#extensions#tabline#buflist#list()
return airline#extensions#tabline#formatters#{s:formatter}#format(a:nr, buffers) let formatter = get(g:, 'airline#extensions#tabline#formatter', 'default')
return airline#extensions#tabline#formatters#{formatter}#format(a:nr, buffers)
endfunction endfunction
function! airline#extensions#tabline#new_builder() function! airline#extensions#tabline#new_builder()