[Buffers] Sort buffers by MRU order

Close #100
This commit is contained in:
Junegunn Choi
2016-03-16 00:18:23 +09:00
parent 49e88a1d75
commit 852cfa0c11
2 changed files with 13 additions and 1 deletions

View File

@@ -402,8 +402,13 @@ function! s:format_buffer(b)
return s:strip(printf("[%s] %s\t%s\t%s", s:yellow(a:b), flag, name, extra))
endfunction
function! s:sort_buffers(...)
let [b1, b2] = map(copy(a:000), 'get(g:fzf#vim#buffers, v:val, v:val)')
return b1 - b2
endfunction
function! fzf#vim#buffers(...)
let bufs = map(s:buflisted(), 's:format_buffer(v:val)')
let bufs = map(sort(s:buflisted(), 's:sort_buffers'), 's:format_buffer(v:val)')
return s:fzf(fzf#vim#wrap({
\ 'source': reverse(bufs),
\ 'sink*': s:function('s:bufopen'),