Skip to content

Commit c3a9388

Browse files
committed
fix: projectile: centralize per-project cache files
Projectile was bumped in #8317, which introduced per-project file caches, but they were written to the root of the project. Rather than litter projects with these dotfiles, I advise projectile to write them to a single place (under `doom-profile-cache-dir`). Also moves the known-projectiles cache file to the same directory. Amend: #8317
1 parent 4def7f3 commit c3a9388

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lisp/doom-projects.el

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Is nil if no executable is found in your PATH during startup.")
1414
1515
Is nil if no executable is found in your PATH during startup.")
1616

17+
(defvar doom-projectile-cache-dir (file-name-concat doom-profile-cache-dir "projectile")
18+
"The directory where per-project projectile file index caches are stored.")
19+
1720

1821
;;
1922
;;; Packages
@@ -49,14 +52,16 @@ Is nil if no executable is found in your PATH during startup.")
4952
projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o")
5053
projectile-kill-buffers-filter 'kill-only-files
5154
projectile-ignored-projects '("~/")
52-
projectile-known-projects-file (concat doom-cache-dir "projectile-projects.eld")
55+
projectile-known-projects-file (concat doom-projectile-cache-dir "projects.eld")
5356
projectile-ignored-project-function #'doom-project-ignored-p
5457
projectile-fd-executable doom-fd-executable)
5558

5659
(global-set-key [remap evil-jump-to-tag] #'projectile-find-tag)
5760
(global-set-key [remap find-tag] #'projectile-find-tag)
5861

5962
:config
63+
(make-directory doom-projectile-cache-dir t)
64+
6065
;; HACK: Auto-discovery and cleanup on `projectile-mode' is slow and
6166
;; premature. Let's try to defer it until it's needed.
6267
(add-transient-hook! 'projectile-relevant-known-projects
@@ -97,6 +102,17 @@ Is nil if no executable is found in your PATH during startup.")
97102
(setq compilation-buffer-name-function #'projectile-compilation-buffer-name
98103
compilation-save-buffers-predicate #'projectile-current-project-buffer-p)
99104

105+
;; Centralize Projectile's per-project cache files, so they don't litter
106+
;; projects with dotfiles.
107+
(defadvice! doom--projectile-centralized-cache-files-a (fn &optional proot)
108+
:around #'projectile-project-cache-file
109+
(let* ((proot (abbreviate-file-name (or proot (doom-project-root))))
110+
(projectile-cache-file
111+
(expand-file-name
112+
(format "%s-%s" (doom-project-name proot) (sha1 proot))
113+
doom-projectile-cache-dir)))
114+
(funcall fn proot)))
115+
100116
;; Support the more generic .project files as an alternative to .projectile
101117
(defadvice! doom--projectile-dirconfig-file-a ()
102118
:override #'projectile-dirconfig-file

0 commit comments

Comments
 (0)