diff --git a/modules/completion/corfu/README.org b/modules/completion/corfu/README.org index b9c0b0b96..b282f90ef 100644 --- a/modules/completion/corfu/README.org +++ b/modules/completion/corfu/README.org @@ -89,6 +89,8 @@ is visible, the following relevant keys are available: | [[kbd:][M-m]] | Export to minibuffer (if [[doom-module::completion vertico]]) | | [[kbd:][M-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) | | [[kbd:][RET]] | Insert candidate | +| [[kbd:][C-RET]] | (in minibuffer) Finish minibuffer without inserting candidate | +| [[kbd:][S-RET]] | (in minibuffer) Finish minibuffer after inserting candidate | | [[kbd:][SPC]] | Quit autocompletion after a wildcard or pass-through | | [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) | | [[kbd:][C-SPC]] | (when completing) Insert separator DWIM (see below) | @@ -141,9 +143,8 @@ A few variables may be set to change behavior of this module: recommended to leave it at that. Otherwise, single matches on snippet keys expand immediately. - [[var:+corfu-buffer-scanning-size-limit]] :: - Sets the maximum buffer size to be scanned by ~cape-dabbrev~ and - ~cape-lines~. Defaults to 1 MB. Set this if you are having performance - problems using either CAPF. + Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1 + MB. Set this if you are having performance problems using the CAPF. ** Adding CAPFs to a mode To add other CAPFs on a mode-per-mode basis, put either of the following in your diff --git a/modules/completion/corfu/autoload.el b/modules/completion/corfu/autoload.el index 618aae42d..841802596 100644 --- a/modules/completion/corfu/autoload.el +++ b/modules/completion/corfu/autoload.el @@ -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. diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index 1c32a7c2b..5337a1da1 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -1,10 +1,7 @@ ;;; completion/corfu/config.el -*- lexical-binding: t; -*- (defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB - "Size limit for a buffer to be scanned by `cape-line' or `cape-dabbrev'. - -As an exception, `cape-line' will also scan buffers with the same -major mode regardless of size.") + "Size limit for a buffer to be scanned by `cape-dabbrev'.") ;; ;;; Packages @@ -37,12 +34,6 @@ major mode regardless of size.") tab-always-indent (if (modulep! +tng) 'complete tab-always-indent)) (add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles))) - (add-hook! corfu-mode - (defun +corfu-mode-unbinds () - ;; In `corfu-mode', unbind C-SPC from `global-map', so Emacs keeps searching. - (make-local-variable 'global-map) - (unbind-key "C-SPC" 'global-map))) - (add-hook! 'minibuffer-setup-hook (defun +corfu-enable-in-minibuffer () "Enable Corfu in the minibuffer if `completion-at-point' is bound." diff --git a/modules/config/default/config.el b/modules/config/default/config.el index 58befa14f..e34c465ab 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -475,8 +475,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 + :gi "C-" '(menu-item "Conclude the minibuffer" exit-minibuffer + :enable (active-minibuffer-window)) + :gi "S-" '(menu-item "Insert completion and conclude" +corfu-complete-and-exit-minibuffer + :enable (active-minibuffer-window)))) (when-let ((cmds-del (and (modulep! :completion corfu +tng) (cmds! (and (> corfu--index -1) (eq corfu-preview-current 'insert))