feat(evil): vim completion keybinds on C-x

Vim has a set of completion commands bound to the C-x prefix. We had
this for company, but with this commit, we now have them for the corfu
module.
This commit is contained in:
Henrik Lissner 2024-07-12 19:05:31 -04:00
parent 8ab42fa774
commit ce84690dc5
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 32 additions and 12 deletions

View file

@ -37,3 +37,13 @@
(save-excursion (backward-char 1)
(insert-char ?\\)))
(t (call-interactively #'corfu-insert-separator))))
;;;###autoload
(defun +corfu/dabbrev-this-buffer ()
"Like `cape-dabbrev', but only scans current buffer."
(interactive)
(require 'cape)
(let ((cape-dabbrev-check-other-buffers nil))
(cape-dabbrev t)))
;;; end of autoload.el

View file

@ -576,15 +576,25 @@ directives. By default, this only recognizes C directives.")
:v "gl" #'evil-lion-left
:v "gL" #'evil-lion-right
;; Omni-completion
(:when (modulep! :completion company)
(:prefix "C-x"
:i "C-l" #'+company/whole-lines
:i "C-k" #'+company/dict-or-keywords
:i "C-f" #'company-files
:i "C-]" #'company-etags
:i "s" #'company-ispell
:i "C-s" #'company-yasnippet
:i "C-o" #'company-capf
:i "C-n" #'+company/dabbrev
:i "C-p" #'+company/dabbrev-code-previous)))
;; Emulation of Vim's omni-completion keybinds
(:prefix "C-x"
(:when (modulep! :completion company)
:i "C-l" #'+company/whole-lines
:i "C-k" #'+company/dict-or-keywords
:i "C-f" #'company-files
:i "C-]" #'company-etags
:i "s" #'company-ispell
:i "C-s" #'company-yasnippet
:i "C-o" #'company-capf
:i "C-n" #'+company/dabbrev
:i "C-p" #'+company/dabbrev-code-previous)
(:when (modulep! :completion corfu)
:i "C-l" #'cape-line
:i "C-k" #'cape-keyword
:i "C-f" #'cape-file
:i "C-]" #'complete-tag
:i "s" #'cape-dict
:i "C-s" #'yasnippet-capf
:i "C-o" #'completion-at-point
:i "C-n" #'cape-dabbrev
:i "C-p" #'+corfu/dabbrev-this-buffer)))