+ function! s:ProjectRg(query) abort
+ let dir = expand('%:p:h')
+ let dir = isdirectory(dir) ? dir : getcwd()
+ let root = systemlist('git -C ' . shellescape(dir) . ' rev-parse --show-toplevel 2>/dev/null')
+ if v:shell_error || empty(root)
+ echoerr 'Not in a Git repository'
+ return
+ endif
+ call fzf#vim#grep2(
+ \ 'rg --hidden --glob "!.git" --column --line-number --no-heading --color=always --smart-case -- ',
+ \ a:query, fzf#vim#with_preview({'dir': root[0]}))
+ endfunction
+
+ command! -nargs=* ProjectRg call <SID>ProjectRg(<q-args>)