feat(corfu): vim-like C-n/C-p keybinds
In vim/evil, C-n/C-p invokes dabbrev, so we're doing the same, but powered by cape-dabbrev, falling back to corfu-next/corfu-prev is a corfu popup is already open. Close: #7748 Co-authored-by: 45mg <45mg@users.noreply.github.com> Co-authored-by: LemonBreezes <LemonBreezes@users.noreply.github.com>
This commit is contained in:
parent
4a4a9a1ada
commit
08f8f57e2f
2 changed files with 30 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue