feat(config): add smart-ret for corfu

This commit makes RET in Corfu quit auto-completion and passthrough to
the underlying keymap if no completion is selected.
This commit is contained in:
StrawberryTea 2024-02-19 23:44:58 -06:00 committed by Luigi Sartor Piucco
parent 881c45bd05
commit 16c4daee52
No known key found for this signature in database
GPG key ID: 6FF1A01853A47A66

View file

@ -461,8 +461,6 @@ Continues comments if executed from a commented line. Consults
(map! :when (modulep! :completion corfu)
:after corfu
(:map corfu-map
[return] #'corfu-insert
"RET" #'corfu-insert
"C-S-s" #'+corfu-move-to-minibuffer
"C-p" #'corfu-previous
"C-n" #'corfu-next
@ -489,11 +487,19 @@ Continues comments if executed from a commented line. Consults
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
'(menu-item "Reset completion" corfu-reset
:enable (and (> corfu--index -1)
(eq corfu-preview-current 'insert))))))
(map! :after corfu
(eq corfu-preview-current 'insert)))))
(cmds-ret '(menu-item "Insert completion" corfu-insert
:filter (lambda (cmd)
(if (eq corfu--index -1)
(corfu-quit)
cmd)))))
(map! :when (modulep! :completion corfu)
:after corfu
:map corfu-map
[backspace] cmds-del
"DEL" cmds-del))
"DEL" cmds-del
:ig [return] cmds-ret
:ig "RET" cmds-ret))
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
;; Pressing it again will send you to the true bol. Same goes for C-e, except