|
| 1 | +# Prelude Corfu |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +[Corfu](https://github.com/minad/corfu) is a minimal in-buffer |
| 6 | +completion UI for Emacs -- a modern, lightweight alternative to |
| 7 | +Company. It uses Emacs' built-in `completion-at-point` infrastructure |
| 8 | +and the standard completion styles (so it cooperates with |
| 9 | +`orderless` from `prelude-vertico`), instead of providing its own |
| 10 | +backend abstraction the way Company does. |
| 11 | + |
| 12 | +[Cape](https://github.com/minad/cape) extends |
| 13 | +`completion-at-point-functions` with extra sources -- file paths, |
| 14 | +dabbrev, keywords, ispell, abbrevs, etc. -- so they show up in the |
| 15 | +Corfu popup alongside the language-specific completions provided by |
| 16 | +LSP servers, Eglot, etc. |
| 17 | + |
| 18 | +!!! Note |
| 19 | + |
| 20 | + This module is mutually exclusive with the |
| 21 | + [Company](company.md) module -- enable one or the other, not |
| 22 | + both. |
| 23 | + |
| 24 | +## Packages |
| 25 | + |
| 26 | +- [corfu](https://github.com/minad/corfu) - the completion popup |
| 27 | +- [cape](https://github.com/minad/cape) - completion-at-point extensions |
| 28 | + |
| 29 | +## Defaults |
| 30 | + |
| 31 | +Corfu auto-pops after typing 2 characters (with a 200 ms debounce) |
| 32 | +and cycles through candidates with <kbd>TAB</kbd>: |
| 33 | + |
| 34 | +| Variable | Value | Effect | |
| 35 | +| -------- | ----- | ------ | |
| 36 | +| `corfu-auto` | `t` | Open the popup automatically as you type | |
| 37 | +| `corfu-auto-prefix` | `2` | Minimum prefix length to trigger | |
| 38 | +| `corfu-auto-delay` | `0.2` | Delay (seconds) before popup | |
| 39 | +| `corfu-cycle` | `t` | Wrap around at end of list | |
| 40 | + |
| 41 | +`corfu-popupinfo-mode` is enabled by default -- it shows |
| 42 | +documentation for the highlighted candidate in a side popup. |
| 43 | + |
| 44 | +## Default Cape sources |
| 45 | + |
| 46 | +The following completion-at-point sources are added globally: |
| 47 | + |
| 48 | +- `cape-dabbrev` - completes from words in open buffers |
| 49 | +- `cape-file` - completes file paths |
| 50 | + |
| 51 | +Add more from your personal config: |
| 52 | + |
| 53 | +```emacs-lisp |
| 54 | +(with-eval-after-load 'cape |
| 55 | + (add-hook 'completion-at-point-functions #'cape-keyword) |
| 56 | + (add-hook 'completion-at-point-functions #'cape-elisp-block)) |
| 57 | +``` |
| 58 | + |
| 59 | +## Tips |
| 60 | + |
| 61 | +- Press <kbd>M-SPC</kbd> in the popup to insert a space without |
| 62 | + dismissing it (useful with orderless). |
| 63 | +- <kbd>M-g</kbd> opens the candidate at point (e.g. jumps to the |
| 64 | + function definition); <kbd>M-h</kbd> shows its documentation in a |
| 65 | + separate buffer. |
| 66 | +- For language-specific completions to feel snappy, configure your |
| 67 | + LSP setup (Eglot or `lsp-mode`) to expose richer |
| 68 | + `completion-at-point-functions` -- both already do this out of |
| 69 | + the box. |
0 commit comments