projectile: resort to ripgrep if fd is absent

Speeds up file search in general, and on Windows especially.
This commit is contained in:
Henrik Lissner 2019-05-12 22:12:04 -04:00
parent 5e8db5a860
commit 769cfbe5d1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -95,14 +95,25 @@ c) are not valid projectile projects."
(funcall orig-fn file name))) (funcall orig-fn file name)))
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file) (advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)
;; If fd exists, use it for git and generic projects (cond
;; fd is a rust program that is significantly faster. It also respects ;; If fd exists, use it for git and generic projects fd is a rust program
;; .gitignore. This is recommended in the projectile docs ;; that is significantly faster. It also respects .gitignore. This is
(when (executable-find doom-projectile-fd-binary) ;; recommended in the projectile docs
((executable-find doom-projectile-fd-binary)
(setq projectile-git-command (concat (setq projectile-git-command (concat
doom-projectile-fd-binary doom-projectile-fd-binary
" . --type f -0 -H -E .git") " . --type f -0 -H -E .git")
projectile-generic-command projectile-git-command))) projectile-generic-command projectile-git-command))
;; Otherwise, resort to ripgrep, which is also faster than find.
((executable-find "rg")
(setq projectile-generic-command
(concat "rg -0 --files --color=never --hidden"
(cl-loop for dir in projectile-globally-ignored-directories
concat (format " --glob '!%s'" dir))))
(when IS-WINDOWS
(setq projectile-indexing-method 'alien
projectile-enable-caching nil)))))
;; ;;
;; Project-based minor modes ;; Project-based minor modes