parent
576eb40b50
commit
523e945a3a
3 changed files with 46 additions and 51 deletions
|
@ -11,9 +11,9 @@ Emacs.")
|
||||||
"If non-nil, non-projects are purged from the cache on `kill-emacs-hook'.")
|
"If non-nil, non-projects are purged from the cache on `kill-emacs-hook'.")
|
||||||
|
|
||||||
(defvar doom-projectile-fd-binary
|
(defvar doom-projectile-fd-binary
|
||||||
(or (cl-find-if #'executable-find '("fdfind" "fd"))
|
(cl-find-if #'executable-find (list "fdfind" "fd"))
|
||||||
"fd")
|
"The filename of the `fd' executable. On some distros it's 'fdfind' (ubuntu,
|
||||||
"name of `fd-find' executable binary")
|
debian, and derivatives). On most it's 'fd'.")
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -131,6 +131,11 @@ c) are not valid projectile projects."
|
||||||
projectile-project-root-files)
|
projectile-project-root-files)
|
||||||
projectile-project-root-files-bottom-up nil)))
|
projectile-project-root-files-bottom-up nil)))
|
||||||
|
|
||||||
|
;; Some utilities have issues with windows-style paths in MSYS, so emit
|
||||||
|
;; unix-style paths instead.
|
||||||
|
(when IS-WINDOWS
|
||||||
|
(setenv "MSYS_NO_PATHCONV" "1"))
|
||||||
|
|
||||||
;; HACK Don't rely on VCS-specific commands to generate our file lists. That's
|
;; 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
|
;; 7 commands to maintain, versus the more generic, reliable and
|
||||||
;; performant `fd' or `ripgrep'.
|
;; performant `fd' or `ripgrep'.
|
||||||
|
@ -142,48 +147,38 @@ And if it's a function, evaluate it."
|
||||||
(funcall projectile-generic-command vcs)
|
(funcall projectile-generic-command vcs)
|
||||||
projectile-generic-command))
|
projectile-generic-command))
|
||||||
|
|
||||||
(cond
|
;; `projectile-generic-command' doesn't typically support a function, but my
|
||||||
;; If fd exists, use it for git and generic projects. fd is a rust program
|
;; `doom--only-use-generic-command-a' advice allows this. I do it this way so
|
||||||
;; that is significantly faster than git ls-files or find, and it respects
|
;; that projectile can adapt to remote systems (over TRAMP), rather then look
|
||||||
;; .gitignore. This is recommended in the projectile docs.
|
;; for fd/ripgrep on the remote system simply because it exists on the host.
|
||||||
((executable-find doom-projectile-fd-binary)
|
;; It's faster too.
|
||||||
(setq projectile-generic-command
|
(setq projectile-git-submodule-command nil
|
||||||
;; `projectile-generic-command' doesn't typically support a function.
|
projectile-indexing-method 'hybrid
|
||||||
;; My `doom--only-use-generic-command-a' advice allows this. I do it
|
projectile-generic-command
|
||||||
;; this way so that future changes to
|
|
||||||
;; `projectile-globally-ignored-directories' are respected.
|
|
||||||
(lambda (_)
|
(lambda (_)
|
||||||
(concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow"
|
(let ((find-exe-fn
|
||||||
(or (cl-find-if (if EMACS27+
|
(if EMACS27+
|
||||||
(doom-rpartial #'executable-find t)
|
(doom-rpartial #'executable-find t)
|
||||||
#'executable-find)
|
#'executable-find)))
|
||||||
'("fdfind" "fd"))
|
;; If fd exists, use it for git and generic projects. fd is a rust
|
||||||
"fd"))
|
;; program that is significantly faster than git ls-files or find, and
|
||||||
(cl-loop for dir in projectile-globally-ignored-directories
|
;; it respects .gitignore. This is recommended in the projectile docs.
|
||||||
concat " -E "
|
(cond
|
||||||
concat (shell-quote-argument dir))
|
((when-let
|
||||||
(if IS-WINDOWS " --path-separator=//")))
|
(bin (if (file-remote-p buffer-file-name nil t)
|
||||||
projectile-git-submodule-command nil
|
(cl-find-if find-exe-fn (list "fdfind" "fd"))
|
||||||
;; ensure Windows users get fd's benefits
|
doom-projectile-fd-binary))
|
||||||
projectile-indexing-method 'alien))
|
(concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow"
|
||||||
|
bin)
|
||||||
|
(if IS-WINDOWS " --path-separator=/"))))
|
||||||
;; Otherwise, resort to ripgrep, which is also faster than find
|
;; Otherwise, resort to ripgrep, which is also faster than find
|
||||||
((executable-find "rg")
|
((funcall find-exe-fn "rg")
|
||||||
(setq projectile-generic-command
|
|
||||||
(lambda (_)
|
|
||||||
(concat "rg -0 --files --follow --color=never --hidden"
|
(concat "rg -0 --files --follow --color=never --hidden"
|
||||||
(cl-loop for dir in projectile-globally-ignored-directories
|
(cl-loop for dir in projectile-globally-ignored-directories
|
||||||
concat " --glob "
|
concat " --glob "
|
||||||
concat (shell-quote-argument (concat "!" dir)))
|
concat (shell-quote-argument (concat "!" dir)))
|
||||||
(if IS-WINDOWS " --path-separator //")))
|
(if IS-WINDOWS " --path-separator /")))
|
||||||
projectile-git-submodule-command nil
|
("find . -type f -print0")))))
|
||||||
;; ensure Windows users get rg's benefits
|
|
||||||
projectile-indexing-method 'alien))
|
|
||||||
|
|
||||||
;; Fix breakage on windows in git projects with submodules, since Windows
|
|
||||||
;; doesn't have tr
|
|
||||||
(IS-WINDOWS
|
|
||||||
(setq projectile-git-submodule-command nil)))
|
|
||||||
|
|
||||||
(defadvice! doom--projectile-default-generic-command-a (orig-fn &rest args)
|
(defadvice! doom--projectile-default-generic-command-a (orig-fn &rest args)
|
||||||
"If projectile can't tell what kind of project you're in, it issues an error
|
"If projectile can't tell what kind of project you're in, it issues an error
|
||||||
|
|
|
@ -278,11 +278,11 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
|
||||||
"Change `counsel-file-jump' to use fd or ripgrep, if they are available."
|
"Change `counsel-file-jump' to use fd or ripgrep, if they are available."
|
||||||
:override #'counsel--find-return-list
|
:override #'counsel--find-return-list
|
||||||
(cl-destructuring-bind (find-program . args)
|
(cl-destructuring-bind (find-program . args)
|
||||||
(cond ((executable-find doom-projectile-fd-binary)
|
(cond ((when-let (fd (executable-find (or doom-projectile-fd-binary "fd")))
|
||||||
(append (list doom-projectile-fd-binary
|
(append (list fd
|
||||||
"--color=never" "-E" ".git"
|
"--color=never" "-E" ".git"
|
||||||
"--type" "file" "--type" "symlink" "--follow")
|
"--type" "file" "--type" "symlink" "--follow")
|
||||||
(if IS-WINDOWS '("--path-separator=/"))))
|
(if IS-WINDOWS '("--path-separator=/")))))
|
||||||
((executable-find "rg")
|
((executable-find "rg")
|
||||||
(append (list "rg" "--files" "--follow" "--color=never" "--hidden" "--no-messages")
|
(append (list "rg" "--files" "--follow" "--color=never" "--hidden" "--no-messages")
|
||||||
(cl-loop for dir in projectile-globally-ignored-directories
|
(cl-loop for dir in projectile-globally-ignored-directories
|
||||||
|
|
|
@ -162,7 +162,7 @@ we have to clean it up ourselves."
|
||||||
|
|
||||||
|
|
||||||
(use-package! fd-dired
|
(use-package! fd-dired
|
||||||
:when (executable-find doom-projectile-fd-binary)
|
:when doom-projectile-fd-binary
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
(global-set-key [remap find-dired] #'fd-dired)
|
(global-set-key [remap find-dired] #'fd-dired)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue