nvim: Add fzf-preview

This plugin provides support for Quickfix and Location list along with
previews. Also, does not do fuzzy match on file names which is useful.
Move some of the commands from fzf to fzf-preview as it provides
previews for those as well.

Using pedit for previews for quickfix list wasn't super comfortable.
Drop it, now that we have quickfix preview with fzf-preview.
This commit is contained in:
Sanchayan Maity 2020-09-22 11:43:59 +05:30
parent 78447af8df
commit c25188661b
4 changed files with 10 additions and 30 deletions

View file

@ -15,30 +15,3 @@ setlocal nospell
nnoremap <buffer> [- :colder<CR> nnoremap <buffer> [- :colder<CR>
nnoremap <buffer> ]+ :cnewer<CR> nnoremap <buffer> ]+ :cnewer<CR>
nnoremap <buffer> <Leader>g :Cfilter<SPACE> nnoremap <buffer> <Leader>g :Cfilter<SPACE>
nnoremap <buffer> o <CR><C-w>p
nnoremap <silent> <buffer> p :call <SID>preview_file()<CR>
let b:qf_isLoc = ! empty(getloclist(0))
if b:qf_isLoc == 1
nnoremap <buffer> q <CR>:lclose<CR>
else
nnoremap <buffer> q <CR>:cclose<CR>
endif
" Taken from https://github.com/voldikss/dotfiles
function! s:preview_file()
let winwidth = &columns
let cur_list = b:qf_isLoc == 1 ? getloclist('.') : getqflist()
let cur_line = getline(line('.'))
let cur_file = fnameescape(substitute(cur_line, '|.*$', '', ''))
if cur_line =~# '|\d\+'
let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '')
execute 'vertical pedit +'.cur_pos.' '.cur_file
else
execute 'vertical pedit '.cur_file
endif
wincmd P
execute 'vert resize '.(winwidth / 2)
wincmd p
endfunction

View file

@ -0,0 +1,9 @@
nnoremap <Leader>fg :FZFGGrep<CR>
nnoremap <Leader>fG :FZFGrep<CR>
nnoremap <Leader>fl :FZFBLines<CR>
nnoremap <Leader>f\ :FZFRg<CR>
nnoremap <Leader>fS :exe ':FZFRg ' . expand('<cword>')<CR>
nnoremap <Leader>ft :exe ':FZFTags ' . expand('<cword>')<CR>
nnoremap <Leader>fT :FZFTags<SPACE>
nnoremap <Leader>fq :cclose<CR>:FZFQuickFix<CR>
nnoremap <Leader>fQ :lclose<CR>:FZFLocList<CR>

View file

@ -4,9 +4,6 @@ nnoremap <Leader>/ :GFiles?<CR>
nnoremap <Leader>ff :GFiles<CR> nnoremap <Leader>ff :GFiles<CR>
nnoremap <Leader>fF :Files<CR> nnoremap <Leader>fF :Files<CR>
nnoremap <Leader>fL :Lines<CR> nnoremap <Leader>fL :Lines<CR>
nnoremap <Leader>fl :BLines<CR>
nnoremap <Leader>ft :exe ':Tags ' . expand('<cword>')<CR>
nnoremap <Leader>fT :Tags<SPACE>
nnoremap <Leader>fc :BCommits<CR> nnoremap <Leader>fc :BCommits<CR>
nnoremap <Leader>fC :Commits<CR> nnoremap <Leader>fC :Commits<CR>
nnoremap <Leader>fh :History:<CR> nnoremap <Leader>fh :History:<CR>

View file

@ -36,6 +36,7 @@ Plug 'hauleth/asyncdo.vim'
Plug 'ronakg/quickr-cscope.vim' Plug 'ronakg/quickr-cscope.vim'
Plug 'milkypostman/vim-togglelist' Plug 'milkypostman/vim-togglelist'
Plug 'yssl/QFEnter' Plug 'yssl/QFEnter'
Plug 'chengzeyi/fzf-preview.vim'
" Text Object plugins " Text Object plugins
Plug 'wellle/targets.vim' Plug 'wellle/targets.vim'
Plug 'tpope/vim-surround' Plug 'tpope/vim-surround'