Expand description
Editor-agnostic completion logic for Beancount sources.
This crate is the single source of truth for the completion logic
shared between the LSP (rustledger-lsp) and the WASM editor
(rustledger-wasm). It is deliberately pure: no clock access, no
lsp-types, no wasm-bindgen. Callers supply the live data
(account/currency/payee/tag/link string lists and “today’s” date)
and map the neutral CompletionCandidate results into their own
editor-specific item types.
The two responsibilities are:
- Context detection —
offset_to_bytemaps a position (under aPositionEncoding) to a byte offset, thenclassify_contextclassifies the text before the cursor into aCompletionContext. - Candidate generation — the
*_candidatesfunctions produce neutralCompletionCandidatelists for each context.
Structs§
- Completion
Candidate - A neutral, editor-agnostic completion candidate.
Enums§
- Completion
Context - Completion context detected from cursor position.
- Completion
Kind - The kind of a completion candidate.
- Position
Encoding - How a position offset is encoded by the caller.
Constants§
- ACCOUNT_
TYPES - Standard Beancount account types.
- DIRECTIVES
- Standard Beancount directives.
Functions§
- account_
segment_ candidates - Candidates for the next account segment after a
prefix. - account_
start_ candidates - Candidates when starting an account name: the standard account types followed by every known account.
- after_
date_ candidates - Candidates after a date: the directive keywords.
- classify_
context - Classify the completion context from the text before the cursor.
- currency_
candidates - Candidates for a currency after an amount.
- line_
start_ candidates - Candidates at line start: a single date template using the supplied
todaystring (the crate is clock-free; each adapter passes its own date). - link_
candidates - Candidates for a link after
^(issue #1268). Mirrorstag_candidates; the sigil is kept inlabeland dropped ininsert_text. - offset_
to_ byte - Map a position
offset(in the givenencoding) into a byte offset intoline, clamped to a char boundary. - payee_
candidates - Candidates for a payee/narration inside a string. Returns all known
payees — the client filters (issue #1183, the
.take(20)trap). - tag_
candidates - Candidates for a tag after
#(issue #1268).