Alexander-Miller/treemacs@96a808f067 -> Alexander-Miller/treemacs@820b09db10 FStarLang/fstar-mode.el@36ffb46259 -> FStarLang/fstar-mode.el@3bbfe93abd JuliaEditorSupport/julia-emacs@0f4d74f904 -> JuliaEditorSupport/julia-emacs@5c940c4ba3 ProofGeneral/PG@85cde55a86 -> ProofGeneral/PG@af2e7b9a4e Silex/docker.el@3bea08f1d2 -> Silex/docker.el@464105ed8b Wilfred/helpful@6a4d5e0760 -> Wilfred/helpful@03756fa6ad abo-abo/swiper@e33b028ed4 -> abo-abo/swiper@2529a23f9f agda/agda@49a12eab7f -> agda/agda@900bdaa335 alexluigit/dirvish@ecb7c42e20 -> alexluigit/dirvish@e8ec5765da ardumont/markdown-toc@d2fb4cbd95 -> ardumont/markdown-toc@1b0c5ae7f3 bastibe/org-journal@cf72173233 -> bastibe/org-journal@e581bf5530 clojure-emacs/cider@fdfa7c2200 -> clojure-emacs/cider@12f10a6f4b clojure-emacs/clojure-mode@eabe29b076 -> clojure-emacs/clojure-mode@b766094aea company-mode/company-mode@8d599ebc8a -> company-mode/company-mode@41f07c7d40 creichert/ido-vertical-mode.el@b1659e967d -> creichert/ido-vertical-mode.el@35c521789b dgutov/diff-hl@7da881a957 -> dgutov/diff-hl@aa667ac58a dimitri/switch-window@61e425e703 -> dimitri/switch-window@8f771b571a doomelpa/code-review@eeffdd9e20 -> doomelpa/code-review@fba8fe3343 editorconfig/editorconfig-emacs@1a9942746c -> editorconfig/editorconfig-emacs@d2beb3ec2e ema2159/centaur-tabs@7704f2017c -> ema2159/centaur-tabs@a790dc8fb6 emacs-circe/circe@d0e531bd2a -> emacs-circe/circe@e5e64d549f emacs-citar/citar-org-roam@ff38add0aa -> emacs-citar/citar-org-roam@9750cfbbf3 emacs-ess/ESS@56f355acbd -> emacs-ess/ESS@d19efaae12 emacs-helm/helm-org@22d60952f8 -> emacs-helm/helm-org@4744ca7f8b emacs-helm/helm@f948dc4464 -> emacs-helm/helm@5a222a8a6b emacs-lsp/dap-mode@56e92dd86b -> emacs-lsp/dap-mode@b977566657 emacs-lsp/emacs-ccls@28c7930c89 -> emacs-lsp/emacs-ccls@5636ee6c50 emacs-lsp/helm-lsp@cf4ea6fb42 -> emacs-lsp/helm-lsp@54926afd10 emacs-lsp/lsp-dart@2170823139 -> emacs-lsp/lsp-dart@34e2a1191f emacs-lsp/lsp-haskell@cd0f5d251c -> emacs-lsp/lsp-haskell@081d5115ce emacs-lsp/lsp-ivy@bdc730a209 -> emacs-lsp/lsp-ivy@3ee14a24bb emacs-lsp/lsp-java@6cfff8761e -> emacs-lsp/lsp-java@21c89243ad emacs-lsp/lsp-metals@345b4fa80e -> emacs-lsp/lsp-metals@e1d9d04f3b emacs-lsp/lsp-mode@7c0df125c1 -> emacs-lsp/lsp-mode@54251da4ff emacs-lsp/lsp-pyright@b4cee81af4 -> emacs-lsp/lsp-pyright@73377169be emacs-lsp/lsp-sourcekit@3bd9750e7e -> emacs-lsp/lsp-sourcekit@1fb230109e emacs-lsp/lsp-treemacs@312dee2b3a -> emacs-lsp/lsp-treemacs@3e5550f278 emacs-lsp/lsp-ui@09d4080642 -> emacs-lsp/lsp-ui@a0dde8b52b emacs-php/composer.el@6c7e19256f -> emacs-php/composer.el@eba6b953a4 emacs-php/php-mode@5b6cc1c068 -> emacs-php/php-mode@462b62248f emacs-php/psysh.el@ae15a36301 -> emacs-php/psysh.el@223bf55975 emacs-rustic/rustic@22a5ef8bfd -> emacs-rustic/rustic@29f912c750 emacs-straight/auctex@6fb366064c -> emacs-straight/auctex@f58a2b972b emacs-straight/dape@c7a1f1abdb -> emacs-straight/dape@588a907c87 emacs-straight/eglot@6a9e0c76b9 -> emacs-straight/eglot@928c216af5 emacs-straight/org-mode@74dde3abae -> emacs-straight/org-mode@79781bac69 emacs-straight/project@369ac661c8 -> emacs-straight/project@27c6b04914 emacs-straight/sml-mode@021233f60a -> emacs-straight/sml-mode@c33659fd9b emacs-straight/use-package@d79bac4574 -> emacs-straight/use-package@bbfe01bdf1 emacs-straight/vundo@c32481ab48 -> emacs-straight/vundo@5a666b34e4 emacs-tree-sitter/elisp-tree-sitter@8516c9977e -> emacs-tree-sitter/elisp-tree-sitter@12f92ef399 emacs-tree-sitter/tree-sitter-langs@2ff446b4b8 -> emacs-tree-sitter/tree-sitter-langs@4eb4989d1a emacsmirror/org-contrib@8d14a600a2 -> emacsmirror/org-contrib@f1f6b6ec81 emacsorphanage/dart-mode@6229941ec5 -> emacsorphanage/dart-mode@f82ff05230 emacsorphanage/ox-pandoc@34e6ea97b5 -> emacsorphanage/ox-pandoc@5766c70b6d emacsorphanage/quickrun@4b6df453f8 -> emacsorphanage/quickrun@a5c9a5e8c6 ericdallo/hover.el@4ca0638a14 -> ericdallo/hover.el@1b380fa395 erlang/otp@740af6bae5 -> erlang/otp@b9d3ec017d flycheck/flycheck@b9db1379dc -> flycheck/flycheck@16b536b031 fsharp/emacs-fsharp-mode@bf7a11e1ba -> fsharp/emacs-fsharp-mode@8d08f05788 godotengine/emacs-gdscript-mode@3f3739dd88 -> godotengine/emacs-gdscript-mode@5136be407a greghendershott/racket-mode@88d82e249e -> greghendershott/racket-mode@c4cc7c160b hakimel/reveal.js@dfc5690c6d -> hakimel/reveal.js@eb95b14531 haskell/haskell-mode@be2639592f -> haskell/haskell-mode@e9c3567393 https://git.notmuchmail.org/git/notmuch@dfc800c26e7b -> https://git.notmuchmail.org/git/notmuch@d8ebc9cf80b6 https://git.savannah.gnu.org/git/emms.git@8713a0ee985c -> https://git.savannah.gnu.org/git/emms.git@abb4f614dae6 idris-hackers/idris-mode@09de86a8f0 -> idris-hackers/idris-mode@ccf32ed0b5 jcollard/elm-mode@699841865e -> jcollard/elm-mode@90b72cd2c9 jdtsmith/indent-bars@fa293f98ab -> jdtsmith/indent-bars@ea74161b46 jdtsmith/ultra-scroll@b72c507f67 -> jdtsmith/ultra-scroll@f2e4fba601 jimhourihan/glsl-mode@c5f2c2e7ed -> jimhourihan/glsl-mode@86e6bb6cf2 joaotavora/sly@c48defcf58 -> joaotavora/sly@ce17a568ef jrblevin/markdown-mode@d2d960bec1 -> jrblevin/markdown-mode@90ad4af79a jschaf/powershell.el@38727f1cda -> jschaf/powershell.el@9efa1b4d0a magit/magit@bf58615a03 -> magit/magit@531e7ca619 minad/cape@f72ebcaeff -> minad/cape@5546a2db8e minad/consult-flycheck@3bc2141daf -> minad/consult-flycheck@77d3e790a3 minad/consult@f94d557807 -> minad/consult@ee64a2a299 minad/corfu@061d926d0f -> minad/corfu@2e05fe8244 minad/goggles@d71e85ff8d -> minad/goggles@6141d31c51 minad/marginalia@c51fd9e4d4 -> minad/marginalia@2ff4d690f7 minad/org-modern@3cc432dc99 -> minad/org-modern@6158d3d007 minad/vertico@e0bb699ebf -> minad/vertico@304be874be mohkale/consult-yasnippet@834d39acfe -> mohkale/consult-yasnippet@a3482dfbdc msnoigrs/ox-rst@b4ba5c7e95 -> msnoigrs/ox-rst@b73eff187e oantolin/embark@d5df0eff18 -> oantolin/embark@923d0ec52e ocaml/dune@a46193e167 -> ocaml/dune@422986440e ocaml/merlin@2eeb63d002 -> ocaml/merlin@e4c66857ad oer/org-re-reveal@53e9be7d89 -> oer/org-re-reveal@89ed240450 polymode/poly-R@8024e852cf -> polymode/poly-R@fee0b6e999 purcell/package-lint@43012b41ac -> purcell/package-lint@2dc48e5fb9 purescript-emacs/purescript-mode@a3d6ca4ba5 -> purescript-emacs/purescript-mode@8c4736759a pythonic-emacs/pyenv-mode@7faed57eb7 -> pythonic-emacs/pyenv-mode@ba1a8c7bd7 rust-lang/rust-mode@efd830806c -> rust-lang/rust-mode@25d91cff28 seagle0128/doom-modeline@1708db2d35 -> seagle0128/doom-modeline@a85cb28da8 seagle0128/grip-mode@e90e3b47d8 -> seagle0128/grip-mode@96a927dce6 seagle0128/nerd-icons-ivy-rich@5006f91b49 -> seagle0128/nerd-icons-ivy-rich@83c7b60595 sebasmonia/sharper@496e90e337 -> sebasmonia/sharper@5049795848 swift-emacs/swift-mode@2c0b2b72dc -> swift-emacs/swift-mode@e30b9d46e0 szermatt/emacs-bash-completion@a4c8fbc902 -> szermatt/emacs-bash-completion@d0637428fd technomancy/fennel-mode@811f39de12 -> technomancy/fennel-mode@df8e83d6e2 wanderlust/wanderlust@6a0605415d -> wanderlust/wanderlust@d6dcbad228 weijiangan/flycheck-golangci-lint@424ba1b3a1 -> weijiangan/flycheck-golangci-lint@14bf143ea7 ziglang/zig-mode@4ad4edf759 -> ziglang/zig-mode@c46d024733
: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.
If you choose Corfu, we also highly recomend reading its README and cape's README, as the backend is very configurable and provides many power-user utilities for fine-tuning. Only some of common behaviors are documented here.
Maintainers
Module flags
- +icons
- Display icons beside completion suggestions.
- +orderless
- Pull in doom-package:orderless if necessary and apply multi-component completion (still needed if doom-module::completion vertico is active).
- +dabbrev
- Enable and configure doom-package:dabbrev as a close-to-universal CAPF fallback.
Packages
- doom-package:corfu
- doom-package:cape
- 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?
By default, completion gets triggered after typing 2 non-space consecutive characters, by means of C-SPC at any moment or TAB on a line with proper indentation. Many styles of completion are documented below, which can be composed to suit the user. The following keybindings are generally available:
Keybind | Description |
---|---|
C-n | Go to next candidate |
C-p | Go to previous candidate |
C-S-n | Go to next doc line |
C-S-p | Go to previous doc line |
C-S-s | Export to minibuffer |
TAB | (when not completing) Indent or complete |
C-SPC | (when not completing) Complete |
C-u | (evil) Go to next candidate page |
C-d | (evil) Go to previous candidate page |
C-h | (evil) Toggle documentation (if available) |
M-t | (emacs) (when not completing) Complete |
Bindings in the following sections are additive, and unless otherwise noted, are enabled by default with configurable behavior. Additionally, for users of evil, C-SPC is smart regarding your state. In normal-like states, enter insert then start corfu; in visual-like states, perform evil-change (which leaves you in insert state) then start corfu; in insert-like states, start corfu immediatelly.
Commit preview on type
When the completion popup is visible, by default the current candidate is previewed into the buffer, and further input commits that candidate as previewed (note it does not perform candidate exit actions, such as expanding snippets).
The feature is in line with other common editors, but if you prefer the preview to be only visual or for there to be no preview, configure var:corfu-preview-current.
;; Non-inserting preview
(setq corfu-preview-current t)
;; No preview
(setq corfu-preview-current nil)
Commit on RET with pass-through
A lot of people like to use RET to commit, so here we bind it to Corfu's insertion function. Note that Corfu allows "no candidate" to be selected, and in that case, we have a custom binding to quit completion and pass-through. To make it less obtrusive by default, the popup starts in this unselected state. See var:corfu-preselect to alter the initial behavior; it can start with the first one selected, for instance. Then, you have to move one candidate backwards to pass-through The exact action of RET can be changed via var:+corfu-want-ret-to-confirm.
Keybind | Description |
---|---|
RET | Insert candidate DWIM |
Cycle directionally
If you'd rather think in directions rather than next/previous, arrow keys and vi
movements to control the selection and documentation view are bound by default.
You may unbind them by setting to nil, see map!
's documentation.
Keybind | Description |
---|---|
<down> | Go to next candidate |
<up> | 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-j | (evil) Go to next doc line |
C-S-k | (evil) Go to previous doc line |
Cycle with TAB
Searching with multiple keywords (+orderless
)
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 quits completion, so that when typing sentences it doesn't try to complete the whole sentence instead of just the word. Pressing C-SPC with point after a separator escapes it with a 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 you accidentaly press more than needed.
Keybind | Description |
---|---|
C-SPC | (evil) (when completing) Insert separator DWIM |
M-SPC | (emacs) (when completing) Insert separator DWIM |
SPC | (when completing) Quit autocompletion |
SPC | (when completing with separators) Self-insert |
Exporting to the minibuffer
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
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: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
- Number of characters till auto-completion starts to happen. Defaults to 2.
- var:corfu-on-exact-match
- Configures behavior for exact matches.
- var:corfu-preselect
- Configures startup selection, choosing between the first candidate or the prompt.
- var:corfu-preview-current
- Configures current candidate preview.
- var:+corfu-want-ret-to-confirm
-
Controls the behavior of RET when the popup is visible - whether it confirms
the selected candidate, and whether RET is passed through (ie. the normal
behavior of RET is performed). The default value of
t
enables confirmation and disables pass-through. Other variations arenil
for pass-through and no confirmation andboth
for confirmation followed by pass-through. Finally, the value ofminibuffer
will both confirm and pass-through (likeboth
) when in the minibuffer, and only confirm (liket
) otherwise. - var:+corfu-buffer-scanning-size-limit
-
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. - var:+corfu-want-minibuffer-completion
- Whether to enable Corfu in the minibuffer. See its documentation for additional tweaks.
- var:+corfu-want-tab-prefer-expand-snippets
- Whether to prefer expanding snippets over cycling candidates when pressing TAB.
- var:+corfu-want-tab-prefer-navigating-snippets
- Whether to prefer navigating snippets over cycling candidates when pressing TAB and S-TAB.
- var:+corfu-want-tab-prefer-navigating-org-tables
- Whether to prefer navigating org tables over cycling candidates when pressing TAB and S-TAB.
Turning off auto-completion
To disable idle (as-you-type) completion, unset corfu-auto
:
;;; in $DOOMDIR/config.el
(after! corfu
(setq corfu-auto nil))
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 if nil. Also
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
:
(map! :map some-mode-map
"C-x e" #'cape-emoji)
It's okay to add to the mode directly because completion-at-point
works
regardless of Corfu (the latter is an enhanced UI for the former). Just note not
all CAPFs are interactive to be called this way, in which case you can use
doom-package:cape's adapter to enable this.
Troubleshooting
Troubleshooting cape-dabbrev
If you have performance issues with cape-dabbrev
, the first thing I recommend
doing is to look at the list of buffers Dabbrev is scanning:
(dabbrev--select-buffers) ; => (#<buffer README.org> #<buffer config.el<3>> #<buffer cape.el> ...)
(length (dabbrev--select-buffers)) ; => 37
… and modify dabbrev-ignored-buffer-regexps
or dabbrev-ignored-buffer-modes
accordingly.
If you see garbage completion candidates, you can use the following command to debug the issue:
;;;###autoload
(defun search-in-dabbrev-buffers (search-string)
"Search for SEARCH-STRING in all buffers returned by `dabbrev--select-buffers'."
(interactive "sSearch string: ")
(let ((buffers (dabbrev--select-buffers)))
(multi-occur buffers search-string)))
;; Example usage:
;; Why are these weird characters appearing in my completions?
(search-in-dabbrev-buffers "\342\200\231")
Fixing TAB Keybindings
If you encounter an issue where your TAB
keybindings are not responding in Doom
Emacs while the :editor evil
module is active, it's likely caused by a conflict
where <tab>
keybindings and insert state bindings are overriding your TAB
key
assignments.
In Evil mode, keybinding priorities are set such that:
<tab>
keybindings supersedeTAB
keybindings and only work in GUI Emacs.- Bindings in insert state take precedence whenever the insert state is active.
To resolve this conflict and to assign your desired command to the TAB
key, you
must redefine the keybindings with insert state set explicitly. You can do this
by configuring your evil
keybindings for the insert state as follows:
(map! :gi "TAB" #'your-command
:gi "<tab>" #'your-command)
Place this code in your Doom Emacs configuration file to set the function your-command
as the response to pressing TAB
during insert mode.
Remember to replace #'your-command
with the actual command you wish to invoke
with the TAB
key.
If ever in a situation like this, use describe-key
with C-h k
and look at what
command is being called as well as what keymaps the command is defined in.
Frequently asked questions
This module has no FAQs yet. Ask one?
TODO Appendix
🔨 This module has no appendix yet. Write one?