fix: projectile: ignore more vc directories in file listings

This commit is contained in:
Henrik Lissner 2024-08-09 20:56:52 -04:00
parent 4fcf332749
commit d04e1404c2
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -33,6 +33,10 @@ Is nil if no executable is found in your PATH during startup.")
:init :init
(setq project-list-file (file-name-concat doom-profile-state-dir "projects")) (setq project-list-file (file-name-concat doom-profile-state-dir "projects"))
:config :config
;; Not valid vc backends, but I use it to inform (global) file index
;; exclusions below and elsewhere.
(add-to-list 'project-vc-backend-markers-alist '(Jujutsu . ".jj"))
(add-to-list 'project-vc-backend-markers-alist '(Sapling . ".sl"))
(add-to-list 'project-vc-extra-root-markers ".jj") (add-to-list 'project-vc-extra-root-markers ".jj")
;; TODO: Advice or add command for project-wide `find-sibling-file'. ;; TODO: Advice or add command for project-wide `find-sibling-file'.
@ -213,6 +217,10 @@ And if it's a function, evaluate it."
(if (version< version "8.3.0") (if (version< version "8.3.0")
(replace-regexp-in-string "--strip-cwd-prefix" "" projectile-git-fd-args t t) (replace-regexp-in-string "--strip-cwd-prefix" "" projectile-git-fd-args t t)
projectile-git-fd-args) projectile-git-fd-args)
(when project-vc-backend-markers-alist
(mapconcat (fn! (format "-E %s" (shell-quote-argument (cdr %))))
project-vc-backend-markers-alist
" "))
(if doom--system-windows-p " --path-separator=/" ""))) (if doom--system-windows-p " --path-separator=/" "")))
" "))) " ")))
;; Otherwise, resort to ripgrep, which is also faster than find ;; Otherwise, resort to ripgrep, which is also faster than find
@ -221,6 +229,10 @@ And if it's a function, evaluate it."
(delq (delq
nil (list doom-ripgrep-executable nil (list doom-ripgrep-executable
"-0 --files --follow --color=never --hidden" "-0 --files --follow --color=never --hidden"
(when project-vc-backend-markers-alist
(mapconcat (fn! (format "-g!%s" (shell-quote-argument (cdr %))))
project-vc-backend-markers-alist
" "))
(if doom--system-windows-p " --path-separator=/"))) (if doom--system-windows-p " --path-separator=/")))
" ")) " "))
((not doom--system-windows-p) "find . -type f | cut -c3- | tr '\\n' '\\0'") ((not doom--system-windows-p) "find . -type f | cut -c3- | tr '\\n' '\\0'")