diff --git a/core/core-projects.el b/core/core-projects.el index 9fa542fcf..968f37924 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -130,19 +130,34 @@ c) are not valid projectile projects." projectile-project-root-files) projectile-project-root-files-bottom-up nil))) + ;; HACK Don't rely on VCS-specific commands to generate our file lists. That's + ;; 7 commands to maintain, versus the more generic, reliable and + ;; performant `fd' or `ripgrep'. + (defadvice! doom--only-use-generic-command-a (orig-fn vcs) + "Only use `projectile-generic-command' for indexing project files. +And if it's a function, evaluate it." + :around #'projectile-get-ext-command + (if (functionp projectile-generic-command) + (funcall projectile-generic-command vcs) + projectile-generic-command)) + (cond ;; If fd exists, use it for git and generic projects. fd is a rust program ;; that is significantly faster than git ls-files or find, and it respects ;; .gitignore. This is recommended in the projectile docs. ((executable-find doom-projectile-fd-binary) (setq projectile-generic-command - (concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow" - doom-projectile-fd-binary) - (cl-loop for dir in projectile-globally-ignored-directories - concat " -E " - concat (shell-quote-argument dir)) - (if IS-WINDOWS " --path-separator=//")) - projectile-git-command projectile-generic-command + ;; `projectile-generic-command' doesn't typically support a function. + ;; My `doom--only-use-generic-command-a' advice allows this. I do it + ;; this way so that future changes to + ;; `projectile-globally-ignored-directories' are respected. + (lambda (_) + (concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow" + doom-projectile-fd-binary) + (cl-loop for dir in projectile-globally-ignored-directories + concat " -E " + concat (shell-quote-argument dir)) + (if IS-WINDOWS " --path-separator=//"))) projectile-git-submodule-command nil ;; ensure Windows users get fd's benefits projectile-indexing-method 'alien)) @@ -150,12 +165,12 @@ c) are not valid projectile projects." ;; Otherwise, resort to ripgrep, which is also faster than find ((executable-find "rg") (setq projectile-generic-command - (concat "rg -0 --files --follow --color=never --hidden" - (cl-loop for dir in projectile-globally-ignored-directories - concat " --glob " - concat (shell-quote-argument (concat "!" dir))) - (if IS-WINDOWS " --path-separator //")) - projectile-git-command projectile-generic-command + (lambda (_) + (concat "rg -0 --files --follow --color=never --hidden" + (cl-loop for dir in projectile-globally-ignored-directories + concat " --glob " + concat (shell-quote-argument (concat "!" dir))) + (if IS-WINDOWS " --path-separator //"))) projectile-git-submodule-command nil ;; ensure Windows users get rg's benefits projectile-indexing-method 'alien))