Made s:variables local

Moved small functions out of main function
This commit is contained in:
mg979 2018-03-07 02:21:52 +01:00
parent 63111e9810
commit 26aa528c42

View File

@ -7,33 +7,33 @@ function! airline#extensions#tabline#buflist#invalidate()
unlet! s:current_buffer_list unlet! s:current_buffer_list
endfunction endfunction
" paths in excludes list
function! s:ExcludePaths(nr, exclude_paths)
let bpath = fnamemodify(bufname(a:nr), ":p")
for f in a:exclude_paths
if bpath =~# f | return 1 | endif
endfor
endfunction
" other types to exclude
function! s:ExcludeOther(nr, exclude_preview)
if (getbufvar(a:nr, 'current_syntax') == 'qf') ||
\ (a:exclude_preview && getbufvar(a:nr, '&bufhidden') == 'wipe'
\ && getbufvar(a:nr, '&buftype') == 'nofile')
return 1 | endif
endfunction
function! airline#extensions#tabline#buflist#list() function! airline#extensions#tabline#buflist#list()
if exists('s:current_buffer_list') if exists('s:current_buffer_list')
return s:current_buffer_list return s:current_buffer_list
endif endif
let s:exclude_buffers = get(g:, 'airline#extensions#tabline#exclude_buffers', []) let exclude_buffers = get(g:, 'airline#extensions#tabline#exclude_buffers', [])
let s:exclude_paths = get(g:, 'airline#extensions#tabline#excludes', []) let exclude_paths = get(g:, 'airline#extensions#tabline#excludes', [])
let s:exclude_preview = get(g:, 'airline#extensions#tabline#exclude_preview', 1) let exclude_preview = get(g:, 'airline#extensions#tabline#exclude_preview', 1)
let list = (exists('g:did_bufmru') && g:did_bufmru) ? BufMRUList() : range(1, bufnr("$")) let list = (exists('g:did_bufmru') && g:did_bufmru) ? BufMRUList() : range(1, bufnr("$"))
" paths in excludes list
fun! s:ExcludePaths(nr)
let bpath = fnamemodify(bufname(a:nr), ":p")
for f in s:exclude_paths
if bpath =~# f | return 1 | endif
endfor
endfun
" other types to exclude
fun! s:ExcludeOther(nr)
if (getbufvar(a:nr, 'current_syntax') == 'qf') ||
\ (s:exclude_preview && getbufvar(a:nr, '&bufhidden') == 'wipe'
\ && getbufvar(a:nr, '&buftype') == 'nofile')
return 1 | endif
endfun
let buffers = [] let buffers = []
" If this is too slow, we can switch to a different algorithm. " If this is too slow, we can switch to a different algorithm.
" Basically branch 535 already does it, but since it relies on " Basically branch 535 already does it, but since it relies on
@ -49,13 +49,13 @@ function! airline#extensions#tabline#buflist#list()
" 'buftype' == nofile " 'buftype' == nofile
" check buffer numbers first " check buffer numbers first
if index(s:exclude_buffers, nr) >= 0 if index(exclude_buffers, nr) >= 0
continue continue
" check paths second " check paths second
elseif !empty(s:exclude_paths) && s:ExcludePaths(nr) elseif !empty(exclude_paths) && s:ExcludePaths(nr, exclude_paths)
continue continue
" check other types last " check other types last
elseif s:ExcludeOther(nr) elseif s:ExcludeOther(nr, exclude_preview)
continue continue
endif endif