(macros)
Editing

Completion

Macros has a corfu-style in-buffer completion popup. It can appear automatically as you type or on demand, and it draws candidates from your own completion-at-point functions (CAPFs) and from the language server.

Triggering completion

  • On demand: M-i (completion-at-point). In modal editing, Space c.
  • Automatically: when completion-auto is on (the default), the popup appears after you've typed completion-auto-prefix word characters.

These bindings are active only while the popup is open:

Key Action
C-n / next candidate
C-p / previous candidate
Tab / Enter accept
C-g abort

Options

Set these in your init.scm (defaults shown). Values are typed — numbers and booleans (#t / #f) — though a quoted string works too:

(set-option "completion-style"       "popup")  ; "popup" or "minibuffer"
(set-option "completion-auto"        #t)       ; auto-popup while typing
(set-option "completion-auto-prefix" 2)        ; min chars before auto-popup
(set-option "completion-max-rows"    10)       ; visible rows
(set-option "completion-show-detail" #t)       ; show signature/type
(set-option "completion-show-kind"   #t)       ; show kind tag (fn, var, kw…)
(set-option "completion-capf"        #t)       ; set #f for LSP-only

completion-at-point functions (CAPFs)

completion-at-point tries each registered Scheme CAPF in order, then falls back to the language server. A CAPF is a function of the prefix word that returns one of:

  • a flat list of candidate strings (the word before point is replaced), or
  • (start end candidate-list) to control the replaced byte range, or
  • '() / #f to decline (the next CAPF, then LSP, is tried).

Each candidate is either a bare string or a (text annotation) pair, where the annotation renders dimmed beside the candidate (marginalia-style).

Registering a CAPF

;; Complete from a fixed word list whenever the prefix is non-empty.
(define (my-words prefix)
  (list "lambda" "let" "letrec"
        (list "define" "special form")))   ; annotated candidate

(add-completion-at-point-function "my-words")

To use the language server exclusively and skip the CAPF path entirely:

(set-option "completion-capf" #f)

See Language servers for LSP-driven completion, and Scripting with Steel for the primitives a CAPF can call.