From 275a07bf4e69119c937bca73506141f5cebdf432 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 19 Aug 2018 14:15:09 +0800 Subject: [PATCH] Fix Rag and add ag shortcut --- plugin/keys.vim | 1 + vimrc | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugin/keys.vim b/plugin/keys.vim index 9d26569..b34cbad 100644 --- a/plugin/keys.vim +++ b/plugin/keys.vim @@ -155,5 +155,6 @@ nnoremap ggVG inoremap :call Select() " fzf +nnoremap ag :call fzf#vim#ag(expand(''), WithGitRoot()) nnoremap tg :call fzf#vim#tags(expand(''), {'options': '--exact --select-1 --exit-0'}) diff --git a/vimrc b/vimrc index 157b0e0..a4ef2f7 100644 --- a/vimrc +++ b/vimrc @@ -272,12 +272,14 @@ let g:ctrlp_match_func = { 'match': 'cpsm#CtrlPMatch' } " --color: Search color options command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!.git/*" --color "always" '.shellescape(), 1, 0) -function! s:with_git_root() - let root = systemlist('git rev-parse --show-toplevel')[0] - return v:shell_error ? {} : {'dir': root} +function! WithGitRoot() + let groot = systemlist('git -C ' . expand('%:p:h') . ' rev-parse --show-toplevel')[0] + return v:shell_error ? {} : {'dir': groot} endfunction -command! -bang -nargs=* Rag call fzf#vim#ag_raw(, s:with_git_root()) +command! -nargs=* Rag + \ call fzf#vim#ag(, WithGitRoot()) + " ==== conque ==== " command aliases