diff --git a/lisp/lib/projects.el b/lisp/lib/projects.el index ce7964421..ffd2aa9b1 100644 --- a/lisp/lib/projects.el +++ b/lisp/lib/projects.el @@ -150,8 +150,8 @@ If DIR is not a project, it will be indexed (but not cached)." #'counsel-projectile-find-file #'projectile-find-file))) ((and (bound-and-true-p vertico-mode) - (fboundp '+vertico/find-file-in)) - (+vertico/find-file-in default-directory)) + (fboundp '+vertico/consult-fd-or-find)) + (+vertico/consult-fd-or-find default-directory)) ((and (bound-and-true-p ivy-mode) (fboundp 'counsel-file-jump)) (call-interactively #'counsel-file-jump)) diff --git a/modules/completion/vertico/autoload/vertico.el b/modules/completion/vertico/autoload/vertico.el index 0b4219eaf..50059b68b 100644 --- a/modules/completion/vertico/autoload/vertico.el +++ b/modules/completion/vertico/autoload/vertico.el @@ -137,26 +137,6 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location (+vertico/embark-preview) (user-error (vertico-directory-enter))))) -(defvar +vertico/find-file-in--history nil) -;;;###autoload -(defun +vertico/find-file-in (&optional dir initial) - "Jump to file under DIR (recursive). -If INITIAL is non-nil, use as initial input." - (interactive) - (require 'consult) - (let* ((default-directory (or dir default-directory)) - (prompt-dir (consult--directory-prompt "Find" default-directory)) - (cmd (split-string-and-unquote +vertico-consult-fd-args " "))) - (find-file - (consult--read - (split-string (cdr (apply #'doom-call-process cmd)) "\n" t) - :prompt default-directory - :sort nil - :initial (if initial (shell-quote-argument initial)) - :add-history (thing-at-point 'filename) - :category 'file - :history '(:input +vertico/find-file-in--history))))) - ;;;###autoload (defun +vertico/jump-list (jump) "Go to an entry in evil's (or better-jumper's) jumplist." @@ -229,27 +209,23 @@ targets." (not (string-suffix-p "-argument" (cdr binding)))))))) ;;;###autoload -(defun +vertico--consult--fd-make-builder () - (let ((cmd (split-string-and-unquote +vertico-consult-fd-args))) - (lambda (input) - (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) - (`(,re . ,hl) (funcall consult--regexp-compiler - arg 'extended t))) - (when re - (cons (append cmd - (list (consult--join-regexps re 'extended)) - opts) - hl)))))) - -(autoload #'consult--directory-prompt "consult") -;;;###autoload -(defun +vertico/consult-fd (&optional dir initial) +(defun +vertico/consult-fd-or-find (&optional dir initial) + "Runs consult-fd if fd version > 8.6.0 exists, consult-find otherwise. +See URL `https://github.com/minad/consult/issues/770'." (interactive "P") - (if doom-projectile-fd-binary - (pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Fd" dir)) - (default-directory dir) - (builder (consult--find-make-builder paths))) - (find-file (consult--find prompt builder initial))) + ;; TODO this condition was adapted from a similar one in lisp/doom-projects.el, to be replaced with a more robust check post v3 + (if (when-let* + ((bin (if (ignore-errors (file-remote-p default-directory nil t)) + (cl-find-if (doom-rpartial #'executable-find t) + (list "fdfind" "fd")) + doom-projectile-fd-binary)) + (version (with-memoization doom-projects--fd-version + (cadr (split-string (cdr (doom-call-process bin "--version")) + " " t)))) + ((ignore-errors (version-to-list version)))) + ;; TODO remove once fd 8.6.0 is widespread enough to be the minimum version for doom + (version< "8.6.0" version)) + (consult-fd dir initial) (consult-find dir initial))) ;;;###autoload diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index a4efa7c4e..e92b9ec47 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -7,9 +7,6 @@ The completion/vertico module uses the orderless completion style by default, but this returns too broad a candidate set for company completion. This variable overrides `completion-styles' during company completion sessions.") -(defvar +vertico-consult-fd-args nil - "Shell command and arguments the vertico module uses for fd.") - (defvar +vertico-consult-dir-container-executable "docker" "Command to call for listing container hosts.") @@ -142,20 +139,21 @@ orderless." :before (list #'consult-recent-file #'consult-buffer) (recentf-mode +1)) - (setq consult-project-root-function #'doom-project-root + (setq consult-project-function #'doom-project-root consult-narrow-key "<" consult-line-numbers-widen t consult-async-min-input 2 consult-async-refresh-delay 0.15 consult-async-input-throttle 0.2 consult-async-input-debounce 0.1) - (unless +vertico-consult-fd-args - (setq +vertico-consult-fd-args - (if doom-projectile-fd-binary - (format "%s --color=never -i -H -E .git --regex %s" - doom-projectile-fd-binary - (if IS-WINDOWS "--path-separator=/" "")) - consult-find-args))) + (if doom-projectile-fd-binary + (setq consult-fd-args + '(doom-projectile-fd-binary + "--color=never" + ;; https://github.com/sharkdp/fd/issues/839 + "--full-path --absolute-path" + "--hidden --exclude .git" + (when IS-WINDOWS "--path-separator=/")))) (consult-customize consult-ripgrep consult-git-grep consult-grep @@ -305,9 +303,9 @@ orderless." (map! (:map embark-file-map :desc "Open target with sudo" "s" #'doom/sudo-find-file (:when (modulep! :tools magit) - :desc "Open magit-status of target" "g" #'+vertico/embark-magit-status) + :desc "Open magit-status of target" "g" #'+vertico/embark-magit-status) (:when (modulep! :ui workspaces) - :desc "Open in new workspace" "TAB" #'+vertico/embark-open-in-new-workspace)))) + :desc "Open in new workspace" "TAB" #'+vertico/embark-open-in-new-workspace)))) (use-package! marginalia diff --git a/modules/completion/vertico/packages.el b/modules/completion/vertico/packages.el index 68f1b73e9..0189e2357 100644 --- a/modules/completion/vertico/packages.el +++ b/modules/completion/vertico/packages.el @@ -1,24 +1,21 @@ ;; -*- no-byte-compile: t; -*- ;;; completion/vertico/packages.el -(package! vertico - :recipe (:host github :repo "minad/vertico" - :files ("*.el" "extensions/*.el")) - :pin "a28370d07f35c5387c7a9ec2e5b67f0d4598058d") +(package! vertico :pin "cf8b2abf5207696c054c33214c86e3969d415054") -(package! orderless :pin "e6784026717a8a6a7dcd0bf31fd3414f148c542e") +(package! orderless :pin "b24748093b00b37c3a572c4909f61c08fa27504f") -(package! consult :pin "fe49dedd71802ff97be7b89f1ec4bd61b98c2b13") -(package! consult-dir :pin "ed8f0874d26f10f5c5b181ab9f2cf4107df8a0eb") +(package! consult :pin "e4d371235647a7f4967f093eff2125652796957c") +(package! consult-dir :pin "3f5f4b71ebe819392cb090cda71bd39a93bd830a") (when (and (modulep! :checkers syntax) (not (modulep! :checkers syntax +flymake))) - (package! consult-flycheck :pin "3f2a7c17cc2fe64e0c07e3bf90e33c885c0d7062")) -(package! embark :pin "9a44418c349e41020cdc5ad1bd21e8c77a429062") -(package! embark-consult :pin "9a44418c349e41020cdc5ad1bd21e8c77a429062") + (package! consult-flycheck :pin "d83f87581af74f7a2739d8b1b90c37da5ae3d310")) +(package! embark :pin "33c392cf3ce5b92ad73ed5c4f44dbca5d0741cde") +(package! embark-consult :pin "33c392cf3ce5b92ad73ed5c4f44dbca5d0741cde") -(package! marginalia :pin "866e50aee4f066b0903752c69b33e9b7cab93f97") +(package! marginalia :pin "ea356ebb1ddb8d6da78574b517155475cf52d46f") -(package! wgrep :pin "3132abd3750b8c87cbcf6942db952acfab5edccd") +(package! wgrep :pin "208b9d01cfffa71037527e3a324684b3ce45ddc4") (when (modulep! +icons) (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010")) @@ -26,4 +23,4 @@ (when (modulep! +childframe) (package! vertico-posframe :recipe (:host github :repo "tumashu/vertico-posframe") - :pin "7da6d648ff4202a48eb6647ee7dce8d65de48779")) + :pin "bc0e67cbbba4daaf6ce7b8701a0dc7797d468752")) diff --git a/modules/tools/lookup/autoload/lookup.el b/modules/tools/lookup/autoload/lookup.el index 0a2002773..b72a52f4e 100644 --- a/modules/tools/lookup/autoload/lookup.el +++ b/modules/tools/lookup/autoload/lookup.el @@ -283,7 +283,7 @@ otherwise falling back to ffap.el (find-file-at-point)." (counsel-file-jump guess (doom-project-root))) ((and (modulep! :completion vertico) (doom-project-p)) - (+vertico/find-file-in (doom-project-root) guess)) + (+vertico/consult-fd-or-find (doom-project-root) guess)) ((find-file-at-point (ffap-prompter guess)))) t))