fix(corfu): move binds to :config default

Bindings were moved to the `:config default` module and some keys were
adjusted to match Company/other modules. The changes were documented in
the README.
This commit is contained in:
Luigi Sartor Piucco 2023-12-11 19:12:54 -03:00
parent b3bd325000
commit 14a3eaaa02
No known key found for this signature in database
GPG key ID: 6FF1A01853A47A66
5 changed files with 150 additions and 74 deletions

View file

@ -511,7 +511,7 @@
"C-x C-b" #'ibuffer
"C-x K" #'doom/kill-this-buffer-in-all-windows
;;; company-mode
;;; completion (in-buffer)
(:when (modulep! :completion company)
"C-;" #'+company/complete
(:after company
@ -537,6 +537,13 @@
"C-p" #'company-search-repeat-backward
"C-s" (cmd! (company-search-abort) (company-filter-candidates))))
(:when (modulep! :completion corfu)
:after corfu
(:map corfu-mode-map
"C-M-i" #'completion-at-point)
(:map corfu-popupinfo-map
"C-S-h" #'corfu-popupinfo-toggle))
;;; ein notebooks
(:after ein:notebook-multilang
:map ein:notebook-multilang-mode-map

View file

@ -43,7 +43,10 @@
#'yas-expand
(and (bound-and-true-p company-mode)
(modulep! :completion company +tng))
#'company-indent-or-complete-common)
#'company-indent-or-complete-common
(and (bound-and-true-p corfu-mode)
(modulep! :completion corfu +tng))
#'completion-at-point)
:m [tab] (cmds! (and (modulep! :editor snippets)
(evil-visual-state-p)
(or (eq evil-visual-selection 'line)
@ -127,7 +130,7 @@
;;
;;; Module keybinds
;;; :completion
;;; :completion (in-buffer)
(map! (:when (modulep! :completion company)
:i "C-@" (cmds! (not (minibufferp)) #'company-complete-common)
:i "C-SPC" (cmds! (not (minibufferp)) #'company-complete-common)
@ -156,7 +159,39 @@
"C-s" #'company-filter-candidates
[escape] #'company-search-abort)))
(:when (modulep! :completion ivy)
(:when (modulep! :completion corfu)
(:after corfu
(:map corfu-mode-map
:e "C-M-i" #'completion-at-point
(:prefix "C-x"
:i "C-l" #'cape-line
:i "C-k" #'cape-keyword
:i "C-f" #'cape-file
:i "s" #'cape-dict
:i "C-s" #'yasnippet-capf
:i "C-n" #'cape-dabbrev
:i "C-p" #'cape-history)
(:unless (modulep! :completion corfu +tng)
:i "C-SPC" #'completion-at-point
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
(call-interactively #'completion-at-point))
:v "C-SPC" (cmd! (call-interactively #'evil-change)
(call-interactively #'completion-at-point))))
(:map corfu-map
"C-u" (cmd! (let (corfu-cycle)
(funcall-interactively #'corfu-next (- corfu-count))))
"C-d" (cmd! (let (corfu-cycle)
(funcall-interactively #'corfu-next corfu-count)))))
(:after corfu-popupinfo
:map corfu-popupinfo-map
;; Reversed because popupinfo assumes opposite of what feels intuitive
;; with evil.
"C-S-k" #'corfu-popupinfo-scroll-down
"C-S-j" #'corfu-popupinfo-scroll-up
"C-h" #'corfu-popupinfo-toggle)))
;;; :completion (separate)
(map! (:when (modulep! :completion ivy)
(:after ivy
:map ivy-minibuffer-map
"C-SPC" #'ivy-call-and-recenter ; preview file
@ -169,7 +204,8 @@
[C-return] #'+ivy/git-grep-other-window-action))
(:when (modulep! :completion helm)
(:after helm :map helm-map
(:after helm
:map helm-map
[remap next-line] #'helm-next-line
[remap previous-line] #'helm-previous-line
[left] #'left-char

View file

@ -458,6 +458,39 @@ Continues comments if executed from a commented line. Consults
'(evil-ex-completion-map)))
"C-s" command))
(map! :when (modulep! :completion corfu)
:after corfu
(:map corfu-map
[return] #'corfu-insert
"RET" #'corfu-insert
"C-S-s" #'+corfu-move-to-minibuffer
"C-p" #'corfu-previous
"C-n" #'corfu-next
(:when (modulep! :completion corfu +orderless)
[remap completion-at-point] #'+corfu-smart-sep-toggle-escape)
(:when (modulep! :completion corfu +tng)
[tab] #'corfu-next
"TAB" #'corfu-next
[backtab] #'corfu-previous
"S-TAB" #'corfu-previous))
(:after corfu-popupinfo
:map corfu-popupinfo-map
"C-<up>" #'corfu-popupinfo-scroll-down
"C-<down>" #'corfu-popupinfo-scroll-up
"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))))
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
'(menu-item "Reset completion" corfu-reset
:enable (and (> corfu--index -1)
(eq corfu-preview-current 'insert))))))
(map! :after corfu
:map corfu-map
[backspace] cmds-del
"DEL" cmds-del))
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
;; Pressing it again will send you to the true bol. Same goes for C-e, except
;; it will ignore comments+trailing whitespace before jumping to eol.