reddit / emacs

Vertico and ignore files/directories

m-gregoire · 2022-06-27 20:34
Hello everyone! This post follows [this comment](https://www.reddit.com/r/emacs/comments/vlt68k/comment/idxfp0t/?utm_source=share&utm_medium=web2x&context=3), but to make It easier to search later on, if anyone encounter this issue in the future, I've creating a new thread. I've recently switched to Vertico as it became the default completion system on Doom Emacs (Which I'm using). So far, I'm really happy with it, however, I couldn't find any information of filtering/ignoring some directories/files in search results. I have some projects containing folders (e.g. "vendor") with so many files that search results become unusable but I might not want to ignore those folder at the VCS level, so I would like to ignore those folders/files in Vertico via Emacs config (And not using `.projectile` or `.gitignore` files. Looking at the source of Doom Emacs, [vertico-file-search](https://github.com/doomemacs/doomemacs/blob/master/modules/completion/vertico/autoload/vertico.el#L8), I don't see any option to do so. I couldn't find anything in Vertico documentation either. /u/sarit-hadad-enjoyer mentioned adding it to `projectile-globally-ignored-directories` seems to also apply in Vertico for him but unfortunately that doesn't seems to be working in my case. I would appreciate any information or help to help me solve this issue,
lcvas · 2022-06-27 23:38
Not exactly what you're looking for, but there's `completion-ignored-extensions`
m-gregoire · 2022-06-28 06:48
Thank you for your reply. Unfortunately I couldn't find a way to make it work for my usage (As `vendor/` is not a suffix). I've opened an issue on Github: https://github.com/minad/vertico/issues/246
yapfff · 2022-06-28 08:42
Vertico allows customizing the sorting function, but the function can also add an arbitrary filter. So using your own filter function removing what you don't want to see, then using vertico default sorting and returning the result should do what you want. See https://github.com/minad/vertico/issues/245 as an example to filter dot files.
m-gregoire · 2022-07-01 11:10
Sorry for my slow reply and thank you for your reply. I'll give it a try, however, It seems (https://github.com/minad/vertico/issues/246#issuecomment-1168368252) that Vertico relies on the search command so I'm guessing there is another way of ignoring files.
bram85 · 2022-07-03 06:08
You may consider using the orderless package for more advanced filtering. You can extend the syntax such that `!vendor/` removes all matching items from the list: (defun without-if-bang (pattern _index _total) (cond ((equal "!" pattern) '(orderless-literal . "")) ((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1))))) (setq orderless-style-dispatchers '(without-if-bang)))
m-gregoire · 2022-07-04 07:39
Indeed, `orderless` seems to be the way to go! Thank you for your help, this is what I was looking for :)