0
votes

I have installed Projectile on my emacs26 installation. My configuration looks like as below:

(projectile-mode +1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-global-mode) ;; to enable in all buffers
(setq projectile-enable-caching t) ;; to prevent constantly reindexing projectsx

I installed Projectile using Melpa.

I would like Projectile to find files in a project similar to how the command C-p works in vscode. Given the following directory:

src/
  views/
    cars.html
    dogs.html
  models/
    animals/
      dogs.js
      cats.js
    vehicles/
      cars.js
      trucks.js

In vscode if I do C-p dogs (no <RET>), I would see a selectable list containing dogs.html and dogs.js. As far as I can tell, this is duplicated by Projectile's C-c p f. The problem is when I do a search like models/dogs. In vscode, this would return only dogs.js, in Projectile, it returns nothing (reasonable, but not what I want).

I have large collections/model directories with many subdirectories and so I'm hoping to emulate this vscode behavior in Emacs if possible.

How can I have Projectile (or another Emacs plugin) file-search similarly to how vscode's C-p file-searches when dealing with multi-nested directories?

I investigated projectile-fix, but it does not seem to do as I want, and is also apparently incompatible with Helm, which I am starting to use and like.

2

2 Answers

1
votes

By default, Projectile uses Ido for completion. (Check the value of the variable projectile-completion-system to see if this has been configured differently in your Emacs.)

In Ido, you can type a part of the file name, and then hit C-SPC to restrict the list of items to what you've currently typed. So in your example you would type models C-SPC dogs to get to dogs.js.

If you have configured Projectile to use Helm, you can use a space character between the portions of the match: typing models dogs should narrow the list of matches down to dogs.js.

0
votes

You could use helm or ivy and its corresponding projectile plugins helm-projectile or counsel-projectile.

But this means you would have to pretty much change your the way of using emacs (at least in the short term). Anyway this will help you be more productive on the future so it's a good investment.