From 6e629c1c538cd846f17685d1cb3b46c66e3db0f2 Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Sun, 17 Oct 2021 14:12:41 +0300 Subject: [PATCH 1/6] refactor(vertico): move defadvice!'s to config.el The vast majority of Doom modules have their defadvice! statements in their config.el files, and not their autoloads. Since these don't need to be autoloaded to function, we move them for better consistency. --- .../completion/vertico/autoload/vertico.el | 19 ------------------- modules/completion/vertico/config.el | 13 +++++++++++++ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/modules/completion/vertico/autoload/vertico.el b/modules/completion/vertico/autoload/vertico.el index cdd8ce67a..84f149a9e 100644 --- a/modules/completion/vertico/autoload/vertico.el +++ b/modules/completion/vertico/autoload/vertico.el @@ -1,28 +1,9 @@ ;;; completion/vertico/autoload/vertico.el -*- lexical-binding: t; -*- -;; To prevent "Unused lexical variable" warning from +vertico--company-capf--candidates-a -;;;###autoload -(defvar orderless-match-faces) - ;; To prevent "Defining as dynamic an already lexical var" from +vertico/embark-preview ;;;###autoload (defvar embark-quit-after-action) -;;;###autoload -(defadvice! +vertico--company-capf--candidates-a (fn &rest args) - "Highlight company matches correctly, and try default completion styles before -orderless." - :around #'company-capf--candidates - (let ((orderless-match-faces [completions-common-part]) - (completion-styles +vertico-company-completion-styles)) - (apply fn args))) - -;;;###autoload -(defadvice! +vertico--consult-recent-file-a (&rest _args) - "`consult-recent-file' needs to have `recentf-mode' on to work correctly" - :before #'consult-recent-file - (recentf-mode +1)) - ;;;###autoload (cl-defun +vertico-file-search (&key query in all-files (recursive t) prompt args) "Conduct a file search using ripgrep. diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index 55dec4678..40588d591 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -34,6 +34,14 @@ overrides `completion-styles' during company completion sessions.") (use-package! orderless :after-call doom-first-input-hook :config + (defadvice! +vertico--company-capf--candidates-a (fn &rest args) + "Highlight company matches correctly, and try default completion styles before +orderless." + :around #'company-capf--candidates + (let ((orderless-match-faces [completions-common-part]) + (completion-styles +vertico-company-completion-styles)) + (apply fn args))) + (defun +vertico-orderless-dispatch (pattern _index _total) (cond ;; Ensure $ works with Consult commands, which add disambiguation suffixes @@ -94,6 +102,11 @@ overrides `completion-styles' during company completion sessions.") (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple) (advice-add #'multi-occur :override #'consult-multi-occur) :config + (defadvice! +vertico--consult-recent-file-a (&rest _args) + "`consult-recent-file' needs to have `recentf-mode' on to work correctly" + :before #'consult-recent-file + (recentf-mode +1)) + (setq consult-project-root-function #'doom-project-root consult-narrow-key "<" consult-line-numbers-widen t From 423939033f155d5c62d5dc8a54e69c6a156fd98e Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Sun, 17 Oct 2021 14:34:38 +0300 Subject: [PATCH 2/6] fix(vertico): which-key buffer on embark prompter The which-key buffer now disappears immediately on using embark-completing-read-prompter, instead of only after further user input. --- modules/completion/vertico/config.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index 40588d591..f766f4785 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -168,6 +168,14 @@ orderless." :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) + + (defadvice! +vertico--embark-which-key-prompt-a (fn &rest args) + "Hide the which-key indicator immediately when using the completing-read prompter." + :around #'embark-completing-read-prompter + (which-key--hide-popup-ignore-command) + (let ((embark-indicators + (remq #'embark-which-key-indicator embark-indicators))) + (apply fn args))) (cl-nsubstitute #'+vertico-embark-which-key-indicator #'embark-mixed-indicator embark-indicators) (add-to-list 'embark-indicators #'+vertico-embark-vertico-indicator) ;; add the package! target finder before the file target finder, From c8199c5c20509a60237f0841be73b4a54f177f9c Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Sat, 30 Oct 2021 19:22:46 +0300 Subject: [PATCH 3/6] fix(vertico): remove noise from which-key indicator Embark adds easier prefix-argument and digit-argument insertion in embark-act, but these clog up the space in the which-key indicator Also update the embark-become test to the new target format. --- modules/completion/vertico/autoload/vertico.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/completion/vertico/autoload/vertico.el b/modules/completion/vertico/autoload/vertico.el index 84f149a9e..7ea6a47e4 100644 --- a/modules/completion/vertico/autoload/vertico.el +++ b/modules/completion/vertico/autoload/vertico.el @@ -192,7 +192,7 @@ targets." (if (null keymap) (which-key--hide-popup-ignore-command) (which-key--show-keymap - (if (eq (caar targets) 'embark-become) + (if (eq (plist-get (car targets) :type) 'embark-become) "Become" (format "Act on %s '%s'%s" (plist-get (car targets) :type) @@ -203,7 +203,8 @@ targets." ((and (pred keymapp) km) km) (_ (key-binding prefix 'accept-default))) keymap) - nil nil t)))) + nil nil t (lambda (binding) + (not (string-suffix-p "-argument" (cdr binding)))))))) ;;;###autoload (defun +vertico/crm-select () From 8a2b7badc7845a857cdee1fb5d08e836cb4f2bd2 Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Sat, 30 Oct 2021 19:46:16 +0300 Subject: [PATCH 4/6] fix(vertico): remove unneeded manual preview... from +vertico/search-symbol-at-point. It only acts on buffers so it shouldn't have been there in the first place. --- modules/completion/vertico/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index f766f4785..a382709f6 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -125,8 +125,8 @@ orderless." (consult-customize consult-ripgrep consult-git-grep consult-grep consult-bookmark consult-recent-file - +default/search-project +default/search-project-for-symbol-at-point - +default/search-other-project +vertico/search-symbol-at-point + +default/search-project +default/search-other-project + +default/search-project-for-symbol-at-point +default/search-cwd +default/search-other-cwd +default/search-notes-for-symbol-at-point consult--source-file consult--source-project-file consult--source-bookmark From 5b630e17237d810653ac45970fc4bcbb654a968b Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Mon, 1 Nov 2021 13:49:28 +0200 Subject: [PATCH 5/6] feat(vertico): add consult-dir package --- modules/completion/vertico/config.el | 6 ++++++ modules/completion/vertico/packages.el | 1 + 2 files changed, 7 insertions(+) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index a382709f6..99d6e2dfd 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -148,6 +148,12 @@ orderless." :desc "Enter candidates" "RET" #'+vertico/crm-exit)) +(use-package! consult-dir + :bind (([remap list-directory] . consult-dir) + :map vertico-map + ("C-x C-d" . consult-dir) + ("C-x C-j" . consult-dir-jump-file))) + (use-package! consult-flycheck :when (featurep! :checkers syntax) :after (consult flycheck)) diff --git a/modules/completion/vertico/packages.el b/modules/completion/vertico/packages.el index 65793d736..40a53d5f0 100644 --- a/modules/completion/vertico/packages.el +++ b/modules/completion/vertico/packages.el @@ -9,6 +9,7 @@ (package! orderless :pin "62f71c34baca0b7d0adeab4a1c07d85ffcee80d9") (package! consult :pin "166e3b03c3de4f88bbfdeef7f52efac27642e2d3") +(package! consult-dir :pin "08f543ae6acbfc1ffe579ba1d00a5414012d5c0b") (when (featurep! :checkers syntax) (package! consult-flycheck :pin "92b259e6a8ebe6439f67d3d7ffa44b7e64b76478")) From a310fb4a779dbcb931e553ef133a8400fc8ee14c Mon Sep 17 00:00:00 2001 From: "Itai Y. Efrat" Date: Thu, 11 Nov 2021 01:45:10 +0200 Subject: [PATCH 6/6] bump: :completion vertico minad/consult@39f41edda6f3 -> minad/consult@57dc1adfdc0f minad/marginalia@09d8ab38a5a4 -> minad/marginalia@678b6528f390 minad/vertico@0df38cf1d729 -> minad/vertico@75f33e36204f oantolin/embark@d09fff2da750 -> oantolin/embark@5b34b2b60370 Update vertico-repeat configuration due to upstream changes. --- modules/completion/vertico/config.el | 1 + modules/completion/vertico/packages.el | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index 99d6e2dfd..990d5f36e 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -28,6 +28,7 @@ overrides `completion-styles' during company completion sessions.") ;; Cleans up path when moving directories with shadowed paths syntax, e.g. ;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/. (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy) + (add-hook 'minibuffer-setup-hook #'vertico-repeat-save) (map! :map vertico-map [backspace] #'vertico-directory-delete-char)) diff --git a/modules/completion/vertico/packages.el b/modules/completion/vertico/packages.el index 40a53d5f0..aa983772e 100644 --- a/modules/completion/vertico/packages.el +++ b/modules/completion/vertico/packages.el @@ -4,19 +4,19 @@ (package! vertico :recipe (:host github :repo "minad/vertico" :files ("*.el" "extensions/*.el")) - :pin "cd3c400aac2f5435080dc55d13c03c8886241365") + :pin "75f33e36204f8a72d0b8cde81e04d3350a848981") (package! orderless :pin "62f71c34baca0b7d0adeab4a1c07d85ffcee80d9") -(package! consult :pin "166e3b03c3de4f88bbfdeef7f52efac27642e2d3") +(package! consult :pin "57dc1adfdc0feafc71c6f418ff7aa1adbe47a5fd") (package! consult-dir :pin "08f543ae6acbfc1ffe579ba1d00a5414012d5c0b") (when (featurep! :checkers syntax) (package! consult-flycheck :pin "92b259e6a8ebe6439f67d3d7ffa44b7e64b76478")) -(package! embark :pin "8a0b80c6e6ecdf6bb0df7dc496fe4d03197def65") -(package! embark-consult :pin "8a0b80c6e6ecdf6bb0df7dc496fe4d03197def65") +(package! embark :pin "5b34b2b60370cea5ad9da5931856667a6fae0501") +(package! embark-consult :pin "5b34b2b60370cea5ad9da5931856667a6fae0501") -(package! marginalia :pin "fbd2f378f532b6d34d95d84b43edabd00e99a472") +(package! marginalia :pin "678b6528f3905e624b01daf787461d8c7e06ec0f") (package! wgrep :pin "f9687c28bbc2e84f87a479b6ce04407bb97cfb23")