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 6, 2020
1 parent 2c07630 commit a5ffba5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions autoload/fzf/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ endfunction
function! s:all_files()
return fzf#vim#_uniq(map(
\ filter([expand('%')], 'len(v:val)')
\ + filter(map(s:buflisted_sorted(), 'bufname(v:val)'), 'len(v:val)')
\ + filter(map(fzf#vim#_buflisted_sorted(), 'bufname(v:val)'), 'len(v:val)')
\ + filter(copy(v:oldfiles), "filereadable(fnamemodify(v:val, ':p'))"),
\ 'fnamemodify(v:val, ":~:.")'))
endfunction
Expand Down 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 a5ffba5

Please sign in to comment.