mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 12:44:24 +08:00
[fzf#vim#buffers] Allow users to pass a custom list of buffer numbers
Introducing a global configuration variable may seem easier but this
method is more flexible in that it allows you to define multiple
variations of the command without having to repeatedly setting and
unsetting the variable.
function! MyBuffers()
return filter(range(1, bufnr('$')), 'buflisted(v:val) && getbufvar(v:val, "&filetype") != "qf"')
endfunction
command! -bar -bang Buffers call fzf#vim#buffers(MyBuffers(), fzf#vim#with_preview({'placeholder': '{1}'}), <bang>0)
Close #831
Close #393
This commit is contained in:
@@ -807,10 +807,16 @@ function! fzf#vim#_buflisted_sorted()
|
||||
return sort(s:buflisted(), 's:sort_buffers')
|
||||
endfunction
|
||||
|
||||
" [query (string)], [bufnrs (list)], [spec (dict)], [fullscreen (bool)]
|
||||
function! fzf#vim#buffers(...)
|
||||
let [query, args] = (a:0 && type(a:1) == type('')) ?
|
||||
\ [a:1, a:000[1:]] : ['', a:000]
|
||||
let sorted = fzf#vim#_buflisted_sorted()
|
||||
if len(args) && type(args[0]) == s:TYPE.list
|
||||
let [buffers; args] = args
|
||||
else
|
||||
let buffers = s:buflisted()
|
||||
endif
|
||||
let sorted = sort(buffers, 's:sort_buffers')
|
||||
let header_lines = '--header-lines=' . (bufnr('') == get(sorted, 0, 0) ? 1 : 0)
|
||||
let tabstop = len(max(sorted)) >= 4 ? 9 : 8
|
||||
return s:fzf('buffers', {
|
||||
|
||||
Reference in New Issue
Block a user