15

After visiting a file that is part of a git repository, Projectile acknowledges the existence of my git repository as a project, but it only lists one file (the current file) as being part of the project. As I visit other files in the project, they become part of the project one at a time.

How do I create projects in Projectile so that they are immediately aware of all files in the project?

All of the tutorials that I have found so far assume that you are visiting a file within an existing project, and that Projectile knows what files that project contains.


Update

When I set up Projectile I took the following suggestion in the Projectile documentation:

Caching

Since indexing a big project is not exactly quick (especially in Emacs Lisp), Projectile supports caching of the project's files. The caching is enabled by default whenever native indexing is enabled.

To enable caching unconditionally use this snippet of code:

(setq projectile-enable-caching t)

Since I will occasionally be navigating some large projects, I added this to my init file hoping that it would give me a performance boost. I do not know how Projectile manages its caching, but at the time I assumed that the first time I visited a project, the project tree would be explored, and the cache would be populated with all of the project files. It appears that my assumption was wrong.

After I set projectile-enable-caching to nil, Projectile was able to find all of the files in my project. Thanks to alexurba's answer and follow-up comments, I was able to find the problem.

nispio
  • 8,175
  • 2
  • 35
  • 73
  • This question is far too broad, and should be closed. It is not a good candidate for SE. Please pose a specific question about a single, specific problem you are having. Provide contextual info as needed for the specific problem. – Drew Oct 14 '14 at 18:02
  • 4
    I think it is a good question that just has too much backstory. I think if it were refocused on this line: "How do I set up projects in Projectile so that they are immediately aware of all files in the project.", it would be good. – Jordon Biondo Oct 14 '14 at 18:36
  • 3
    @JordonBiondo: The more focused it is, the more useful (for SE) it is. Certainly one could aim for a minimal degree of focus, so that it would not be closed/closable. But one should be able to do even better than that. I'm guessing that there are probably 3 or 4 good questions in there, somewhere, and everyone would benefit if they were posed separately, in a focused way. – Drew Oct 14 '14 at 19:21
  • Which platform are you using (Windows, Mac, Linux)? The indexing of project files seems to be implemented platform dependently. – alexurba Oct 14 '14 at 20:32
  • 1
    I am testing this on Linux (RHEL 6.5), but I would like to be able to use it on all platforms. – nispio Oct 14 '14 at 20:37
  • Your update edit has saved my sanity. I was so confused about why I was only seeing files I had already visited in projectile, instead of all files in a project. I found it very annoying but put up with it. I must have turned on projectile-enable-caching accidentally at some point. Thanks for posting the update. – sanimalp Nov 21 '14 at 17:09

1 Answers1

9

Once activated, projectile works out-of-the-box for git projects. To activate include

(projectile-global-mode)

in your Emacs configuration (or start projectile-mode) manually.

Then projectile-find-file (default key binding is C-c p f) works just like find-file, but will act on all files in the subdirectories of the project's main directory (where the .git directory is).

If you want to avoid git, you can alternatively create a file .projectile in the project root. This will have the same effect and can be used to ignore certain files or directories (similar to .gitignore).

Much more info can be found on the project's github page (which is too long a read, either). I especially recommend to read the sections about Ido and helm.

Edit:

Check the value of projectile-indexing-method. On Linux this should be alien, and the value of projectile-enable-caching should be nil.

alexurba
  • 216
  • 1
  • 4
  • This is exactly the part that is not working for me. When I run `projectile-find-file`, the only files listed are the ones that I have already visited, even though the project directory contains many more. – nispio Oct 14 '14 at 20:36
  • @nispio, on the project page it mentions different indexing and caching methods. Can you check the value of `projectile-indexing-method` (`C-h v projectile-indexing-method`)? On Linux this should be `alien`. – alexurba Oct 14 '14 at 20:42
  • And `projectile-enable-caching` should be `nil`. – alexurba Oct 14 '14 at 20:43
  • 2
    You found it. I set `projectile-enable-caching` to `nil` and it started working how I expect. Knowing that, I was able to set it back to `t` and then use `C-u C-c p f` to invalidate the cache for `projectile-find-file` and that is also working. I'm confused why I need to invalidate the cache if the project has never been cached before, but I will save that for another question, perhaps. – nispio Oct 14 '14 at 20:52
  • Great that it works. Though, I am not sure what will happen under Windows where 'alien' indexing is not available. But maybe that can really be the subject of a second question when you run into it. – alexurba Oct 14 '14 at 21:03
  • Since I have marked this post as the answer, I copied the comments that fixed my problem up into the body of the post. – nispio Oct 14 '14 at 21:11