Giter Club home page Giter Club logo

Comments (10)

atropo avatar atropo commented on July 20, 2024 1

The vim-rooter plugin does the trick, thanks @danihodovic

from vim-ags.

gabesoft avatar gabesoft commented on July 20, 2024

Currently that's not the case by default. But, you can specify the directory in the command as the last parameter like so :Ags search-term /my/root/dir. You would have to enter the full path, for example ~/my/dir would not work.

from vim-ags.

danihodovic avatar danihodovic commented on July 20, 2024

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!

from vim-ags.

gabesoft avatar gabesoft commented on July 20, 2024

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.

from vim-ags.

danihodovic avatar danihodovic commented on July 20, 2024

@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

from vim-ags.

gabesoft avatar gabesoft commented on July 20, 2024

Thanks @dani-h that makes sense. I'll add an option similar to ag.vim when I get a chance.

from vim-ags.

danihodovic avatar danihodovic commented on July 20, 2024

@gabesoft 👍

from vim-ags.

atropo avatar atropo commented on July 20, 2024

Is this feature request still open?
It would be very useful to have this feature so it's a +1 for me.

from vim-ags.

danihodovic avatar danihodovic commented on July 20, 2024

@atropo You might want to look at https://github.com/airblade/vim-rooter

from vim-ags.

gabesoft avatar gabesoft commented on July 20, 2024

@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.

from vim-ags.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.