From ebd287f7895cb76c5d5aed142d8a635335b233e1 Mon Sep 17 00:00:00 2001 From: pittcat Date: Tue, 3 Apr 2018 21:18:37 +0800 Subject: [PATCH] improve fzf (#282) * improve fzf and fix ctrl arrows conflix in tmux * improve fzf * improve fzf * improve fzf --- core/autoload/spacevim/plug/fzf.vim | 28 ++++++++++++++++++++++++++++ layers/+tools/fzf/config.vim | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/core/autoload/spacevim/plug/fzf.vim b/core/autoload/spacevim/plug/fzf.vim index 087ed422..36e422b7 100644 --- a/core/autoload/spacevim/plug/fzf.vim +++ b/core/autoload/spacevim/plug/fzf.vim @@ -190,6 +190,34 @@ function! s:align_lists(lists) return a:lists endfunction +command! -bang -nargs=* Ag + \ call fzf#vim#ag(, + \ 0 ? fzf#vim#with_preview('up:80%') + \ : fzf#vim#with_preview('right:80%:hidden', '?'), + \ 0) + +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always '.shellescape(), 1, + \ 0 ? fzf#vim#with_preview('up:70%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ 0) + +" Likewise, Files command with preview window +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview(), 0) +" } + +function! spacevim#plug#fzf#Session() + call fzf#run({ + \ 'source': 'ls -1 ~/.vim/session', + \ 'sink': 'SLoad', + \ 'options': '+m --prompt="Sessions> "', + \ 'down': '40%' + \}) +endfunction + + " ------------------------------------------------------------------ " Configuration Files " ------------------------------------------------------------------ diff --git a/layers/+tools/fzf/config.vim b/layers/+tools/fzf/config.vim index 916e2e0f..c5e06c38 100644 --- a/layers/+tools/fzf/config.vim +++ b/layers/+tools/fzf/config.vim @@ -15,7 +15,7 @@ else xmap ? (fzf-maps-x) omap ? (fzf-maps-o) - nnoremap ag :Ag + nnoremap ag :Ag! nnoremap bb :Buffers nnoremap b? :Buffers @@ -23,5 +23,7 @@ else nnoremap f? :Files nnoremap ff :Files ~ + nnoremap sf :call spacevim#plug#fzf#Session() + nnoremap rg :Rg! " } endif