nvim: after/plugin/fzf: Add command for wiping out all selected buffers

This commit is contained in:
Sanchayan Maity 2021-10-17 17:29:23 +05:30
parent 4cc5fb67c9
commit 8e1f6a8834

View file

@ -6,6 +6,24 @@ function! s:build_quickfix_list(lines)
cc
endfunction
" https://github.com/junegunn/fzf.vim/pull/733
function! s:list_buffers()
redir => list
silent ls
redir END
return split(list, "\n")
endfunction
function! s:delete_buffers(lines)
execute 'bwipeout' join(map(a:lines, {_, line -> split(line)[0]}))
endfunction
command! BD call fzf#run(fzf#wrap({
\ 'source': s:list_buffers(),
\ 'sink*': { lines -> s:delete_buffers(lines) },
\ 'options': '--multi --reverse --bind ctrl-a:select-all+accept'
\ }))
let g:fzf_action = {
\ 'ctrl-q': function('s:build_quickfix_list'),
\ 'ctrl-t': 'tab split',
@ -31,6 +49,7 @@ nnoremap <Leader>fo :Locate<CR>
nnoremap <Leader>fk :Maps<CR>
nnoremap <Leader>f/ :Rg<CR>
nnoremap <Leader>fs :<C-u>Rg <C-r><C-w><CR>
nnoremap <Leader>fw :BD<CR>
imap <C-x><C-w> <Plug>(fzf-complete-word)
imap <C-x><C-p> <Plug>(fzf-complete-path)