diff --git a/README.md b/README.md index 8d16b56..6fc2d18 100644 --- a/README.md +++ b/README.md @@ -217,16 +217,16 @@ endfunction Each command in fzf.vim is backed by a Vim function. You can override a command or define a variation of it by calling its corresponding function. -| Command | Vim function | -| --- | --- | -| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` | -| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` | -| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` | -| `Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])` | -| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` | -| `Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])` | -| `RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])` | -| ... | ... | +| Command | Vim function | +| --- | --- | +| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` | +| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` | +| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` | +| `Buffers` | `fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])` | +| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` | +| `Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])` | +| `RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])` | +| ... | ... | (We can see that the last two optional arguments of each function are identical. They are directly passed to `fzf#wrap` function. If you haven't diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 02fc3ae..e57b7fa 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -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', { diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index 71b2679..d2179d2 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -1,4 +1,4 @@ -fzf-vim.txt fzf-vim Last change: September 14 2023 +fzf-vim.txt fzf-vim Last change: October 14 2023 FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* ============================================================================== @@ -291,18 +291,18 @@ Vim functions~ Each command in fzf.vim is backed by a Vim function. You can override a command or define a variation of it by calling its corresponding function. - ----------+----------------------------------------------------------------------- - Command | Vim function ~ - ----------+----------------------------------------------------------------------- + ----------+--------------------------------------------------------------------------------- + Command | Vim function ~ + ----------+--------------------------------------------------------------------------------- `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` - `Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])` + `Buffers` | `fzf#vim#buffers([query string], [bufnrs list], [spec dict], [fullscreen bool])` `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` `Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])` `RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])` ... | ... - ----------+----------------------------------------------------------------------- + ----------+--------------------------------------------------------------------------------- (We can see that the last two optional arguments of each function are identical. They are directly passed to `fzf#wrap` function. If you haven't