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:
parent
386a073b59
commit
73090187d7
5 changed files with 150 additions and 74 deletions
|
@ -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
|
||||
|
@ -129,9 +128,42 @@ exported to a consult minibuffer, giving access to all the manipulations the
|
|||
Vertico suite allows. 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
|
||||
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
|
||||
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
|
||||
look through). This module provides some such bindings for Evil users (see the
|
||||
table below), and you're free map your own of course. Emacs users have to map it
|
||||
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 |
|
||||
|---------+---------------------------------|
|
||||
| [[kbd:][C-x]] [[kbd:][C-l]] | (insert-state) ~cape-line~ |
|
||||
| [[kbd:][C-x]] [[kbd:][C-k]] | (insert-state) ~cape-keyword~ |
|
||||
| [[kbd:][C-x]] [[kbd:][C-f]] | (insert-state) ~cape-file~ |
|
||||
| [[kbd:][C-x]] [[kbd:][s]] | (insert-state) ~cape-dict~ |
|
||||
| [[kbd:][C-x]] [[kbd:][C-s]] | (insert-state) ~yasnippet-capf~ |
|
||||
| [[kbd:][C-x]] [[kbd:][C-n]] | (insert-state) ~cape-dabbrev~ |
|
||||
| [[kbd:][C-x]] [[kbd:][C-p]] | (insert-state) ~cape-history~ |
|
||||
|
||||
* Configuration
|
||||
A few variables may be set to change behavior of this module:
|
||||
|
||||
- [[var:completion-at-point-functions]] ::
|
||||
This is not a module/package variable, but a builtin Emacs one. Even so, it's
|
||||
very important to how Corfu works, so we document it here. It contains a list
|
||||
of functions that are called in turn to generate completion candidates. The
|
||||
regular (non-lexical) value should contain few entries and they should
|
||||
generally be context aware, so as to predict what you need. Additional
|
||||
functions can be added as you get into more and more specific contexts. Also,
|
||||
there may be cases where you know beforehand the kind of candidate needed, and
|
||||
want to enable only that one. For this, the variable may be lexically bound to
|
||||
the correct value, or you may call the CAPF interactively if a single function
|
||||
is all you need.
|
||||
- [[var:corfu-auto-delay]] ::
|
||||
Number of seconds till completion occurs automatically. Defaults to 0.1.
|
||||
- [[var:corfu-auto-prefix]] ::
|
||||
|
@ -158,6 +190,20 @@ To add other CAPFs on a mode-per-mode basis, put either of the following in your
|
|||
see ~add-hook!~'s documentation for additional ways to call it. ~add-hook~ only
|
||||
accepts the quoted arguments form above.
|
||||
|
||||
** Adding CAPFs to a key
|
||||
To add other CAPFs to keys, adapt the snippet below into your ~config.el~:
|
||||
#+begin_src emacs-lisp
|
||||
;; For binding inside `corfu-mode-map'. Line 1 ensures the binding only exists
|
||||
;; 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!'
|
||||
;; call is enough.
|
||||
(add-hook! some-mode ; Only needed if the binding is mode-specific
|
||||
(make-local-variable 'corfu-mode-map)
|
||||
(map! :map corfu-mode-map
|
||||
: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
|
||||
#+end_src
|
||||
|
||||
* Troubleshooting
|
||||
[[doom-report:][Report an issue?]]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue