commit 6761daf7065c850514d071728b0c9f8ed892b117
parent 5e3d0375598bdf6352f7a9fe61ee2656c9402aef
Author: Lukas Henkel <lh@entf.net>
Date: Sat, 9 Apr 2022 13:23:00 +0200
When pressing return and no completion is selected, insert newline
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/init.el b/init.el
@@ -46,7 +46,6 @@
(delete-selection-mode 1)
(which-key-mode 1)
(marginalia-mode 1)
-(corfu-global-mode 1)
(global-aggressive-indent-mode 1)
(diminish 'which-key-mode)
@@ -153,6 +152,18 @@
(("G" . elfeed-update))
elfeed)
+(defun corfu-insert-with-return ()
+ (interactive)
+ (let ((idx corfu--index))
+ (corfu-insert)
+ (when (< idx 0)
+ (newline)
+ (indent-according-to-mode))))
+
+(lh/define-keys corfu-map
+ (("RET" . corfu-insert-with-return))
+ corfu)
+
(add-hook 'lisp-mode-hook #'paredit-mode)
(add-hook 'emacs-lisp-mode-hook #'paredit-mode)