2019-03-25 07:27:10 -04:00
|
|
|
" MIT License. Copyright (c) 2013-2019 Bailey Ling et al.
|
2015-02-18 18:48:47 -05:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2016-09-23 20:16:30 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2015-02-18 18:48:47 -05:00
|
|
|
function! airline#extensions#tabline#buflist#invalidate()
|
|
|
|
unlet! s:current_buffer_list
|
|
|
|
endfunction
|
|
|
|
|
2018-07-13 16:29:34 -04:00
|
|
|
function! airline#extensions#tabline#buflist#clean()
|
|
|
|
call airline#extensions#tabline#buflist#invalidate()
|
|
|
|
call airline#extensions#tabline#buffers#invalidate()
|
|
|
|
endfunction
|
|
|
|
|
2018-03-06 20:21:52 -05:00
|
|
|
" paths in excludes list
|
|
|
|
function! s:ExcludePaths(nr, exclude_paths)
|
2019-02-02 16:39:07 -05:00
|
|
|
let bname = bufname(a:nr)
|
|
|
|
if empty(bname)
|
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
let bpath = fnamemodify(bname, ":p")
|
2018-03-06 20:21:52 -05:00
|
|
|
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
|
|
|
|
|
2015-02-18 18:48:47 -05:00
|
|
|
function! airline#extensions#tabline#buflist#list()
|
|
|
|
if exists('s:current_buffer_list')
|
|
|
|
return s:current_buffer_list
|
|
|
|
endif
|
|
|
|
|
2018-03-06 20:21:52 -05:00
|
|
|
let exclude_buffers = get(g:, 'airline#extensions#tabline#exclude_buffers', [])
|
|
|
|
let exclude_paths = get(g:, 'airline#extensions#tabline#excludes', [])
|
|
|
|
let exclude_preview = get(g:, 'airline#extensions#tabline#exclude_preview', 1)
|
2016-12-03 23:40:15 -05:00
|
|
|
|
2016-02-16 15:16:55 -05:00
|
|
|
let list = (exists('g:did_bufmru') && g:did_bufmru) ? BufMRUList() : range(1, bufnr("$"))
|
|
|
|
|
2015-02-18 18:48:47 -05:00
|
|
|
let buffers = []
|
2016-02-08 14:34:27 -05: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-16 15:16:55 -05:00
|
|
|
for nr in list
|
2016-02-08 14:34:27 -05:00
|
|
|
if buflisted(nr)
|
|
|
|
" Do not add to the bufferlist, if either
|
2018-03-03 17:39:14 -05: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
|
2018-09-20 04:26:32 -04:00
|
|
|
" 5) ignore buffers matching airline#extensions#tabline#ignore_bufadd_pat
|
2018-03-03 17:39:14 -05:00
|
|
|
|
|
|
|
" check buffer numbers first
|
2018-03-06 20:21:52 -05:00
|
|
|
if index(exclude_buffers, nr) >= 0
|
2018-03-03 17:39:14 -05:00
|
|
|
continue
|
2018-09-20 04:26:32 -04:00
|
|
|
" check paths second
|
2018-03-06 20:21:52 -05:00
|
|
|
elseif !empty(exclude_paths) && s:ExcludePaths(nr, exclude_paths)
|
2018-03-03 17:39:14 -05:00
|
|
|
continue
|
2018-09-20 04:26:32 -04:00
|
|
|
" ignore buffers matching airline#extensions#tabline#ignore_bufadd_pat
|
|
|
|
elseif airline#util#ignore_buf(bufname(nr))
|
|
|
|
continue
|
|
|
|
" check other types last
|
2018-03-06 20:21:52 -05:00
|
|
|
elseif s:ExcludeOther(nr, exclude_preview)
|
2016-02-08 14:34:27 -05:00
|
|
|
continue
|
2015-02-18 18:48:47 -05:00
|
|
|
endif
|
2018-03-03 17:39:14 -05:00
|
|
|
|
2016-02-08 14:34:27 -05:00
|
|
|
call add(buffers, nr)
|
2015-02-18 18:48:47 -05:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let s:current_buffer_list = buffers
|
|
|
|
return buffers
|
|
|
|
endfunction
|