2022-03-24 04:45:33 +01:00
" See https://github.com/junegunn/fzf/blob/master/README-VIM.md
" An action can be a reference to a function that processes selected lines
function ! s :build_quickfix_list ( lines )
call setqflist ( [], ' ' , { 'title' : 'FZF Selected' , 'items' : map ( copy ( a :lines ) , '{ "filename": v:val }' ) })
copen
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' ,
\ 'ctrl-x' : 'split' ,
\ 'ctrl-v' : 'vsplit' ,
\ }
let $FZF_DEFAULT_OPTS = '--layout=reverse --bind "Ctrl-d:half-page-down,Ctrl-u:half-page-up,Ctrl-n:preview-down,Ctrl-p:preview-up,Ctrl-f:preview-page-down,Ctrl-b:preview-page-up,ctrl-a:select-all+accept"'
2022-03-24 05:06:04 +01:00
if exists ( '$TMUX' )
let g :fzf_layout = { 'tmux' : '-p90%,90%' }
else
let g :fzf_layout = { 'window' : { 'width' : 0 .9 , 'height' : 0 .9 }, }
endif
2022-03-24 04:45:33 +01:00
nnoremap < Leader > b :Buffers < CR >
nnoremap < Leader > B :History < CR >
nnoremap < Leader > / :GFiles ?< CR >
nnoremap < Leader > ff :GFiles < CR >
nnoremap < Leader > fF :Files < CR >
nnoremap < Leader > fL :Lines < CR >
nnoremap < Leader > fc :BCommits < CR >
2022-03-27 15:53:11 +02:00
xnoremap < Leader > fc :BCommits < CR >
2022-03-24 04:45:33 +01:00
nnoremap < Leader > fC :Commits < CR >
nnoremap < Leader > fh :History :< CR >
nnoremap < Leader > fH :History /< CR >
nnoremap < Leader > fm :Marks < CR >
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 >
xnoremap < Leader > fs "zy<Esc>:Rg <C-R>z<CR>
nnoremap < Leader > fw :BD < CR >
imap < C - x > < C - w > < Plug > ( fzf - complete - word )
imap < C - x > < C - p > < Plug > ( fzf - complete - path )
imap < C - x > < C - f > < Plug > ( fzf - complete - file )
imap < C - x > < C - l > < Plug > ( fzf - complete - line )