refactor(corfu): settings and keybinding overhaul

Previously, a distinction was made only between "regular" style (assumed
to be for people who prefer to cycle directionally and commit with RET)
and +tng (assumed to be for people who prefer TAB and auto-commit). This
made composing further variations harder on the user, as they would have
to work around our bindings. Now we provide a flag per feature, and the
user can compose to their liking. Some variable options were turned into
flags and the global CAPF list was pruned, suggesting to use individual
keys for those functions if required.
This commit is contained in:
Luigi Sartor Piucco 2024-03-02 13:10:00 -03:00
parent 2bb5f29a01
commit 03f065df9f
No known key found for this signature in database
GPG key ID: 6FF1A01853A47A66
5 changed files with 149 additions and 171 deletions

View file

@ -8,7 +8,7 @@ This module provides code completion, powered by [[doom-package:corfu]].
It is recommended to enable either this or [[doom-module::completion company]], in It is recommended to enable either this or [[doom-module::completion company]], in
case you desire pre-configured auto-completion. Corfu is much lighter weight and case you desire pre-configured auto-completion. Corfu is much lighter weight and
focused, plus it's built on native Emacs functionality, whereas company is heavy focused, plus it's built on native Emacs functionality, whereas Company is heavy
and highly non-native, but has some extra features and more maturity. and highly non-native, but has some extra features and more maturity.
** Maintainers ** Maintainers
@ -19,21 +19,16 @@ and highly non-native, but has some extra features and more maturity.
** Module flags ** Module flags
- +icons :: - +icons ::
Display icons beside completion suggestions. Display icons beside completion suggestions.
- +tng ::
Known as Tab'n'Go to Company users, changes behavior to invoke completion on
[[kbd:][TAB]]. When Corfu is active, [[kbd:][TAB]] and [[kbd:][S-TAB]] will navigate the completion
candidates. Arrow keys and evil-style movement are still supported.
- +orderless :: - +orderless ::
Pull in [[doom-package:orderless]] if necessary and apply multi-component Pull in [[doom-package:orderless]] if necessary and apply multi-component
completion (still needed if [[doom-module::completion vertico]] is active). completion (still needed if [[doom-module::completion vertico]] is active).
- +dabbrev :: - +dabbrev ::
Enable and configure [[doom-package:dabbrev]] as a close-to-universal CAPF Enable and configure [[doom-package:dabbrev]] as a close-to-universal CAPF
fallback. fallback.
- +dict :: - +individual ::
Enable and configure dictionary completion for text modes and related regions Add bindings for specific CAPFs under the [[kbd:][C-x]] prefix.
in programming modes. - +on-type +on-ret +on-ret-pt +direction +tab ::
- +emoji :: Enable corresponding completion-style features. See [[*Usage]].
Enable and configure emoji completion via the emoji input method.
** Packages ** Packages
- [[doom-package:corfu]] - [[doom-package:corfu]]
@ -68,65 +63,87 @@ words. Snippets may also appear in the candidate list if available.
** Code completion ** Code completion
By default, completion gets triggered after typing 2 non-space consecutive 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 characters, by means of [[kbd:][C-SPC]] at any moment or [[kbd:][TAB]] on a line with proper
is visible, the following relevant keys are available: indentation. Many styles of completion are offered, which can be composed with
module flags to suit the user; they are described in subsections. The following
keybindings are generally available:
| Keybind | Description | | Keybind | Description |
|----------+-----------------------------------------------------------| |---------+---------------------------------------------|
| [[kbd:][<down>]] | Go to next candidate | | [[kbd:][C-n]] | Go to next candidate |
| [[kbd:][<up>]] | Go to previous candidate | | [[kbd:][C-p]] | Go to previous candidate |
| [[kbd:][C-n]] | Go to next candidate | | [[kbd:][C-u]] | (evil) Go to next candidate page |
| [[kbd:][C-p]] | Go to previous candidate | | [[kbd:][C-d]] | (evil) Go to previous candidate page |
| [[kbd:][C-j]] | (evil) Go to next candidate | | [[kbd:][C-S-n]] | Go to next doc line |
| [[kbd:][C-k]] | (evil) Go to previous candidate | | [[kbd:][C-S-p]] | Go to previous doc line |
| [[kbd:][C-<down>]] | Go to next doc line | | [[kbd:][C-S-h]] | (emacs) Toggle documentation (if available) |
| [[kbd:][C-<up>]] | Go to previous doc line | | [[kbd:][C-h]] | (evil) Toggle documentation (if available) |
| [[kbd:][C-S-n]] | Go to next doc line | | [[kbd:][C-S-s]] | Export to minibuffer |
| [[kbd:][C-S-p]] | Go to previous doc line | | [[kbd:][DEL]] | Reset completion DWIM |
| [[kbd:][C-S-j]] | (evil) Go to next doc line | | [[kbd:][TAB]] | (when not completing) Indent or complete |
| [[kbd:][C-S-k]] | (evil) Go to previous doc line | | [[kbd:][C-SPC]] | (when not completing) Complete |
| [[kbd:][C-h]] | Toggle documentation (if available) | | [[kbd:][C-M-i]] | (emacs) (when not completing) Complete |
| [[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 Bindings in the following sections are additive, and get enabled by the
corfu +tng]] flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the corresponding module flags. Additionally, for users of evil [[kdb:][C-SPC]] is smart
following additional binds: regarding your state. In normal-like states, enter insert then start corfu; in
visual-like states, perform [[help:evil-change][evil-change]] (which leaves you in insert state) then
start corfu; in insert-like states, start corfu immediatelly.
| Keybind | Description | ** Commit on type (~+on-type~)
|---------+-----------------------------------------------| When the completion popup is visible and the current candidate is previewed into
| [[kbd:][TAB]] | Complete | the buffer, further input commits that candidate as previewed. Note it does not
| [[kbd:][TAB]] | (when completing) Go to next candidate | perform candidate exit actions, such as expanding snippets. This is intended for
| [[kbd:][S-TAB]] | (when completing) Go to previous candidate | people who prefer to leave [[kbd:][RET]] free.
| [[kbd:][DEL]] | (when completing) Reset completion DWIM-style |
*** Completion in the minibuffer ** Commit on [[kbd:][RET]] (~+on-ret~)
In the minibuffer, sometimes autocompletion can interfere with your goal; Some people prefer to use [[kbd:][RET]] to commit, so here we bind it to Corfu's insertion
Imagine you're composing a search pattern incrementally, and you find what you function. Note that Corfu allows "no candidate" to be selected, and in that
want early, with only half the word. You then press [[kbd:RET]]. If completion case, it will just quit without inserting. To make it less obtrusive by default,
kicked in as you typed, you may lose the match, since it will complete the the popup starts in this unselected state. See [[var:corfu-preselect]] to alter this
first candidate. On the other hand, if you were paying attention to the behavior; it can start with the first candidate selected, for instance.
suggestions and selecting one appropriate, that's desired behavior, and you may
even desire to modify the prompt further (if you were composing a command
instead, you may want to extend it after the candidate). To allow better
control, there are 3 confirm bindings when Corfu appears in the minibuffer:
| Keybind | Description | | Keybind | Description |
|-----------+--------------------------------------------------------------------| |---------+--------------------------|
| [[kbd:RET]] | Accept the candidate only | | [[kbd:][RET]] | Insert candidate or quit |
| [[kbd:C-RET]] | Confirm the current prompt only |
| [[kbd:S-RET]] | Accept the candidate then immediately confirm the completed prompt |
- Use [[kbd:RET]] when you want to continue composing after completing; ** Commit on [[kbd:][RET]] with pass-through (~+on-ret-pt~)
- Use [[kbd:C-RET]] when you already have the desired string, and completing would This enables [[kbd:][RET]] to work as a finisher like above. The difference is that
break it; without a current candidate, after quitting it passes-through to whatever action
- Use [[kbd:S-RET]] when you know the composition will be finished after completion would have happened normally. So if you're in the minibuffer composing a shell
(thus avoiding the need to type [[kbd:RET]] twice); command and press [[kbd:][RET]], unless a candidate is selected, it quits completion then
commits the minibuffer automatically. Contrast to the above, you would need to
press twice to commit. [[var:corfu-preselect]] is important here, as having the
first candidate from the start prevents the pass-through.
** Searching with multiple keywords | Keybind | Description |
|---------+-------------------------------------------|
| [[kbd:][RET]] | Insert candidate or quit and pass-through |
** Cycle directionally (~+direction~)
If you'd rather think in directions rather than next/previous, enable arrow keys
and vi movements to control the selection and documentation view.
| Keybind | Description |
|----------+---------------------------------|
| [[kbd:][<down>]] | Go to next candidate |
| [[kbd:][<up>]] | 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-j]] | (evil) Go to next doc line |
| [[kbd:][C-S-k]] | (evil) Go to previous doc line |
** Cycle with [[kbd:][TAB]] (~+tab~)
Binds [[kbd:][TAB]]-based cycling alternatives.
| Keybind | Description |
|---------+--------------------------|
| [[kbd:][TAB]] | Go to next candidate |
| [[kbd:][S-TAB]] | Go to previous candidate |
** Searching with multiple keywords (~+orderless~)
If the [[doom-module::completion corfu +orderless]] flag is enabled, users can If the [[doom-module::completion corfu +orderless]] flag is enabled, users can
perform code completion with multiple search keywords by use of space as the perform code completion with multiple search keywords by use of space as the
separator. More information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while separator. More information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while
@ -139,28 +156,19 @@ backslash, including the space in the search term, and pressing it with an
already escaped separator before point deletes it. Thus, you can cycle back if already escaped separator before point deletes it. Thus, you can cycle back if
you accidentaly press more than needed. you accidentaly press more than needed.
Additionally, for users of evil and regular corfu style, [[kdb:][C-SPC]] is smart | Keybind | Description |
regarding your state. In normal-like states, enter insert then start corfu; in |---------+------------------------------------------------------|
visual-like states, perform [[help:evil-change][evil-change]] (which leaves you in insert state) then | [[kbd:][C-SPC]] | (when completing) Insert separator DWIM |
start corfu; in insert-like states, start corfu immediatelly. | [[kbd:][SPC]] | Quit autocompletion or insert space after a wildcard |
** Exporting to the minibuffer ** Manually call generic CAPFs (~+individual~)
The entries shown in the completion popup can be exported to a ~completing-read~
minibuffer, giving access to all the manipulations that suite allows. Using
Vertico for instance, one could use this to export with [[doom-package:embark]] via
[[kbd:][C-c C-l]] and get a buffer with all candidates.
** Manually call generic CAPFs
Completion at point functions have the property that, when called interactively Completion at point functions have the property that, when called interactively
via their symbol, they work as a call to ~completion-at-point~ where via their symbol, they work as a call to ~completion-at-point~ where
[[var:completion-at-point-functions]] is bound to that CAPF alone. This allows to [[var:completion-at-point-functions]] is bound to that CAPF alone. This allows to
assign generic functions to a binding and call as needed, leaving the default assign generic functions to a binding and call as needed, leaving the default
value used for most completion tasks much leaner (thus, faster and easier to value used for most completion tasks much leaner (thus, faster and easier to
look through). This module provides some such bindings for Evil users (see the look through). This module provides some such bindings for those who enable the
table below), and you're free map your own of course. Emacs users have to map it ~+individual~ module flag. They are listed below:
themselves for now, due to the author's lack of knowledge on ergonomic
equivalents to the Evil ones. If you have suggestions, though, we'd be happy to
know!
| Keybind | Description | | Keybind | Description |
|---------+---------------------------------| |---------+---------------------------------|
@ -172,6 +180,12 @@ know!
| [[kbd:][C-x]] [[kbd:][C-n]] | (insert-state) ~cape-dabbrev~ | | [[kbd:][C-x]] [[kbd:][C-n]] | (insert-state) ~cape-dabbrev~ |
| [[kbd:][C-x]] [[kbd:][C-p]] | (insert-state) ~cape-history~ | | [[kbd:][C-x]] [[kbd:][C-p]] | (insert-state) ~cape-history~ |
** Exporting to the minibuffer
The entries shown in the completion popup can be exported to another
~completion-in-region~ minibuffer, giving access to all the manipulations those
suites allow. Using Vertico for instance, one could use this to export with
[[doom-package:embark]] via [[kbd:][C-c C-l]] and get a buffer with all candidates.
* Configuration * Configuration
A few variables may be set to change behavior of this module: A few variables may be set to change behavior of this module:
@ -191,15 +205,16 @@ A few variables may be set to change behavior of this module:
- [[var:corfu-auto-prefix]] :: - [[var:corfu-auto-prefix]] ::
Number of characters till auto-completion starts to happen. Defaults to 2. Number of characters till auto-completion starts to happen. Defaults to 2.
- [[var:corfu-on-exact-match]] :: - [[var:corfu-on-exact-match]] ::
Configures behavior for exact matches. Its default is nil, and it's Configures behavior for exact matches.
recommended to leave it at that. Otherwise, single matches on snippet keys - [[var:corfu-preselect]] ::
expand immediately. Configures startup selection, choosing between the first candidate or the
prompt.
- [[var:+corfu-buffer-scanning-size-limit]] :: - [[var:+corfu-buffer-scanning-size-limit]] ::
Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1 Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1
MB. Set this if you are having performance problems using the CAPF. MB. Set this if you are having performance problems using the CAPF.
- [[var:+corfu-want-C-x-bindings]] :: - [[var:+corfu-want-minibuffer-completion]] ::
Enables autocompletion backends to be bound under the ~C-x~ prefix. This Enables Corfu in the minibuffer, where it may be obtrusive. May also be set
overrides some built-in Emacs keybindings. to ~aggresive~ to enable even in some places without ~completion-at-point~.
** Adding CAPFs to a mode ** Adding CAPFs to a mode
To add other CAPFs on a mode-per-mode basis, put either of the following in your To add other CAPFs on a mode-per-mode basis, put either of the following in your
@ -222,11 +237,11 @@ To add other CAPFs to keys, adapt the snippet below into your ~config.el~:
;; after some-mode-hook runs. Line 2 is needed only if the binding can't leak ;; after some-mode-hook runs. Line 2 is needed only if the binding can't leak
;; into other Corfu buffers. When neither of the above make sense, the `map!' ;; into other Corfu buffers. When neither of the above make sense, the `map!'
;; call is enough. ;; call is enough.
(add-hook! some-mode ; Only needed if the binding is mode-specific (add-hook! some-mode
(make-local-variable 'corfu-mode-map) (make-local-variable 'corfu-mode-map)
(map! :map corfu-mode-map (map! :map corfu-mode-map
:prefix "C-x" ; C-x is usually used as prefix, but it's not required :prefix "C-x" ; C-x is usually used as prefix, but it's not required
"e" #'cape-emoji)) ; Evil users probably want :i to avoid this in other states "e" #'cape-emoji)) ; Evil users probably want :i to avoid this in other states
#+end_src #+end_src
* Troubleshooting * Troubleshooting

View file

@ -1,13 +1,5 @@
;;; completion/corfu/autoload.el -*- lexical-binding: t; -*- ;;; completion/corfu/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +corfu-complete-and-exit-minibuffer ()
(interactive)
(if (>= corfu--index 0)
(corfu-complete)
(corfu-insert))
(exit-minibuffer))
;;;###autoload ;;;###autoload
(defun +corfu-move-to-minibuffer () (defun +corfu-move-to-minibuffer ()
"Move the current list of candidates to your choice of minibuffer completion UI." "Move the current list of candidates to your choice of minibuffer completion UI."

View file

@ -3,9 +3,6 @@
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB (defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
"Size limit for a buffer to be scanned by `cape-dabbrev'.") "Size limit for a buffer to be scanned by `cape-dabbrev'.")
(defvar +corfu-want-C-x-bindings t
"Whether `C-x' is a completion prefix in Evil insert state.")
(defvar +corfu-want-minibuffer-completion t (defvar +corfu-want-minibuffer-completion t
"Whether to enable Corfu in the minibuffer. "Whether to enable Corfu in the minibuffer.
Setting this to `aggressive' will enable Corfu in more commands which Setting this to `aggressive' will enable Corfu in more commands which
@ -50,22 +47,17 @@ use the minibuffer such as `query-replace'.")
t) t)
corfu-cycle t corfu-cycle t
corfu-separator (when (modulep! +orderless) ?\s) corfu-separator (when (modulep! +orderless) ?\s)
corfu-preselect (if (modulep! +tng) 'prompt 'valid) corfu-preselect 'prompt
corfu-count 16 corfu-count 16
corfu-max-width 120 corfu-max-width 120
corfu-preview-current 'insert corfu-preview-current (if (modulep! +on-type) 'insert t)
corfu-on-exact-match nil corfu-on-exact-match nil
corfu-quit-at-boundary (if (modulep! +orderless) 'separator t) corfu-quit-at-boundary (if (modulep! +orderless) 'separator t)
corfu-quit-no-match (if (modulep! +orderless) 'separator t) corfu-quit-no-match (if (modulep! +orderless) 'separator t)
;; In the case of +tng, TAB should be smart regarding completion; tab-always-indent 'complete)
;; However, it should otherwise behave like normal, whatever normal was.
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles))) (add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
(add-to-list 'corfu-auto-commands #'lispy-colon) (add-to-list 'corfu-auto-commands #'lispy-colon)
(add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer) (add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer)
(add-hook 'evil-insert-state-exit-hook #'corfu-quit) (add-hook 'evil-insert-state-exit-hook #'corfu-quit)
(when (modulep! +icons) (when (modulep! +icons)
@ -116,28 +108,6 @@ use the minibuffer such as `query-replace'.")
"\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?") "\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?")
dabbrev-upcase-means-case-search t) dabbrev-upcase-means-case-search t)
(add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode))) (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)))
;; Complete emojis :).
(when (and (modulep! +emoji) (> emacs-major-version 28))
(add-hook! (prog-mode conf-mode)
(defun +corfu-add-cape-emoji-h ()
(add-hook 'completion-at-point-functions
(cape-capf-predicate (cape-capf-prefix-length #'cape-emoji 1)
#'+corfu-in-doc-or-comment-p)
10 t)))
(add-hook! text-mode
(defun +corfu-add-cape-emoji-text-h ()
(add-hook 'completion-at-point-functions
(cape-capf-prefix-length #'cape-emoji 1) 10 t))))
;; Enable dictionary-based autocompletion.
(when (modulep! +dict)
(add-hook! (prog-mode conf-mode)
(defun +corfu-add-cape-dict-h ()
(add-hook 'completion-at-point-functions
(cape-capf-predicate #'+corfu-in-doc-or-comment-p #'cape-dict)
40 t)))
(add-hook! text-mode
(defun +corfu-add-cape-dict-text-h ()
(add-hook 'completion-at-point-functions #'cape-dict 40 t))))
;; Make these capfs composable. ;; Make these capfs composable.
(advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive) (advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive)

View file

@ -163,15 +163,6 @@
(:after corfu (:after corfu
(:map corfu-mode-map (:map corfu-mode-map
:e "C-M-i" #'completion-at-point :e "C-M-i" #'completion-at-point
(:when +corfu-want-C-x-bindings
(: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) (:unless (modulep! :completion corfu +tng)
:i "C-SPC" #'completion-at-point :i "C-SPC" #'completion-at-point
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state) :n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
@ -187,8 +178,9 @@
:map corfu-popupinfo-map :map corfu-popupinfo-map
;; Reversed because popupinfo assumes opposite of what feels intuitive ;; Reversed because popupinfo assumes opposite of what feels intuitive
;; with evil. ;; with evil.
"C-S-k" #'corfu-popupinfo-scroll-down (:when (modulep! :completion corfu +direction)
"C-S-j" #'corfu-popupinfo-scroll-up "C-S-k" #'corfu-popupinfo-scroll-down
"C-S-j" #'corfu-popupinfo-scroll-up)
"C-h" #'corfu-popupinfo-toggle))) "C-h" #'corfu-popupinfo-toggle)))
;;; :completion (separate) ;;; :completion (separate)

View file

@ -460,56 +460,65 @@ Continues comments if executed from a commented line. Consults
(map! :when (modulep! :completion corfu) (map! :when (modulep! :completion corfu)
:after corfu :after corfu
(:map corfu-mode-map
:when (modulep! :completion corfu +individual)
:prefix "C-x"
:gi "C-l" #'cape-line
:gi "C-k" #'cape-keyword
:gi "C-f" #'cape-file
:gi "s" #'cape-dict
:gi "C-s" #'yasnippet-capf
:gi "C-n" #'cape-dabbrev
:gi "C-p" #'cape-history)
(:map corfu-map (:map corfu-map
"C-S-s" #'+corfu-move-to-minibuffer "C-S-s" #'+corfu-move-to-minibuffer
"C-p" #'corfu-previous "C-p" #'corfu-previous
"C-n" #'corfu-next "C-n" #'corfu-next
(:when (modulep! :completion corfu +orderless) (:when (modulep! :completion corfu +orderless)
[remap completion-at-point] #'+corfu-smart-sep-toggle-escape) [remap completion-at-point] #'+corfu-smart-sep-toggle-escape)
(:when (modulep! :completion corfu +tng) (:when (modulep! :completion corfu +tab)
:gi [tab] #'corfu-next :gi [tab] #'corfu-next
:gi "TAB" #'corfu-next :gi "TAB" #'corfu-next
:gi [backtab] #'corfu-previous :gi [backtab] #'corfu-previous
:gi "S-TAB" #'corfu-previous)) :gi "S-TAB" #'corfu-previous))
(:after corfu-popupinfo (:after corfu-popupinfo
:map corfu-popupinfo-map :map corfu-popupinfo-map
"C-<up>" #'corfu-popupinfo-scroll-down (:when (modulep! :completion corfu +direction)
"C-<down>" #'corfu-popupinfo-scroll-up "C-<up>" #'corfu-popupinfo-scroll-down
"C-<down>" #'corfu-popupinfo-scroll-up)
"C-S-p" #'corfu-popupinfo-scroll-down "C-S-p" #'corfu-popupinfo-scroll-down
"C-S-n" #'corfu-popupinfo-scroll-up "C-S-n" #'corfu-popupinfo-scroll-up
"C-S-u" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-down corfu-popupinfo-min-height)) "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))) "C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height))))
(:when (not (modulep! :completion corfu +tng)) (when-let ((cmds-del
(:map corfu-map `(menu-item "Reset completion" corfu-reset
"C-<return>" `(menu-item "Conclude the minibuffer" exit-minibuffer :filter ,(lambda (cmd)
:filter ,(lambda (cmd) (when (minibufferp nil t) cmd))) (interactive)
"S-<return>" `(menu-item "Insert completion and conclude" (when (and (>= corfu--index 0)
+corfu-complete-and-exit-minibuffer (eq corfu-preview-current 'insert))
:filter ,(lambda (cmd) (when (minibufferp nil t) cmd)))))) cmd))))
(when-let ((cmds-del (and (modulep! :completion corfu +tng) (cmds-ret-pt
`(menu-item "Reset completion" corfu-reset `(menu-item "Insert completion or pass-through" corfu-insert
:filter ,(lambda (cmd) :filter ,(lambda (cmd)
(when (and (>= corfu--index 0) (interactive)
(eq corfu-preview-current 'insert)) (if (>= corfu--index 0)
cmd))))) cmd
(cmds-ret `(menu-item "Insert completion" corfu-insert (corfu-quit))))))
:filter ,(lambda (cmd)
(cond ((eq corfu--index -1)
(corfu-quit))
((and (modulep! :completion corfu +tng)
(eq corfu-preview-current 'insert)
(minibufferp nil t))
(corfu-insert)
nil)
(t
cmd))))))
(map! :when (modulep! :completion corfu) (map! :when (modulep! :completion corfu)
:after corfu :after corfu
:map corfu-map :map corfu-map
[backspace] cmds-del [backspace] cmds-del
"DEL" cmds-del "DEL" cmds-del
:ig [return] cmds-ret (:when (modulep! :completion corfu +on-ret)
:ig "RET" cmds-ret)) :gi [return] #'corfu-insert
:gi "RET" #'corfu-insert)
(:when (modulep! :completion corfu +on-ret-pt)
:gi [return] cmds-ret-pt
:gi "RET" cmds-ret-pt)
(:unless (or (modulep! :completion corfu +on-ret)
(modulep! :completion corfu +on-ret-pt))
[return] nil
"RET" nil)))
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation. ;; 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 ;; Pressing it again will send you to the true bol. Same goes for C-e, except