merge: pull request #7463 from iyefrat/bump/vertico-module

This commit is contained in:
Henrik Lissner 2024-01-28 00:42:17 -05:00 committed by GitHub
commit d21fb3f736
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 40 additions and 69 deletions

View file

@ -150,8 +150,8 @@ If DIR is not a project, it will be indexed (but not cached)."
#'counsel-projectile-find-file #'counsel-projectile-find-file
#'projectile-find-file))) #'projectile-find-file)))
((and (bound-and-true-p vertico-mode) ((and (bound-and-true-p vertico-mode)
(fboundp '+vertico/find-file-in)) (fboundp '+vertico/consult-fd-or-find))
(+vertico/find-file-in default-directory)) (+vertico/consult-fd-or-find default-directory))
((and (bound-and-true-p ivy-mode) ((and (bound-and-true-p ivy-mode)
(fboundp 'counsel-file-jump)) (fboundp 'counsel-file-jump))
(call-interactively #'counsel-file-jump)) (call-interactively #'counsel-file-jump))

View file

@ -137,26 +137,6 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location
(+vertico/embark-preview) (+vertico/embark-preview)
(user-error (vertico-directory-enter))))) (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 ;;;###autoload
(defun +vertico/jump-list (jump) (defun +vertico/jump-list (jump)
"Go to an entry in evil's (or better-jumper's) jumplist." "Go to an entry in evil's (or better-jumper's) jumplist."
@ -229,27 +209,23 @@ targets."
(not (string-suffix-p "-argument" (cdr binding)))))))) (not (string-suffix-p "-argument" (cdr binding))))))))
;;;###autoload ;;;###autoload
(defun +vertico--consult--fd-make-builder () (defun +vertico/consult-fd-or-find (&optional dir initial)
(let ((cmd (split-string-and-unquote +vertico-consult-fd-args))) "Runs consult-fd if fd version > 8.6.0 exists, consult-find otherwise.
(lambda (input) See URL `https://github.com/minad/consult/issues/770'."
(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)
(interactive "P") (interactive "P")
(if doom-projectile-fd-binary ;; TODO this condition was adapted from a similar one in lisp/doom-projects.el, to be replaced with a more robust check post v3
(pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Fd" dir)) (if (when-let*
(default-directory dir) ((bin (if (ignore-errors (file-remote-p default-directory nil t))
(builder (consult--find-make-builder paths))) (cl-find-if (doom-rpartial #'executable-find t)
(find-file (consult--find prompt builder initial))) (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))) (consult-find dir initial)))
;;;###autoload ;;;###autoload

View file

@ -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 but this returns too broad a candidate set for company completion. This variable
overrides `completion-styles' during company completion sessions.") 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" (defvar +vertico-consult-dir-container-executable "docker"
"Command to call for listing container hosts.") "Command to call for listing container hosts.")
@ -142,20 +139,21 @@ orderless."
:before (list #'consult-recent-file #'consult-buffer) :before (list #'consult-recent-file #'consult-buffer)
(recentf-mode +1)) (recentf-mode +1))
(setq consult-project-root-function #'doom-project-root (setq consult-project-function #'doom-project-root
consult-narrow-key "<" consult-narrow-key "<"
consult-line-numbers-widen t consult-line-numbers-widen t
consult-async-min-input 2 consult-async-min-input 2
consult-async-refresh-delay 0.15 consult-async-refresh-delay 0.15
consult-async-input-throttle 0.2 consult-async-input-throttle 0.2
consult-async-input-debounce 0.1) consult-async-input-debounce 0.1)
(unless +vertico-consult-fd-args (if doom-projectile-fd-binary
(setq +vertico-consult-fd-args (setq consult-fd-args
(if doom-projectile-fd-binary '(doom-projectile-fd-binary
(format "%s --color=never -i -H -E .git --regex %s" "--color=never"
doom-projectile-fd-binary ;; https://github.com/sharkdp/fd/issues/839
(if IS-WINDOWS "--path-separator=/" "")) "--full-path --absolute-path"
consult-find-args))) "--hidden --exclude .git"
(when IS-WINDOWS "--path-separator=/"))))
(consult-customize (consult-customize
consult-ripgrep consult-git-grep consult-grep consult-ripgrep consult-git-grep consult-grep
@ -305,9 +303,9 @@ orderless."
(map! (:map embark-file-map (map! (:map embark-file-map
:desc "Open target with sudo" "s" #'doom/sudo-find-file :desc "Open target with sudo" "s" #'doom/sudo-find-file
(:when (modulep! :tools magit) (: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) (: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 (use-package! marginalia

View file

@ -1,24 +1,21 @@
;; -*- no-byte-compile: t; -*- ;; -*- no-byte-compile: t; -*-
;;; completion/vertico/packages.el ;;; completion/vertico/packages.el
(package! vertico (package! vertico :pin "cf8b2abf5207696c054c33214c86e3969d415054")
:recipe (:host github :repo "minad/vertico"
:files ("*.el" "extensions/*.el"))
:pin "a28370d07f35c5387c7a9ec2e5b67f0d4598058d")
(package! orderless :pin "e6784026717a8a6a7dcd0bf31fd3414f148c542e") (package! orderless :pin "b24748093b00b37c3a572c4909f61c08fa27504f")
(package! consult :pin "fe49dedd71802ff97be7b89f1ec4bd61b98c2b13") (package! consult :pin "e4d371235647a7f4967f093eff2125652796957c")
(package! consult-dir :pin "ed8f0874d26f10f5c5b181ab9f2cf4107df8a0eb") (package! consult-dir :pin "3f5f4b71ebe819392cb090cda71bd39a93bd830a")
(when (and (modulep! :checkers syntax) (when (and (modulep! :checkers syntax)
(not (modulep! :checkers syntax +flymake))) (not (modulep! :checkers syntax +flymake)))
(package! consult-flycheck :pin "3f2a7c17cc2fe64e0c07e3bf90e33c885c0d7062")) (package! consult-flycheck :pin "d83f87581af74f7a2739d8b1b90c37da5ae3d310"))
(package! embark :pin "9a44418c349e41020cdc5ad1bd21e8c77a429062") (package! embark :pin "33c392cf3ce5b92ad73ed5c4f44dbca5d0741cde")
(package! embark-consult :pin "9a44418c349e41020cdc5ad1bd21e8c77a429062") (package! embark-consult :pin "33c392cf3ce5b92ad73ed5c4f44dbca5d0741cde")
(package! marginalia :pin "866e50aee4f066b0903752c69b33e9b7cab93f97") (package! marginalia :pin "ea356ebb1ddb8d6da78574b517155475cf52d46f")
(package! wgrep :pin "3132abd3750b8c87cbcf6942db952acfab5edccd") (package! wgrep :pin "208b9d01cfffa71037527e3a324684b3ce45ddc4")
(when (modulep! +icons) (when (modulep! +icons)
(package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010")) (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010"))
@ -26,4 +23,4 @@
(when (modulep! +childframe) (when (modulep! +childframe)
(package! vertico-posframe (package! vertico-posframe
:recipe (:host github :repo "tumashu/vertico-posframe") :recipe (:host github :repo "tumashu/vertico-posframe")
:pin "7da6d648ff4202a48eb6647ee7dce8d65de48779")) :pin "bc0e67cbbba4daaf6ce7b8701a0dc7797d468752"))

View file

@ -283,7 +283,7 @@ otherwise falling back to ffap.el (find-file-at-point)."
(counsel-file-jump guess (doom-project-root))) (counsel-file-jump guess (doom-project-root)))
((and (modulep! :completion vertico) ((and (modulep! :completion vertico)
(doom-project-p)) (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)))) ((find-file-at-point (ffap-prompter guess))))
t)) t))