2023-03-29 17:03:22 -04:00
|
|
|
#+title: :completion corfu
|
|
|
|
#+subtitle: Complete with cap(f), cape and a flying feather
|
|
|
|
#+created: September 9, 2022
|
|
|
|
#+since: 3.0.0 (#7002)
|
|
|
|
|
|
|
|
* Description :unfold:
|
2023-09-06 10:06:14 -04:00
|
|
|
This module provides code completion, powered by [[doom-package:corfu]].
|
2023-03-29 17:03:22 -04:00
|
|
|
|
2023-09-06 10:06:14 -04:00
|
|
|
It is recommended to enable either this or [[doom-module::completion company]], in case you
|
2023-03-29 17:03:22 -04:00
|
|
|
desire pre-configured auto-completion. Corfu is much lighter weight and 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.
|
|
|
|
|
|
|
|
** Maintainers
|
|
|
|
- [[doom-user:][@LuigiPiucco]]
|
|
|
|
|
|
|
|
[[doom-contrib-maintainer:][Become a maintainer?]]
|
|
|
|
|
|
|
|
** Module flags
|
|
|
|
- +icons ::
|
|
|
|
Display icons beside completion suggestions.
|
|
|
|
- +tng ::
|
|
|
|
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.
|
2023-09-06 10:06:14 -04:00
|
|
|
- +orderless ::
|
|
|
|
Pull in [[doom-package:orderless]] if necessary and apply multi-component
|
|
|
|
completion (still needed if [[:completion vertico]] is active).
|
2023-03-29 17:03:22 -04:00
|
|
|
|
|
|
|
** Packages
|
2023-09-06 10:06:14 -04:00
|
|
|
- [[doom-package:corfu]]
|
|
|
|
- [[doom-package:cape]]
|
|
|
|
- [[doom-package:kind-icon]] if [[doom-module::completion corfu +icons]]
|
|
|
|
- [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]]
|
|
|
|
- [[doom-package:corfu-terminal]] if [[doom-module::os tty]]
|
|
|
|
- [[doom-package:yasnippet-capf]] if [[doom-module::editor snippets]]
|
|
|
|
|
2023-03-29 17:03:22 -04:00
|
|
|
** Hacks
|
|
|
|
/No hacks documented for this module./
|
|
|
|
|
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
Enable this module in your ~doom!~ block.
|
|
|
|
|
|
|
|
This module has no direct requirements, but some languages may have their own
|
|
|
|
requirements to fulfill before you get code completion in them (and some
|
|
|
|
languages may lack code completion support altogether). Run ~$ doom doctor~ to
|
|
|
|
find out if you're missing any dependencies. Note that corfu may have support
|
|
|
|
for completions in languages that have no development intelligence, since it
|
|
|
|
supports generic, context insensitive candidates such as file names or recurring
|
2023-09-06 10:06:14 -04:00
|
|
|
words. Snippets may also appear in the candidate list if available.
|
2023-03-29 17:03:22 -04:00
|
|
|
|
|
|
|
* TODO Usage
|
|
|
|
#+begin_quote
|
|
|
|
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
** Code completion
|
|
|
|
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:][s-<down>]] | Export to minibuffer (if [[doom-module:][:completion vertico]]) |
|
|
|
|
| [[kbd:][s-j]] | (evil) Export to minibuffer (if [[doom-module:][:completion vertico]]) |
|
|
|
|
| [[kbd:][RET]] | Insert candidate |
|
|
|
|
| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) |
|
|
|
|
| [[kbd:][C-SPC]] | Complete (unless [[doom-module:][:completion corfu +tng]]) |
|
|
|
|
|
|
|
|
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 following
|
|
|
|
additional binds:
|
|
|
|
|
|
|
|
| Keybind | Description |
|
|
|
|
|---------+--------------------------------------------|
|
|
|
|
| [[kbd:][TAB]] | Complete |
|
|
|
|
| [[kbd:][TAB]] | (when completing) Go to next candidate |
|
|
|
|
| [[kbd:][S-TAB]] | (when completing) Go to previous candidate |
|
|
|
|
|
|
|
|
** Searching with multiple keywords
|
2023-09-06 10:06:14 -04:00
|
|
|
If the ~+orderless~ flag is enabled, users can perform code completion
|
2023-03-29 17:03:22 -04:00
|
|
|
with multiple search keywords by use of space as separator. More information can
|
|
|
|
be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while completing inserts a space as
|
|
|
|
separator. This allows searching with space-separated terms; each piece will
|
|
|
|
match individually and in any order, with smart casing. Pressing just [[kbd:][SPC]] acts
|
|
|
|
as normal and restarts completion, so that when typing sentences it doesn't try
|
|
|
|
to complete the whole sentence instead of just the word.
|
|
|
|
|
|
|
|
** Exporting to the minibuffer (requires [[doom-module:][:completion vertico]])
|
2023-09-06 10:06:14 -04:00
|
|
|
When using the [[doom-module::completion vertico]] module, which pulls in the
|
|
|
|
[[doom-package:consult]] package, the entries shown in the completion popup can be
|
|
|
|
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.
|
2023-03-29 17:03:22 -04:00
|
|
|
|
|
|
|
* Configuration
|
|
|
|
A few variables may be set to change behavior of this module:
|
|
|
|
|
2023-09-06 10:06:14 -04:00
|
|
|
- [[var:corfu-auto-delay]] ::
|
2023-03-29 17:03:22 -04:00
|
|
|
Number of seconds till completion occurs automatically. Defaults to 0.1.
|
2023-09-06 10:06:14 -04:00
|
|
|
- [[var:corfu-auto-prefix]] ::
|
2023-03-29 17:03:22 -04:00
|
|
|
Number of characters till auto-completion starts to happen. Defaults to 2.
|
2023-09-06 10:06:14 -04:00
|
|
|
- [[var:+corfu-want-multi-component]] ::
|
2023-03-29 17:03:22 -04:00
|
|
|
Sets whether orderless-style matching should be supported with space as a
|
|
|
|
separator.
|
2023-09-06 10:06:14 -04:00
|
|
|
- [[var:corfu-on-exact-match]] ::
|
|
|
|
Configures behavior for exact matches. Its default is nil, and it's
|
|
|
|
recommended to leave it at that. Otherwise, single matches on snippet keys
|
|
|
|
expand immediately.
|
2023-03-29 17:03:22 -04:00
|
|
|
|
|
|
|
* Troubleshooting
|
|
|
|
[[doom-report:][Report an issue?]]
|
|
|
|
|
|
|
|
* Frequently asked questions
|
|
|
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
|
|
|
|
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
|
|
|
#+end_quote
|