feat(corfu): impl smart confirm in minibuffer
An issue when using corfu in the minibuffer was the need for pressing RET twice, since the first only inserts the completion. This commit aliviates that by providing C-RET to ignore completion and conclude the minibuffer imediately and S-RET to insert completion then conclude.
This commit is contained in:
parent
14a3eaaa02
commit
a5db530622
3 changed files with 37 additions and 2 deletions
|
@ -103,6 +103,29 @@ following additional binds:
|
|||
| [[kbd:][S-TAB]] | (when completing) Go to previous candidate |
|
||||
| [[kbd:][DEL]] | (when completing) Reset completion DWIM-style |
|
||||
|
||||
*** Completion in the minibuffer
|
||||
In the minibuffer, sometimes autocompletion can interfere with your goal;
|
||||
Imagine you're composing a search pattern incrementally, and you find what you
|
||||
want early, with only half the word. You then press [[kbd:RET]]. If completion
|
||||
kicked in as you typed, you may lose the match, since it will complete the
|
||||
first candidate. On the other hand, if you were paying attention to the
|
||||
suggestions and selecting one appropriate, that's desired behavior, and you may
|
||||
even desire to modify the prompt further (if you were composing a command
|
||||
instead, you may want to extend it after the candidate). To allow better
|
||||
control, there are 3 confirm bindings when Corfu appears in the minibuffer:
|
||||
|
||||
| Keybind | Description |
|
||||
|-----------+--------------------------------------------------------------------|
|
||||
| [[kbd:RET]] | Accept the candidate only |
|
||||
| [[kbd:C-RET]] | Confirm the current prompt only |
|
||||
| [[kbd:S-RET]] | Accept the candidate then immediately confirm the completed prompt |
|
||||
|
||||
- Use [[kbd:RET]] when you want to continue composing after completing;
|
||||
- Use [[kbd:C-RET]] when you already have the desired string, and completing would
|
||||
break it;
|
||||
- Use [[kbd:S-RET]] when you know the composition will be finished after completion
|
||||
(thus avoiding the need to type [[kbd:RET]] twice);
|
||||
|
||||
** Searching with multiple keywords
|
||||
If the [[doom-module::completion corfu +orderless]] flag is enabled, users can
|
||||
perform code completion with multiple search keywords by use of space as the
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
;;; completion/corfu/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +corfu-complete-and-exit-minibuffer ()
|
||||
(interactive)
|
||||
(if (>= corfu--index 0)
|
||||
(corfu-complete)
|
||||
(corfu-insert))
|
||||
(exit-minibuffer))
|
||||
|
||||
;;;###autoload
|
||||
(defun +corfu-move-to-minibuffer ()
|
||||
;; Taken from corfu's README.
|
||||
|
|
|
@ -480,8 +480,12 @@ Continues comments if executed from a commented line. Consults
|
|||
"C-S-p" #'corfu-popupinfo-scroll-down
|
||||
"C-S-n" #'corfu-popupinfo-scroll-up
|
||||
"C-S-u" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-down corfu-popupinfo-min-height))
|
||||
"C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height))))
|
||||
|
||||
"C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height)))
|
||||
(:map corfu-map
|
||||
"C-<return>" '(menu-item "Conclude the minibuffer" exit-minibuffer
|
||||
:enable (minibufferp nil t))
|
||||
"S-<return>" '(menu-item "Insert completion and conclude" +corfu-complete-and-exit-minibuffer
|
||||
:enable (minibufferp nil t))))
|
||||
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
|
||||
'(menu-item "Reset completion" corfu-reset
|
||||
:enable (and (> corfu--index -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue