reddit / emacs

Projectile and ignore directories behavior

m-gregoire · 2022-06-27 11:19
Hello everyone, I'm using Doom Emacs with Projectile and I'm struggling to understand how to correctly ignore directories globally. I have `projectile-indexing-method` set to hybrid, and wanna ignore the directory `./vendor` in every project I have, regardless of the `.gitignore` file (Or any SVN file). I've added the following configuration: ``` (after! projectile (add-to-list 'projectile-globally-ignored-directories "vendor")) ``` But this does not seems to work. Here is a quick test: ``` mkdir -p /tmp/test-project/vendor echo "Hello" > /tmp/test-project/file echo "Hello" > /tmp/test-project/vendor/file # Create .projectile so Emacs recognize folder as project touch /tmp/test-project/.projectile ``` Now, in Emacs, after going inside the project, `projectile-find-file` shows the vendor directory. `describe-variable` does show `"vendor"` in the `projectile-globally-ignored-directories` list. I've found some contradictory information whether this should work or not with the `hybrid` indexation: - From this comment (https://github.com/doomemacs/doomemacs/issues/976#issuecomment-431711176), I understand I have to use `.gitignore`? - But from an issue I opened https://github.com/doomemacs/doomemacs/issues/6504, I understand it should? I've tried as much debugging as my Lisp skills allows so any help you be appreciated! Thank you
sarit-hadad-enjoyer · 2022-06-27 12:41
I'm not sure whether it is mac-specific or not, but I had the exact same problem and solved it by prefixing all added directories with `*`: (after! projectile (add-to-list 'projectile-globally-ignored-directories "*dist")) I sincerely have no idea why
gepardcv · 2022-06-27 13:40
Maybe Projectile has cached the directories you’re trying to ignore?
m-gregoire · 2022-06-27 13:44
That seems to fix it indeed! Thanks a lot This seems a bit contrary to the documentation where I remember reading (Can't find it again...) the `*` was not used as a wildcard but as a way of ignoring non-root folder (From the project root), and that without, only `./vendor` would be ignored, but not `./something/vendor`. On another note, I just switched to `vertico` but don't see any way of ignoring any directory. Looking at Doom code: https://github.com/doomemacs/doomemacs/blob/master/modules/completion/vertico/autoload/vertico.el#L8 I don't see any variable to do so. Maybe I should create another post on Reddit?
m-gregoire · 2022-06-27 13:50
Thanks for your reply. I ran `projectile-invalidate-cache` after every config change, I should have mentioned that! Seems like adding `*` in front of vendor fixes it, not sure why though...
sarit-hadad-enjoyer · 2022-06-27 14:01
Haha glad it helped. It indeed is odd. I suspect this is not an intended behaviour and I just tripped over a bug or something. Regarding vertico, I'm using it as well and the aforementioned solution works for me... Sounds odd since this filtering should occur before the list is displayed by Vertico as far as I know. But you can never know with this operating system ;)
jigarthanda-paal · 2022-06-27 14:18
I set up a `.ignore` in my project root dir. This helps with ivy completion. Idk why there's an ignore for ivy and for projectile separately.
m-gregoire · 2022-06-27 20:19
Thank you for your reply. Ideally, I wanted a solution inside the configuration which didn't rely on a external file.