From 0c603895a30238e5fae19484738aad5af9d7d0cc Mon Sep 17 00:00:00 2001 From: StrawberryTea Date: Thu, 30 Jan 2025 16:49:31 -0500 Subject: [PATCH] default: add omnicompletion bindings to minibuffer This commit adds omnicompletion bindings to the minibuffer. This is only done for Corfu because we do not currently enable Company in the minibuffer. This is primarily because sometimes I want to insert a file name into the minibuffer and want to do so with C-x C-f. If you have any suggestions on improving this, please comment below. Not all the bindings are added, because some of them do not make sense in the minibuffer unless you wrap them with special forms. --- lisp/doom-keybinds.el | 15 +++++++++++++++ modules/config/default/config.el | 17 +---------------- modules/editor/evil/config.el | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index 144d6b64c4c..551f54d217a 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -31,6 +31,21 @@ and Emacs states, and for non-evil users.") (defvar doom-leader-map (make-sparse-keymap) "An overriding keymap for keys.") +(defvar doom-minibuffer-maps + (append '(minibuffer-local-map + minibuffer-local-ns-map + minibuffer-local-completion-map + minibuffer-local-must-match-map + minibuffer-local-isearch-map + read-expression-map) + (cond ((modulep! :completion ivy) + '(ivy-minibuffer-map + ivy-switch-buffer-map)) + ((modulep! :completion helm) + '(helm-map + helm-rg-map + helm-read-file-map)))) + "A list of all the keymaps used for the minibuffer.") ;; ;;; Global keybind settings diff --git a/modules/config/default/config.el b/modules/config/default/config.el index cf399b3b308..027b8bd8566 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -3,22 +3,7 @@ (defvar +default-want-RET-continue-comments t "If non-nil, RET will continue commented lines.") -(defvar +default-minibuffer-maps - (append '(minibuffer-local-map - minibuffer-local-ns-map - minibuffer-local-completion-map - minibuffer-local-must-match-map - minibuffer-local-isearch-map - read-expression-map) - (cond ((modulep! :completion ivy) - '(ivy-minibuffer-map - ivy-switch-buffer-map)) - ((modulep! :completion helm) - '(helm-map - helm-rg-map - helm-read-file-map)))) - "A list of all the keymaps used for the minibuffer.") - +(defvaralias '+default-minibuffer-maps 'doom-minibuffer-maps) ;; ;;; Reasonable defaults diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index cf31557440a..e9ef32e8c2c 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -581,3 +581,17 @@ directives. By default, this only recognizes C directives.") :i "C-o" #'completion-at-point :i "C-n" #'cape-dabbrev :i "C-p" #'+corfu/dabbrev-this-buffer)))) + + +(unless evil-disable-insert-state-bindings + (when (modulep! :completion corfu) + (define-key! + :keymaps (append doom-minibuffer-maps + (when (modulep! :editor evil +everywhere) + '(evil-ex-completion-map))) + "C-x C-f" #'cape-file + "C-x s" #'cape-dict + "C-x C-s" #'yasnippet-capf + "C-x C-o" #'completion-at-point + "C-x C-n" #'cape-dabbrev + "C-x C-p" #'+corfu/dabbrev-this-buffer)))