Speed up project root detection by resolving it less often

Projectile can consume a lot of cycles, especially in indirect buffers
or because of project-root-sensitive path segments in the modeline. This
experimental fix should spare you that heartache.
This commit is contained in:
Henrik Lissner 2020-04-27 17:27:32 -04:00
parent e9b288744d
commit 9acba6b269
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -40,6 +40,16 @@ Emacs.")
:config
(projectile-mode +1)
;; REVIEW Resolve the project root once, when the file/buffer is opened. This
;; speeds up projectile's project root resolution by leaps, but does
;; put you at risk of having a stale project root.
(setq-hook! '(after-change-major-mode-hook
;; In case the user saves the file to a new location
after-save-hook
;; ...or makes external changes then returns to Emacs
focus-in-hook)
projectile-project-root (if default-directory (doom-project-root)))
;; Projectile runs four functions to determine the root (in this order):
;;
;; + `projectile-root-local' -> checks the `projectile-project-root' variable