-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Searching from git root #21
Comments
Currently that's not the case by default. But, you can specify the directory in the command as the last parameter like so |
I'm not a vimscript wizard but this seems to be working for me. It searches within a git repo regardless of where your :pwd is. nnoremap <leader>ag :AgsWrapper
command! -nargs=* -complete=file AgsWrapper call AgsWrapper(<q-args>, '')
" This function wraps :Ags with by providing the git root folder if inside a git repo.
" It also uses -t for ag which seraches inside .gitignore folders
function! AgsWrapper(args, cmd)
let root = systemlist('git rev-parse --show-toplevel')[0]
" If not in a git repo, search from here
if v:shell_error > 0
execute 'Ags' a:args
else
execute 'Ags' a:args l:root '-t'
endif
endfu! |
Yes I think that will work. But, I'm not sure it should be part of the plugin as it could confuse some people if they are expecting to search within a particular directory. On the other hand I could add it and put it behind an option maybe disabled by default. |
@gabesoft I don't think so either. I was mostly posting in case someone else runs into the same issue and searches the issues. I do however think it would be nice to expose an option to do this as per https://github.com/rking/ag.vim#configuration |
Thanks @dani-h that makes sense. I'll add an option similar to |
Is this feature request still open? |
@atropo You might want to look at https://github.com/airblade/vim-rooter |
@atropo yes this is still open. I haven't had a chance to work on it. But, it's on my list as soon as other stuff clears up. |
The vim-rooter plugin does the trick, thanks @danihodovic |
Is it possible to search from the root folder in a directory which has a .git folder? Similar to how CtrlP works.
The text was updated successfully, but these errors were encountered: