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.
This commit is contained in:
Sanchayan Maity 2021-06-16 18:42:19 +05:30
parent aee5337f55
commit ca9e0d1754
3 changed files with 39 additions and 34 deletions

View File

@ -0,0 +1,38 @@
" 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)

View File

@ -1,30 +0,0 @@
local remap = vim.api.nvim_set_keymap
vim.env.FZF_DEFAULT_OPTS = "--layout=reverse --bind \"Ctrl-n:preview-down,Ctrl-p:preview-up\""
vim.g.fzf_layout = {
window = {
width = 0.8,
height = 0.8
},
}
remap('n', '<Leader>b', ':Buffers<CR>', { noremap = true })
remap('n', '<Leader>B', ':History<CR>', { noremap = true })
remap('n', '<Leader>/', ':GFiles?<CR>', { noremap = true })
remap('n', '<Leader>ff', ':GFiles<CR>', { noremap = true })
remap('n', '<Leader>fF', ':Files<CR>', { noremap = true })
remap('n', '<Leader>fL', ':Lines<CR>', { noremap = true })
remap('n', '<Leader>fc', ':BCommits<CR>', { noremap = true })
remap('n', '<Leader>fC', ':Commits<CR>', { noremap = true })
remap('n', '<Leader>fh', ':History:<CR>', { noremap = true })
remap('n', '<Leader>fH', ':History/<CR>', { noremap = true })
remap('n', '<Leader>fm', ':Marks<CR>', { noremap = true })
remap('n', '<Leader>fo', ':Locate<CR>', { noremap = true })
remap('n', '<Leader>fk', ':Maps<CR>', { noremap = true })
remap('n', '<Leader>f/', ':Rg<CR>', { noremap = true })
remap('n', '<Leader>fs', ':<C-u>Rg <C-r><C-w><CR>', { noremap = true })
remap('i', '<C-x><C-w>', '<Plug>(fzf-complete-word)', { noremap = false })
remap('i', '<C-x><C-p>', '<Plug>(fzf-complete-path)', { noremap = false })
remap('i', '<C-x><C-f>', '<Plug>(fzf-complete-file)', { noremap = false })
remap('i', '<C-x><C-l>', '<Plug>(fzf-complete-line)', { noremap = false })

View File

@ -14,10 +14,7 @@ local init = function ()
'junegunn/fzf',
run = './install --bin'
}
use {
'junegunn/fzf.vim',
config = "require('modules.fzf')"
}
use 'junegunn/fzf.vim'
use 'wincent/ferret'
use 'lambdalisue/reword.vim'
use 'bronson/vim-visual-star-search'