feat(vertico): better crm interface

This commit is contained in:
Itai Y. Efrat 2021-07-31 10:43:00 +03:00
parent 099a4ac8ff
commit 4c3c027a96
3 changed files with 30 additions and 1 deletions

View file

@ -18,6 +18,7 @@
- [[#general][General]] - [[#general][General]]
- [[#jump-to-files-buffers-or-projects][Jump to files, buffers or projects]] - [[#jump-to-files-buffers-or-projects][Jump to files, buffers or projects]]
- [[#search][Search]] - [[#search][Search]]
- [[#consult-modifications][Consult modifications]]
- [[#marginalia][Marginalia]] - [[#marginalia][Marginalia]]
- [[#orderless-filtering][Orderless filtering]] - [[#orderless-filtering][Orderless filtering]]
- [[#configuration][Configuration]] - [[#configuration][Configuration]]
@ -182,6 +183,14 @@ or the last workspace by typing =0 SPC=.
| =SPC s P= | Search another project | | =SPC s P= | Search another project |
| =SPC s s= | Search the current buffer (incrementally) | | =SPC s s= | Search the current buffer (incrementally) |
** Consult modifications
This module modifies the default keybindings used in
~consult-completing-read-multiple~:
| Keybind | Description |
|---------+-------------------------------------------------------------|
| =TAB= | Select or deselect current candidate |
| =RET= | Enters selected candidates (also toggles current candidate) |
** Marginalia ** Marginalia
| Keybind | Description | | Keybind | Description |
|---------+---------------------------------| |---------+---------------------------------|

View file

@ -237,3 +237,20 @@ targets."
(if (cdr targets) "" ""))) (if (cdr targets) "" "")))
(if prefix (lookup-key keymap prefix) keymap) (if prefix (lookup-key keymap prefix) keymap)
nil nil t)))) nil nil t))))
;;;###autoload
(defun +vertico/crm-select ()
"Enter candidate in `consult-completing-read-multiple'"
(interactive)
(let ((idx vertico--index))
(unless (get-text-property 0 'consult--crm-selected (nth vertico--index vertico--candidates))
(setq idx (1+ idx)))
(run-at-time 0 nil (cmd! (vertico--goto idx) (vertico--exhibit))))
(vertico-exit))
;;;###autoload
(defun +vertico/crm-exit ()
"Enter candidate in `consult-completing-read-multiple'"
(interactive)
(run-at-time 0 nil #'vertico-exit)
(vertico-exit))

View file

@ -118,7 +118,10 @@ overrides `completion-styles' during company completion sessions.")
:category buffer :category buffer
:state ,#'consult--buffer-state :state ,#'consult--buffer-state
:items ,(lambda () (mapcar #'buffer-name (org-buffer-list))))) :items ,(lambda () (mapcar #'buffer-name (org-buffer-list)))))
(add-to-list 'consult-buffer-sources '+vertico--consult-org-source 'append))) (add-to-list 'consult-buffer-sources '+vertico--consult-org-source 'append))
(map! :map consult-crm-map
:desc "Select candidate" "TAB" #'+vertico/crm-select
:desc "Enter candidates" "RET" #'+vertico/crm-exit))
(use-package! consult-flycheck (use-package! consult-flycheck