mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 12:44:24 +08:00
Expose some buffer related functions (#1044)
This commit is contained in:
@@ -489,7 +489,7 @@ endfunction
|
|||||||
function! fzf#vim#_recent_files()
|
function! fzf#vim#_recent_files()
|
||||||
return fzf#vim#_uniq(map(
|
return fzf#vim#_uniq(map(
|
||||||
\ filter([expand('%')], 'len(v:val)')
|
\ 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'))"),
|
\ + filter(copy(v:oldfiles), "filereadable(fnamemodify(v:val, ':p'))"),
|
||||||
\ 'fnamemodify(v:val, ":~:.")'))
|
\ 'fnamemodify(v:val, ":~:.")'))
|
||||||
endfunction
|
endfunction
|
||||||
@@ -638,7 +638,7 @@ function! s:bufopen(lines)
|
|||||||
execute 'buffer' b
|
execute 'buffer' b
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:format_buffer(b)
|
function! fzf#vim#_format_buffer(b)
|
||||||
let name = bufname(a:b)
|
let name = bufname(a:b)
|
||||||
let line = exists('*getbufinfo') ? getbufinfo(a:b)[0]['lnum'] : 0
|
let line = exists('*getbufinfo') ? getbufinfo(a:b)[0]['lnum'] : 0
|
||||||
let name = empty(name) ? '[No Name]' : fnamemodify(name, ":p:~:.")
|
let name = empty(name) ? '[No Name]' : fnamemodify(name, ":p:~:.")
|
||||||
@@ -657,7 +657,7 @@ function! s:sort_buffers(...)
|
|||||||
return b1 < b2 ? 1 : -1
|
return b1 < b2 ? 1 : -1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:buflisted_sorted()
|
function! fzf#vim#_buflisted_sorted()
|
||||||
return sort(s:buflisted(), 's:sort_buffers')
|
return sort(s:buflisted(), 's:sort_buffers')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -665,7 +665,7 @@ function! fzf#vim#buffers(...)
|
|||||||
let [query, args] = (a:0 && type(a:1) == type('')) ?
|
let [query, args] = (a:0 && type(a:1) == type('')) ?
|
||||||
\ [a:1, a:000[1:]] : ['', a:000]
|
\ [a:1, a:000[1:]] : ['', a:000]
|
||||||
return s:fzf('buffers', {
|
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'),
|
\ '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]
|
\ 'options': ['+m', '-x', '--tiebreak=index', '--header-lines=1', '--ansi', '-d', '\t', '--with-nth', '2..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query]
|
||||||
\}, args)
|
\}, args)
|
||||||
|
|||||||
Reference in New Issue
Block a user