Comments (13)
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.
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.
I am just a bit busy at work. Hopefully will post more details this weekend. Sorry for the delay.
from counsel-projectile.
Sure, no hurry.
from counsel-projectile.
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.
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
, andsrc
? 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 fromcounsel-projectile-rg
? - Is this a git project?
from counsel-projectile.
- Yes, test is the root and it contains the .projectile file
- 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?
- ag actually behaves same as rg in this case
- 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.
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.
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.
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.
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.
Sounds good. Thanks
from counsel-projectile.
You're welcome.
from counsel-projectile.
Related Issues (20)
- Sorting files by relevance to the query HOT 2
- FR: Add command "counsel-projectile-recent-file" HOT 5
- unable to modify default action HOT 2
- Switching project now makes current buffer a blank *counsel-projectile* buffer HOT 1
- Set a default landing file per project HOT 4
- counsel-projectile cannot work out with other executable program, such as rg、ag、fzf etc. HOT 3
- counsel-projectile-switch-project ignores c-u -- does not refresh cache HOT 1
- f6
- Preselect next buffer HOT 1
- Projectile ag and grep - abbreviate-file-name: Wrong type argument: stringp, nil HOT 1
- counsel-projectile-preview-buffers t and unable to open a file HOT 1
- counsel-projectile-find-file extremely sluggish in larger repositories. HOT 6
- Issue with `counsel-projectile-rg` on melpa-stable HOT 1
- Error in post-command-hook (ivy--queue-exhibit): (void-variable ivy--display-transformers-list) HOT 2
- counsel-projectile-switch-to-project very slow to compare with projectile-switch-to-project
- `C-c C-k` in `counsel-projectile-switch-to-buffer` returns to `switch-to-buffer` instead of going back `counsel-projectile-switch-to-buffer`
- counsel-projectile fn omits file that is a visited buffer
- Use projectile-get-ext-command with counsel-projectile-rg?
- Merge into `abo-abo/swiper` repository? HOT 1
- counsel-projectile-switch-project-by-name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from counsel-projectile.