diff --git a/modules/completion/corfu/autoload.el b/modules/completion/corfu/autoload.el index 7f01018b2..00852e48c 100644 --- a/modules/completion/corfu/autoload.el +++ b/modules/completion/corfu/autoload.el @@ -60,4 +60,32 @@ (message "Corfu auto-complete %s" (if corfu-auto "disabled" "enabled"))) (setq corfu-auto (not corfu-auto))) +;;;###autoload +(defun +corfu/dabbrev-or-next (&optional arg) + "Trigger corfu popup and select the first candidate. + +Intended to mimic `evil-complete-next', unless the popup is already open." + (interactive "p") + (if corfu--candidates + (corfu-next arg) + (require 'cape) + (let ((cape-dabbrev-check-other-buffers (not evil-complete-all-buffers))) + (cape-dabbrev t) + (when (> corfu--total 0) + (corfu--goto (or arg 0)))))) + +;;;###autoload +(defun +corfu/dabbrev-or-last (&optional arg) + "Trigger corfu popup and select the first candidate. + +Intended to mimic `evil-complete-previous', unless the popup is already open." + (interactive "p") + (if corfu--candidates + (corfu-previous arg) + (require 'cape) + (let ((cape-dabbrev-check-other-buffers (not evil-complete-all-buffers))) + (cape-dabbrev t) + (when (> corfu--total 0) + (corfu--goto (- corfu--total (or arg 1))))))) + ;;; end of autoload.el diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 4e3fa545a..01a9e196d 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -192,6 +192,8 @@ (:after corfu (:map corfu-mode-map :i "C-SPC" #'completion-at-point + :i "C-n" #'+corfu/dabbrev-or-next + :i "C-p" #'+corfu/dabbrev-or-last :n "C-SPC" (cmd! (call-interactively #'evil-insert-state) (call-interactively #'completion-at-point)) :v "C-SPC" (cmd! (call-interactively #'evil-change)