" ================================================== " Setup grep shortcuts and use ripgrep if available " ================================================== nmap g/ :grep! nmap g* :grep! -w nmap ga :grepadd! if executable("rg") set grepprg=rg\ --vimgrep\ --no-heading set grepformat=%f:%l:%c:%m,%f:%l:%m endif " Auto open grep quickfix window autocmd QuickFixCmdPost *grep* cwindow " Search from the git repo root, if we're in a repo, else the cwd function FuzzyFind(show_hidden) " Contains a null-byte that is stripped. let gitparent=system('git rev-parse --show-toplevel')[:-2] if a:show_hidden let $FZF_DEFAULT_COMMAND = g:fzf_default_command . ' --hidden' else let $FZF_DEFAULT_COMMAND = g:fzf_default_command endif if empty(matchstr(gitparent, '^fatal:.*')) silent execute ':FZF -m ' . gitparent else silent execute ':FZF -m .' endif endfunction nnoremap :call FuzzyFind(0) nnoremap :call FuzzyFind(1) " Use rg to perform the search, so that .gitignore files and the like are " respected let g:fzf_default_command = 'rg --files' " vim:set et sw=2: