dotfiles/nvim/.config/nvim/after/plugin/fzf.vim
Sanchayan Maity ca9e0d1754 nvim: after/plugin: fzf: Move fzf configuration
Do all fzf configuration in after/plugin instead of lua/modules. While at
it, add functionality to add fzf items to the quickfix list.
2021-06-16 19:11:11 +05:30

39 lines
1.3 KiB
VimL

" 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
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-n:preview-down,Ctrl-p:preview-up"'
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 }, }
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>
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>
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)