Skip to content

Commit

Permalink
Expose some buffer related functions
Browse files Browse the repository at this point in the history
This enables to customize the :Buffers commands extensively.
  • Loading branch information
doronbehar committed Jun 4, 2020
1 parent 2c07630 commit 3064be3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autoload/fzf/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function! s:bufopen(lines)
execute 'buffer' b
endfunction

function! s:format_buffer(b)
function! fzf#vim#_format_buffer(b)
let name = bufname(a:b)
let line = exists('*getbufinfo') ? getbufinfo(a:b)[0]['lnum'] : 0
let name = empty(name) ? '[No Name]' : fnamemodify(name, ":p:~:.")
Expand All @@ -640,15 +640,15 @@ function! s:sort_buffers(...)
return b1 < b2 ? 1 : -1
endfunction

function! s:buflisted_sorted()
function! fzf#vim#_buflisted_sorted()
return sort(s:buflisted(), 's:sort_buffers')
endfunction

function! fzf#vim#buffers(...)
let [query, args] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
return s:fzf('buffers', {
\ 'source': map(s:buflisted_sorted(), 's:format_buffer(v:val)'),
\ 'source': map(fzf#vim#_buflisted_sorted(), 'fzf#vim#_format_buffer(v:val)'),
\ 'sink*': s:function('s:bufopen'),
\ 'options': ['+m', '-x', '--tiebreak=index', '--header-lines=1', '--ansi', '-d', '\t', '--with-nth', '2..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query]
\}, args)
Expand Down

0 comments on commit 3064be3

Please sign in to comment.