Giter VIP home page Giter VIP logo

Comments (13)

ericdanan avatar ericdanan commented on August 16, 2024

Hi,

Can you post the contents of your .projectile file? Is it a git project? What happens if you call counsel-projectile-rg with a C-u prefix and manually add a path from your .projectile file in the options, is it respected then?

from counsel-projectile.

ericdanan avatar ericdanan commented on August 16, 2024

I just installed rg and tested. I can't reproduce your issue: when I exclude a file or folder in the .projectile file, it is not searched by counsel-projectile-rg. So please post more details if you still need help.

from counsel-projectile.

hisnawi avatar hisnawi commented on August 16, 2024

I am just a bit busy at work. Hopefully will post more details this weekend. Sorry for the delay.

from counsel-projectile.

ericdanan avatar ericdanan commented on August 16, 2024

Sure, no hurry.

from counsel-projectile.

hisnawi avatar hisnawi commented on August 16, 2024

Ok.
So I have these directories hierarchy:

test/
test/hrd/
test/hdr/
test/src/

and in all three directories (src/hrd/hdr) I have same file with same content test.c with "test" in it.

In test/ I also have .projectile file that contains:

+/src
+/hrd

When executing counsel-projectile-rg with the search term "test" I get all three files in the results although the one in the hdr directory should not show up because it is not mentioned in the .projectile file.

from counsel-projectile.

ericdanan avatar ericdanan commented on August 16, 2024

Thanks, I have a few questions:

  • Is test the root of your project?
  • Is there something that a priori excludes the three subdirectories hrd, hdr, and src? If not then it seems logical to me that all files show up and that your .projectile file makes no difference.
  • Does counsel-projectile-ag behave differently from counsel-projectile-rg?
  • Is this a git project?

from counsel-projectile.

hisnawi avatar hisnawi commented on August 16, 2024
  1. Yes, test is the root and it contains the .projectile file
  2. No there is nothing that excludes the three subdirectories, but based on the projectile documentation:

http://projectile.readthedocs.io/en/latest/usage/#ignoring-files

You can also ignore everything except certain subdirectories. This is useful when selecting the directories to keep is easier than selecting the directories to ignore, although you can do both. To select directories to keep, that means everything else will be ignored.

Example:

+/src/foo
+/tests/foo

Could you advice on how can I exclude everything under /test except src and hrd?

  1. ag actually behaves same as rg in this case
  2. It is not a git project, but the real project I work on is a git project and it has the same issue.

from counsel-projectile.

ericdanan avatar ericdanan commented on August 16, 2024

Thanks, I replicated your example and was able to reproduce your issue. It seems to be related to the + mechanism in the .projectile file, which I was not aware of.

Looking at the code of projectile-ag, this mechanism does not seem to supported by that command either, so I don't know how to support it in counsel-projectile-ag. I actuallly confirmed that projectile-ag exhibits the exact same behavior (to this end I had to install the ag emacs package and follow the workaround in bbatsov/projectile/issues/1162 to get rid of an error).

The only solution I found is to rewrite your .projectile file using - and ! instead of +:

-/*
!/src
!/hrd

This works as expected for me in your example, hopefully it will as well in your actual project.

Finally, in your first post you mentioned that counsel-projectile-rg was not respecting your .projectile file whereas counsel-projectile-ag was. Do you have an example where this happens? The two commands behave similarly in your example for me.

from counsel-projectile.

hisnawi avatar hisnawi commented on August 16, 2024

Thank you, yes the ! works best although there is no mention of it's use on the projectile page.

Referring to your question, actually, (even now) both ag and rg have the issue if I dont use the ! option.

from counsel-projectile.

hisnawi avatar hisnawi commented on August 16, 2024

It seems this method:

-/*
!/src
!/hdr

only works on first level directories.
Do you know how can I have rg search only some subdirectories?

for example: if I have src2 directory inside src and it has same test.c file. I want to only search that src2 directory and nothing else.

So this wont work:

-/*
!/src/src2


from counsel-projectile.

ericdanan avatar ericdanan commented on August 16, 2024

I actually saw the ! prefix documented in the link you posted, just under the + prefix. The last sentence there says:

When a path is overridden, its contents are still subject to ignore patterns. To override those files as well, specify their full path with a bang prefix.

So I tried the following. I started from your test project and created a /src/src2 directory with the same test.c file inside it. Then I expanded the .projectile file as follows:

-/*
!/src
-/src/*
!/src/src2
!/hrd

Then I called counsel-projectile-ag and searched for test. It worked, only the hrd/test.c and src/src2/test.c file appeared, not src/test.c.

I imagine it can become quite cumbersome in a real-life project, but unfortunately I don't have any better solution to offer currently. If support for the + prefix is implemented in projectile-ag in the future, I could try to mirror that in counsel-projectile-ag.

from counsel-projectile.

hisnawi avatar hisnawi commented on August 16, 2024

Sounds good. Thanks

from counsel-projectile.

ericdanan avatar ericdanan commented on August 16, 2024

You're welcome.

from counsel-projectile.

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.