Only use fd with consult-project-buffer

This commit is contained in:
David Morgan 2021-09-06 13:41:50 +01:00
parent 113355a671
commit a7055e0648
1 changed files with 14 additions and 17 deletions

View File

@ -295,9 +295,17 @@
(plist-put (copy-sequence consult--source-project-file) :narrow '(?x "Project Files")))
(add-to-list 'consult-buffer-sources 'consult--source-perspective-files t)
;; Use fd that that we aren't just getting recentf, but also respect .gitignore
(setq consult--source-project-file
(plist-put consult--source-project-file
;; Versions of consult--source-project-buffer and consult--source-project-file for use by consult-project-buffer
;; They allow narrowing with b and f (instead of p)
;; The file version uses fd to find items, so that all files (rather than using recentf) are listed, respecing .gitignore
(defvar consult--project-source-project-buffer
(plist-put (plist-put (copy-sequence consult--source-project-buffer)
:hidden nil)
:narrow '(?b . "Project Buffer")))
(defvar consult--project-source-project-file
(plist-put (plist-put (plist-put (copy-sequence consult--source-project-file)
:hidden nil)
:narrow '(?f . "Project File"))
:items '(lambda ()
(when-let (root (consult--project-root))
(let ((len (length root))
@ -309,17 +317,6 @@
(format "fd --color never -t f -0 . %s" root))
"\0" t)))))))
;; Versions of consult--source-project-buffer and consult--source-project-file for use by consult-project-buffer
;; They allow narrowing with b and f (instead of p)
(defvar consult--project-source-project-buffer
(plist-put (plist-put (copy-sequence consult--source-project-buffer)
:hidden nil)
:narrow '(?b . "Project Buffer")))
(defvar consult--project-source-project-file
(plist-put (plist-put (copy-sequence consult--source-project-file)
:hidden nil)
:narrow '(?f . "Project File")))
(defun consult-project-buffer ()
(interactive)
(let ((consult-buffer-sources '(consult--project-source-project-buffer