From ca9e0d17542b82b07af39836de92aabc80060595 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Wed, 16 Jun 2021 18:42:19 +0530 Subject: [PATCH] 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. --- nvim/.config/nvim/after/plugin/fzf.vim | 38 ++++++++++++++++++++++++++ nvim/.config/nvim/lua/modules/fzf.lua | 30 -------------------- nvim/.config/nvim/lua/plugins.lua | 5 +--- 3 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 nvim/.config/nvim/after/plugin/fzf.vim delete mode 100644 nvim/.config/nvim/lua/modules/fzf.lua diff --git a/nvim/.config/nvim/after/plugin/fzf.vim b/nvim/.config/nvim/after/plugin/fzf.vim new file mode 100644 index 0000000..aa147d4 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/fzf.vim @@ -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 b :Buffers +nnoremap B :History +nnoremap / :GFiles? +nnoremap ff :GFiles +nnoremap fF :Files +nnoremap fL :Lines +nnoremap fc :BCommits +nnoremap fC :Commits +nnoremap fh :History: +nnoremap fH :History/ +nnoremap fm :Marks +nnoremap fo :Locate +nnoremap fk :Maps +nnoremap f/ :Rg +nnoremap fs :Rg + +imap (fzf-complete-word) +imap (fzf-complete-path) +imap (fzf-complete-file) +imap (fzf-complete-line) diff --git a/nvim/.config/nvim/lua/modules/fzf.lua b/nvim/.config/nvim/lua/modules/fzf.lua deleted file mode 100644 index 4d89c4a..0000000 --- a/nvim/.config/nvim/lua/modules/fzf.lua +++ /dev/null @@ -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', 'b', ':Buffers', { noremap = true }) -remap('n', 'B', ':History', { noremap = true }) -remap('n', '/', ':GFiles?', { noremap = true }) -remap('n', 'ff', ':GFiles', { noremap = true }) -remap('n', 'fF', ':Files', { noremap = true }) -remap('n', 'fL', ':Lines', { noremap = true }) -remap('n', 'fc', ':BCommits', { noremap = true }) -remap('n', 'fC', ':Commits', { noremap = true }) -remap('n', 'fh', ':History:', { noremap = true }) -remap('n', 'fH', ':History/', { noremap = true }) -remap('n', 'fm', ':Marks', { noremap = true }) -remap('n', 'fo', ':Locate', { noremap = true }) -remap('n', 'fk', ':Maps', { noremap = true }) -remap('n', 'f/', ':Rg', { noremap = true }) -remap('n', 'fs', ':Rg ', { noremap = true }) - -remap('i', '', '(fzf-complete-word)', { noremap = false }) -remap('i', '', '(fzf-complete-path)', { noremap = false }) -remap('i', '', '(fzf-complete-file)', { noremap = false }) -remap('i', '', '(fzf-complete-line)', { noremap = false }) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 505a87c..df84916 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -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'