Skip to content

Commit e26e628

Browse files
committed
Add prelude-corfu module as a Company alternative
Corfu is a minimal in-buffer completion UI that uses Emacs' built-in completion-at-point infrastructure -- so it cooperates with the orderless completion style already configured by prelude-vertico, no separate frontend/backend abstraction. Cape is bundled alongside to add a few useful capf sources (cape-dabbrev, cape-file). More can be enabled from personal config. The module is mutually exclusive with prelude-company.
1 parent c1d0df0 commit e26e628

7 files changed

Lines changed: 136 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Add `prelude-ai` module: a thin wrapper around [gptel](https://github.com/karthink/gptel) for LLM-backed chat (Claude, GPT, Gemini, Ollama, etc.). Binds `gptel-menu` to `C-c q`. Backends and API keys are configured in personal config -- see the module documentation for examples.
1010
- Add `prelude-forge` module: enables [Forge](https://github.com/magit/forge) on top of Magit so you can read and reply to GitHub/GitLab/Gitea pull requests and issues without leaving Emacs.
1111
- Add `prelude-eglot-booster` module: speeds up Eglot via the [emacs-lsp-booster](https://github.com/blahgeek/emacs-lsp-booster) wrapper. The Emacs side ([eglot-booster](https://github.com/jdtsmith/eglot-booster)) is auto-installed via `package-vc-install` when the booster binary is on `PATH`; otherwise the module no-ops.
12+
- Add `prelude-corfu` module: a modern, lightweight in-buffer completion stack ([corfu](https://github.com/minad/corfu) + [cape](https://github.com/minad/cape)) -- alternative to `prelude-company`. Pairs naturally with the vertico/orderless setup in `prelude-vertico`.
1213

1314
### Changes
1415

docs/modules/corfu.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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.

docs/modules/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ These modules provide shared functionality used by other modules:
120120
- [Lisp Base](lisp.md) - common foundation for Lisp-family language modules
121121
- [LSP](lsp.md) - common foundation for modules using the Language Server Protocol
122122
- [Eglot Booster](eglot-booster.md) - speeds up Eglot via the `emacs-lsp-booster` wrapper
123-
- [Company](company.md) - completion framework used across many modes
123+
- [Company](company.md) - completion framework (legacy)
124+
- [Corfu](corfu.md) - lightweight modern alternative to Company
124125

125126
## Programming Language Modules
126127

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ nav:
1515
- LSP: modules/lsp.md
1616
- Eglot Booster: modules/eglot-booster.md
1717
- Company: modules/company.md
18+
- Corfu: modules/corfu.md
1819
- Programming Languages:
1920
- C/C++: modules/c.md
2021
- Clojure: modules/clojure.md

modules/prelude-corfu.el

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
;;; prelude-corfu.el --- Corfu in-buffer completion setup
2+
;;
3+
;; Copyright © 2011-2026 Bozhidar Batsov
4+
;;
5+
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
6+
;; URL: https://github.com/bbatsov/prelude
7+
8+
;; This file is not part of GNU Emacs.
9+
10+
;;; Commentary:
11+
12+
;; Corfu is a minimal in-buffer completion UI -- a modern, lightweight
13+
;; alternative to Company. It pairs naturally with the
14+
;; vertico/orderless/marginalia stack in `prelude-vertico'.
15+
;;
16+
;; Cape extends `completion-at-point-functions' with useful sources
17+
;; (file paths, dabbrev, keywords, etc.). This module enables a few
18+
;; sensible defaults; add more from your personal config if you want.
19+
;;
20+
;; This module is mutually exclusive with `prelude-company' -- enable
21+
;; one or the other, not both.
22+
23+
;;; License:
24+
25+
;; This program is free software; you can redistribute it and/or
26+
;; modify it under the terms of the GNU General Public License
27+
;; as published by the Free Software Foundation; either version 3
28+
;; of the License, or (at your option) any later version.
29+
;;
30+
;; This program is distributed in the hope that it will be useful,
31+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
32+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+
;; GNU General Public License for more details.
34+
;;
35+
;; You should have received a copy of the GNU General Public License
36+
;; along with GNU Emacs; see the file COPYING. If not, write to the
37+
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38+
;; Boston, MA 02110-1301, USA.
39+
40+
;;; Code:
41+
42+
(use-package corfu
43+
:ensure t
44+
:custom
45+
(corfu-cycle t)
46+
(corfu-auto t)
47+
(corfu-auto-prefix 2)
48+
(corfu-auto-delay 0.2)
49+
:init
50+
(global-corfu-mode)
51+
:config
52+
(corfu-popupinfo-mode))
53+
54+
(use-package cape
55+
:ensure t
56+
:init
57+
(add-hook 'completion-at-point-functions #'cape-dabbrev)
58+
(add-hook 'completion-at-point-functions #'cape-file))
59+
60+
(provide 'prelude-corfu)
61+
;;; prelude-corfu.el ends here

sample/prelude-modules.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
;; (require 'prelude-helm) ;; Interface for narrowing and search
4848
;; (require 'prelude-helm-everywhere) ;; Enable Helm everywhere
4949
(require 'prelude-company)
50+
;; (require 'prelude-corfu) ;; Lightweight modern alternative to Company (mutually exclusive with prelude-company)
5051
;; (require 'prelude-key-chord) ;; Binds useful features to key combinations
5152
;; (require 'prelude-eglot-booster) ;; Speeds up Eglot via emacs-lsp-booster (requires the binary)
5253

test/prelude-load-test.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
(defvar prelude-load-test-modules
1818
'(prelude-vertico
1919
prelude-company
20+
prelude-corfu
2021
prelude-ai
2122
prelude-eglot-booster
2223
prelude-forge

0 commit comments

Comments
 (0)