From 940f66fa89ab63ec97bd05a3aada17570e1c709d Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Tue, 10 Aug 2021 17:48:00 +0300 Subject: [PATCH] bump: :completion vertico iyefrat/all-the-icons-completion@d1d4b2f0dfbf -> iyefrat/all-the-icons-completion@96500418541b minad/consult@69bbd213dc8a -> minad/consult@105a1ac50169 minad/marginalia@11235445365c -> minad/marginalia@c6ca58bea819 minad/vertico@9de6709cddc0 -> minad/vertico@81a4b35f8d11 oantolin/embark@1a7e6b556142 -> oantolin/embark@19145d5a3367 oantolin/orderless@1e84120a2852 -> oantolin/orderless@1a7011ac9c47 - Adapt consult async commands to new consult-x-args format instead of consult-x-command. - Change regepx in +vertico-file-search to emacs instead of pcre, because consult switched to using only emacs regexps - Move to new embark-indicators variable, and replace embark-mixed-indicator with +vertico/embark-which-key-indicator to be compatible with future changes - Adapt Doom's optional usage of fd to new consult command format --- .../completion/vertico/autoload/vertico.el | 49 +++++++++++++------ modules/completion/vertico/config.el | 14 +++--- modules/completion/vertico/packages.el | 14 +++--- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/modules/completion/vertico/autoload/vertico.el b/modules/completion/vertico/autoload/vertico.el index 24a462d2b..e76966561 100644 --- a/modules/completion/vertico/autoload/vertico.el +++ b/modules/completion/vertico/autoload/vertico.el @@ -40,20 +40,19 @@ orderless." (setq deactivate-mark t) (let* ((project-root (or (doom-project-root) default-directory)) (directory (or in project-root)) - (args - (split-string - (string-trim - (concat (if all-files "-uu") - (unless recursive "--maxdepth 1") - "--null --line-buffered --color=always --max-columns=500 --no-heading --line-number --smart-case" - " --hidden -g !.git " - (mapconcat #'shell-quote-argument args " "))) - " ")) + (consult-ripgrep-args + (concat "rg " + (if all-files "-uu ") + (unless recursive "--maxdepth 1 ") + "--line-buffered --color=never --max-columns=1000 " + "--path-separator / --smart-case --no-heading --line-number " + "--hidden -g !.git " + (mapconcat #'shell-quote-argument args " ") + ".")) (prompt (if (stringp prompt) (string-trim prompt) "Search")) (query (or query (when (doom-region-active-p) - (rxt-quote-pcre (doom-thing-at-point-or-region))))) - (ripgrep-command (string-join `("rg" ,@args "." "-e ARG OPTS" ) " ")) + (regexp-quote (doom-thing-at-point-or-region))))) (consult-async-split-style consult-async-split-style) (consult-async-split-styles-alist consult-async-split-styles-alist)) ;; Change the split style if the initial query contains the separator. @@ -74,7 +73,7 @@ orderless." "%") :type perl) consult-async-split-style 'perlalt)))))) - (consult--grep prompt ripgrep-command directory query))) + (consult--grep prompt #'consult--ripgrep-builder directory query))) ;;;###autoload (defun +vertico/project-search (&optional arg initial-query directory) @@ -175,9 +174,7 @@ If INITIAL is non-nil, use as initial input." (require 'consult) (let* ((default-directory (or dir default-directory)) (prompt-dir (consult--directory-prompt "Find" default-directory)) - (cmd (split-string-and-unquote consult-find-command " ")) - (cmd (remove "OPTS" cmd)) - (cmd (remove "ARG" cmd))) + (cmd (split-string-and-unquote +vertico-consult-fd-args " "))) (find-file (consult--read (split-string (cdr (apply #'doom-call-process cmd)) "\n" t) @@ -270,3 +267,25 @@ targets." (interactive) (run-at-time 0 nil #'vertico-exit) (vertico-exit)) + +;;;###autoload +(defun +vertico--consult--fd-builder (input) + (pcase-let* ((cmd (split-string-and-unquote +vertico-consult-fd-args)) + (`(,arg . ,opts) (consult--command-split input)) + (`(,re . ,hl) (funcall consult--regexp-compiler + arg 'extended))) + (when re + (list :command (append cmd + (list (consult--join-regexps re 'extended)) + opts) + :highlight hl)))) + +(autoload #'consult--directory-prompt "consult") +;;;###autoload +(defun +vertico/consult-fd (&optional dir initial) + (interactive "P") + (if doom-projectile-fd-binary + (let* ((prompt-dir (consult--directory-prompt "Fd" dir)) + (default-directory (cdr prompt-dir))) + (find-file (consult--find (car prompt-dir) #'+vertico--consult--fd-builder initial))) + (consult-find dir initial))) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index e212510ac..0fc5c81f8 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -91,11 +91,12 @@ overrides `completion-styles' during company completion sessions.") consult-async-input-throttle 0.2 consult-async-input-debounce 0.1) - (when doom-projectile-fd-binary - (setq consult-find-command - (format "%s -i -H -E .git --regex %s ARG OPTS" - doom-projectile-fd-binary - (if IS-WINDOWS "--path-separator=/" "")))) + (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)) (consult-customize consult-ripgrep consult-git-grep consult-grep @@ -145,8 +146,7 @@ overrides `completion-styles' during company completion sessions.") :desc "Actions" "a" #'embark-act)) ; to be moved to :config default if accepted :config (set-popup-rule! "^\\*Embark Export Grep" :size 0.35 :ttl 0 :quit nil) - - (setq embark-indicator #'+vertico/embark-which-key-indicator) + (cl-nsubstitute #'+vertico/embark-which-key-indicator #'embark-mixed-indicator embark-indicators) ;; add the package! target finder before the file target finder, ;; so we don't get a false positive match. (let ((pos (or (cl-position diff --git a/modules/completion/vertico/packages.el b/modules/completion/vertico/packages.el index 6db93bb1a..f3619f11e 100644 --- a/modules/completion/vertico/packages.el +++ b/modules/completion/vertico/packages.el @@ -4,22 +4,22 @@ (package! vertico :recipe (:host github :repo "minad/vertico" :files ("*.el" "extensions/*.el")) - :pin "9de6709cddc09740d23d24fb425fa3c174d0e956") + :pin "81a4b35f8d11dfad56de1727ee9bdd3b4461d07c") -(package! orderless :pin "1e84120a28525ccb47b602fc19b7afbeffbbe502") +(package! orderless :pin "1a7011ac9c476dbb083c5ead88462a5f520ef8aa") -(package! consult :pin "69bbd213dc8a98abe94a4f5b1920e3d689d31caa") +(package! consult :pin "105a1ac50169382368a36ed53d7af908d02ffa07") (when (featurep! :checkers syntax) (package! consult-flycheck :pin "92b259e6a8ebe6439f67d3d7ffa44b7e64b76478")) -(package! embark :pin "1a7e6b556142216fa5f9b897bd5eca73968f3c49") -(package! embark-consult :pin "1a7e6b556142216fa5f9b897bd5eca73968f3c49") +(package! embark :pin "19145d5a3367038f0a9a114b7387c8a896037aec") +(package! embark-consult :pin "19145d5a3367038f0a9a114b7387c8a896037aec") -(package! marginalia :pin "11235445365c6ab119acabe91828e9182097ece7") +(package! marginalia :pin "c6ca58bea819c3b5e4b3295ad693c5cd0ae5db31") (package! wgrep :pin "f9687c28bbc2e84f87a479b6ce04407bb97cfb23") (when (featurep! +icons) (package! all-the-icons-completion :recipe (:host github :repo "iyefrat/all-the-icons-completion") - :pin "d1d4b2f0dfbfa94d33fe50e8089c06601adfe674")) + :pin "96500418541b7376cd0b3e4583b9509c0dd92b27"))