2016-01-15 10:38:38 +08:00
|
|
|
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
2015-02-19 07:48:47 +08:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
let s:excludes = get(g:, 'airline#extensions#tabline#excludes', [])
|
2015-06-29 04:34:37 +08:00
|
|
|
let s:exclude_preview = get(g:, 'airline#extensions#tabline#exclude_preview', 1)
|
2015-02-19 07:48:47 +08:00
|
|
|
|
|
|
|
function! airline#extensions#tabline#buflist#invalidate()
|
|
|
|
unlet! s:current_buffer_list
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#extensions#tabline#buflist#list()
|
|
|
|
if exists('s:current_buffer_list')
|
|
|
|
return s:current_buffer_list
|
|
|
|
endif
|
|
|
|
|
|
|
|
let buffers = []
|
2016-02-09 03:34:27 +08:00
|
|
|
" If this is too slow, we can switch to a different algorithm.
|
|
|
|
" Basically branch 535 already does it, but since it relies on
|
|
|
|
" BufAdd autocommand, I'd like to avoid this if possible.
|
2015-02-19 07:48:47 +08:00
|
|
|
for nr in range(1, bufnr('$'))
|
2016-02-09 03:34:27 +08:00
|
|
|
if buflisted(nr)
|
|
|
|
" Do not add to the bufferlist, if either
|
|
|
|
" 1) buffername matches exclude pattern
|
|
|
|
" 2) buffer is a quickfix buffer
|
|
|
|
" 3) exclude preview windows (if 'bufhidden' == wipe
|
|
|
|
" and 'buftype' == nofile
|
|
|
|
if (!empty(s:excludes) && match(bufname(nr), join(s:excludes, '\|')) > -1) ||
|
|
|
|
\ (getbufvar(nr, 'current_syntax') == 'qf') ||
|
|
|
|
\ (s:exclude_preview && getbufvar(nr, '&bufhidden') == 'wipe'
|
|
|
|
\ && getbufvar(nr, '&buftype') == 'nofile')
|
|
|
|
continue
|
2015-02-19 07:48:47 +08:00
|
|
|
endif
|
2016-02-09 03:34:27 +08:00
|
|
|
call add(buffers, nr)
|
2015-02-19 07:48:47 +08:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let s:current_buffer_list = buffers
|
|
|
|
return buffers
|
|
|
|
endfunction
|
|
|
|
|