Skip to content

Commit

Permalink
feat(vim): delete buffers in FZF buffer browser with ctrl-d
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Biggs committed Sep 22, 2015
1 parent 70fe532 commit 1b67490
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions nvimrc
Expand Up @@ -463,36 +463,37 @@
if len(a:lines) < 2 | return | endif

let cmd = get({'ctrl-x': 'sbuffer',
\ 'ctrl-v': 'vert sbuffer',
\ 'ctrl-t': 'tab sb'}, a:lines[0], 'buffer')
\ 'ctrl-v': 'vert sbuffer',
\ 'ctrl-t': 'tab sb',
\ 'ctrl-d': 'bd'}, a:lines[0], 'buffer')
let list = a:lines[1:]

let first = list[0]
execute cmd matchstr(first, '^[ 0-9]*')
endfunction

nnoremap <silent> <C-@> :call fzf#run({
\ 'source': reverse(<sid>buflist()),
\ 'sink*': function('<sid>bufopen'),
\ 'options': '+m --ansi --expect=ctrl-t,ctrl-v,ctrl-x',
\ 'down': len(<sid>buflist()) + 2
\})<CR>
\ 'source': reverse(<sid>buflist()),
\ 'sink*': function('<sid>bufopen'),
\ 'options': '+m --ansi --expect=ctrl-t,ctrl-v,ctrl-x,ctrl-d',
\ 'down': len(<sid>buflist()) + 2
\})<CR>

" Narrow Ag results within Vim
" @see https://github.com/junegunn/fzf/wiki/Examples-(vim)#narrow-ag-results-within-vim
function! s:ag_to_qf(line)
let parts = split(a:line, ':')
return {'filename': parts[0], 'lnum': parts[1], 'col': parts[2],
\ 'text': join(parts[3:], ':')}
\ 'text': join(parts[3:], ':')}
endfunction

function! s:ag_handler(lines)
if len(a:lines) < 2 | return | endif

let cmd = get({'ctrl-x': 'split',
\ 'ctrl-v': 'vertical split',
\ 'ctrl-t': 'tabe'}, a:lines[0], 'e')
\ 'ctrl-v': 'vertical split',
\ 'ctrl-t': 'tabe'}, a:lines[0], 'e')
let list = map(a:lines[1:], 's:ag_to_qf(v:val)')

let first = list[0]
Expand Down

0 comments on commit 1b67490

Please sign in to comment.