2018-01-05 17:37:59 +08:00
|
|
|
" MIT License. Copyright (c) 2013-2018 Bailey Ling et al.
|
2015-02-19 07:48:47 +08:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2016-09-24 08:16:30 +08:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
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
|
|
|
|
|
2018-03-04 06:39:14 +08:00
|
|
|
let s:exclude_buffers = get(g:, 'airline#extensions#tabline#exclude_buffers', [])
|
2018-03-04 06:53:10 +08:00
|
|
|
let s:exclude_paths = get(g:, 'airline#extensions#tabline#excludes', [])
|
2018-03-04 06:39:14 +08:00
|
|
|
let s:exclude_preview = get(g:, 'airline#extensions#tabline#exclude_preview', 1)
|
2016-12-04 12:40:15 +08:00
|
|
|
|
2016-02-17 04:16:55 +08:00
|
|
|
let list = (exists('g:did_bufmru') && g:did_bufmru) ? BufMRUList() : range(1, bufnr("$"))
|
|
|
|
|
2018-03-04 06:39:14 +08:00
|
|
|
" paths in excludes list
|
|
|
|
fun! s:ExcludePaths(nr)
|
|
|
|
let bpath = fnamemodify(bufname(a:nr), ":p")
|
|
|
|
for f in s:exclude_paths
|
2018-03-04 07:31:25 +08:00
|
|
|
if bpath =~# f | return 1 | endif
|
2018-03-04 06:39:14 +08:00
|
|
|
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
|
|
|
|
|
2015-02-19 07:48:47 +08:00
|
|
|
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.
|
2016-02-17 04:16:55 +08:00
|
|
|
for nr in list
|
2016-02-09 03:34:27 +08:00
|
|
|
if buflisted(nr)
|
|
|
|
" Do not add to the bufferlist, if either
|
2018-03-04 06:39:14 +08:00
|
|
|
" 1) bufnr is exclude_buffers list
|
|
|
|
" 2) buffername matches one of exclude_paths patterns
|
|
|
|
" 3) buffer is a quickfix buffer
|
|
|
|
" 4) when excluding preview windows:
|
|
|
|
" 'bufhidden' == wipe
|
|
|
|
" 'buftype' == nofile
|
|
|
|
|
|
|
|
" check buffer numbers first
|
|
|
|
if index(s:exclude_buffers, nr) >= 0
|
|
|
|
continue
|
|
|
|
" check paths second
|
|
|
|
elseif !empty(s:exclude_paths) && s:ExcludePaths(nr)
|
|
|
|
continue
|
|
|
|
" check other types last
|
|
|
|
elseif s:ExcludeOther(nr)
|
2016-02-09 03:34:27 +08:00
|
|
|
continue
|
2015-02-19 07:48:47 +08:00
|
|
|
endif
|
2018-03-04 06:39:14 +08:00
|
|
|
|
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
|