.. | ||
autoload.el | ||
config.el | ||
packages.el | ||
README.org |
:completion corfu
Description unfold
This module provides code completion, powered by doom-package:corfu.
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 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
Module flags
- +icons
- Display icons beside completion suggestions.
- +tng
- Invoke completion on TAB. When corfu is active, TAB and S-TAB will navigate the completion candidates. Arrow keys and evil-style movement are still supported.
- +orderless
- Pull in doom-package:orderless if necessary and apply multi-component completion (still needed if doom-module::completion vertico is active).
Packages
- doom-package:corfu
- doom-package:cape
- doom-package:nerd-icons-completion if doom-module::completion corfu +icons
- doom-package:nerd-icons-corfu 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
Hacks
No hacks documented for this module.
TODO Changelog
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
words. Snippets may also appear in the candidate list if available.
TODO Usage
🔨 This module's usage documentation is incomplete. Complete it?
Code completion
By default, completion gets triggered after typing 2 non-space consecutive characters, or by means of the C-SPC keybinding at any moment. While the popup is visible, the following relevant keys are available:
Keybind | Description |
---|---|
<down> | Go to next candidate |
<up> | Go to previous candidate |
C-n | Go to next candidate |
C-p | Go to previous candidate |
C-j | (evil) Go to next candidate |
C-k | (evil) Go to previous candidate |
C-<down> | Go to next doc line |
C-<up> | Go to previous doc line |
C-S-n | Go to next doc line |
C-S-p | Go to previous doc line |
C-S-j | (evil) Go to next doc line |
C-S-k | (evil) Go to previous doc line |
C-h | Toggle documentation (if available) |
M-m | Export to minibuffer (if doom-module::completion vertico) |
M-j | (evil) Export to minibuffer (if doom-module::completion vertico) |
RET | Insert candidate |
SPC | Quit autocompletion after a wildcard or pass-through |
C-SPC | (when completing) Insert separator (see below) |
C-SPC | Complete (unless doom-module::completion corfu +tng) |
If you prefer a TAB-centric completion style, enable the doom-module::completion corfu +tng flag so that, instead, you trigger completion with TAB, getting the following additional binds:
Keybind | Description |
---|---|
TAB | Complete |
TAB | (when completing) Go to next candidate |
S-TAB | (when completing) Go to previous candidate |
DEL | (when completing) Reset completion DWIM-style |
Searching with multiple keywords
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 separator. More information can be found here. Pressing 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 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.
Furthermore, if you also have var:+orderless-wildcard-character set (by default it's the comma key), then that character acts as a wildcard when typed mid-completion.
Exporting to the minibuffer (requires doom-module::completion vertico)
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 C-c C-l and get a buffer with all candidates.
Configuration
A few variables may be set to change behavior of this module:
- var:corfu-auto-delay
- Number of seconds till completion occurs automatically. Defaults to 0.1.
- var:corfu-auto-prefix
- Number of characters till auto-completion starts to happen. Defaults to 2.
- 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.
- var:+orderless-wildcard-character
-
Used for fuzzy-matching corfu invocations as an escapable alternative to
corfu-separator
. Defaults to comma. - var:+cape-buffer-scanning-size-limit:
-
Sets the maximum buffer size to be scanned by
cape-dabbrev
andcape-lines
. Defaults to 1 MB. Set this if you are having performance problems usingcape-dabbrev
.
Adding CAPFs to a mode
To add other CAPFs on a mode-per-mode basis, put either of the following in your
config.el
:
(add-hook! some-mode (add-hook 'completion-at-point-functions #'some-capf depth t))
;; OR, but note the different call signature
(add-hook 'some-mode-hook (lambda () (add-hook 'completion-at-point-functions #'some-capf depth t)))
DEPTH above is an integer between -100, 100, and defaults to 0 of ommited. Also
see add-hook!
's documentation for additional ways to call it. add-hook
only
accepts the quoted arguments form above.
Troubleshooting
If you have performance issues with cape-dabbrev
, the first thing I recommend
doing is looking at the list of buffers Dabbrev is scanning with:
(dabbrev--select-buffers) ; => (#<buffer README.org> #<buffer config.el<3>> #<buffer cape.el> ...)
(length (dabbrev--select-buffers)) ; => 37
and modifying dabbrev-ignored-buffer-regexps
or dabbrev-ignored-buffer-modes
accordingly.
Frequently asked questions
This module has no FAQs yet. Ask one?
TODO Appendix
🔨 This module has no appendix yet. Write one?