diff --git a/modules/completion/vertico/config.el b/modules/completion/vertico/config.el index 159eb3639..24f6f6f56 100644 --- a/modules/completion/vertico/config.el +++ b/modules/completion/vertico/config.el @@ -263,8 +263,23 @@ orderless." (use-package! embark :defer t :init - (setq which-key-use-C-h-commands nil + ;; Allow C-h to open Consult when calling which-key without a prefix. + (setq which-key-use-C-h-commands t prefix-help-command #'embark-prefix-help-command) + (defvar +vertico-which-key-current-keymap nil + "The current keymap being displayed by which-key.") + (defadvice! +vertico-which-key-update-current-keymap-a (_keymap-name keymap &rest args) + :before #'which-key--show-keymap + (setq +vertico-which-key-current-keymap keymap)) + (defadvice! +vertico-which-key-consult-C-h-dispatch (oldfun) + :around #'which-key-C-h-dispatch + (setq this-command 'embark-prefix-help-command) + (cond ((not (which-key--popup-showing-p)) + (call-interactively #'embark-prefix-help-command)) + ((string-empty-p (which-key--current-key-string)) + (embark-bindings-in-keymap +vertico-which-key-current-keymap)) + (t (call-interactively #'embark-prefix-help-command)))) + (map! [remap describe-bindings] #'embark-bindings "C-;" #'embark-act ; to be moved to :config default if accepted (:map minibuffer-local-map @@ -310,10 +325,10 @@ 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" "" #'+vertico/embark-open-in-new-workspace)))) + :desc "Open in new workspace" "TAB" #'+vertico/embark-open-in-new-workspace + :desc "Open in new workspace" "" #'+vertico/embark-open-in-new-workspace)))) (use-package! marginalia