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. Small formatting issues and
some apparently inintended nestings were corrected as well.
This commit is contained in:
Luigi Sartor Piucco 2023-12-11 19:12:54 -03:00
parent db34c67d20
commit 2f33f7760a
No known key found for this signature in database
GPG key ID: 6FF1A01853A47A66
5 changed files with 115 additions and 84 deletions

View file

@ -71,27 +71,26 @@ By default, completion gets triggered after typing 2 non-space consecutive
characters, or by means of the [[kbd:][C-SPC]] keybinding at any moment. While the popup
is visible, the following relevant keys are available:
| Keybind | Description |
|----------+------------------------------------------------------------------|
| [[kbd:][<down>]] | Go to next candidate |
| [[kbd:][<up>]] | Go to previous candidate |
| [[kbd:][C-n]] | Go to next candidate |
| [[kbd:][C-p]] | Go to previous candidate |
| [[kbd:][C-j]] | (evil) Go to next candidate |
| [[kbd:][C-k]] | (evil) Go to previous candidate |
| [[kbd:][C-<down>]] | Go to next doc line |
| [[kbd:][C-<up>]] | Go to previous doc line |
| [[kbd:][C-S-n]] | Go to next doc line |
| [[kbd:][C-S-p]] | Go to previous doc line |
| [[kbd:][C-S-j]] | (evil) Go to next doc line |
| [[kbd:][C-S-k]] | (evil) Go to previous doc line |
| [[kbd:][C-h]] | Toggle documentation (if available) |
| [[kbd:][M-m]] | Export to minibuffer (if [[doom-module::completion vertico]]) |
| [[kbd:][M-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) |
| [[kbd:][RET]] | Insert candidate |
| [[kbd:][SPC]] | Quit autocompletion after a wildcard or pass-through |
| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) |
| [[kbd:][C-SPC]] | (when completing) Insert separator DWIM (see below) |
| Keybind | Description |
|----------+-----------------------------------------------------------|
| [[kbd:][<down>]] | Go to next candidate |
| [[kbd:][<up>]] | Go to previous candidate |
| [[kbd:][C-n]] | Go to next candidate |
| [[kbd:][C-p]] | Go to previous candidate |
| [[kbd:][C-j]] | (evil) Go to next candidate |
| [[kbd:][C-k]] | (evil) Go to previous candidate |
| [[kbd:][C-<down>]] | Go to next doc line |
| [[kbd:][C-<up>]] | Go to previous doc line |
| [[kbd:][C-S-n]] | Go to next doc line |
| [[kbd:][C-S-p]] | Go to previous doc line |
| [[kbd:][C-S-j]] | (evil) Go to next doc line |
| [[kbd:][C-S-k]] | (evil) Go to previous doc line |
| [[kbd:][C-h]] | Toggle documentation (if available) |
| [[kbd:][C-S-s]] | Export to minibuffer (if [[doom-module::completion vertico]]) |
| [[kbd:][RET]] | Insert candidate |
| [[kbd:][SPC]] | Quit autocompletion or pass-through after a wildcard |
| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) |
| [[kbd:][C-SPC]] | (when completing) Insert separator DWIM (see below) |
If you prefer a [[kbd:][TAB]]-centric completion style, enable the [[doom-module::completion
corfu +tng]] flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the

View file

@ -33,17 +33,6 @@
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
(map! :map corfu-mode-map
:e "C-M-i" #'completion-at-point
: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! :unless (modulep! :editor evil)
:map corfu-mode-map
"C-M-i" #'completion-at-point)
(add-hook! 'minibuffer-setup-hook
(defun +corfu-enable-in-minibuffer ()
"Enable Corfu in the minibuffer if `completion-at-point' is bound."
@ -57,32 +46,9 @@
(when (modulep! +icons)
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
(let ((cmds-del (cmds! (and (modulep! +tng)
(> corfu--index -1)
(eq corfu-preview-current 'insert))
#'corfu-reset)))
(map! :map corfu-map
[return] #'corfu-insert
"RET" #'corfu-insert
(:when (modulep! +orderless)
"<remap> <completion-at-point>" #'+corfu-smart-sep-toggle-escape)
(:when (modulep! +tng)
[tab] #'corfu-next
[backtab] #'corfu-previous
"TAB" #'corfu-next
"S-TAB" #'corfu-previous
[backspace] cmds-del
"DEL" cmds-del)))
(when (modulep! +orderless)
(after! orderless
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
(after! vertico
(map! :map corfu-map
"M-m" #'+corfu-move-to-minibuffer
(:when (modulep! :editor evil)
"M-J" #'+corfu-move-to-minibuffer))))
(setq orderless-component-separator #'orderless-escapable-split-on-space))))
(use-package! cape
:defer t
@ -176,16 +142,4 @@
(use-package! corfu-popupinfo
:hook ((corfu-mode . corfu-popupinfo-mode))
:config
(setq corfu-popupinfo-delay '(0.5 . 1.0))
(map! :map corfu-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-h" #'corfu-popupinfo-toggle)
(map! :when (modulep! :editor evil)
: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))
(setq corfu-popupinfo-delay '(0.5 . 1.0)))