Skip to main content

Crate rustledger_completion

Crate rustledger_completion 

Source
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:

  1. Context detectionoffset_to_byte maps a position (under a PositionEncoding) to a byte offset, then classify_context classifies the text before the cursor into a CompletionContext.
  2. Candidate generation — the *_candidates functions produce neutral CompletionCandidate lists for each context.

Structs§

CompletionCandidate
A neutral, editor-agnostic completion candidate.

Enums§

CompletionContext
Completion context detected from cursor position.
CompletionKind
The kind of a completion candidate.
PositionEncoding
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 today string (the crate is clock-free; each adapter passes its own date).
link_candidates
Candidates for a link after ^ (issue #1268). Mirrors tag_candidates; the sigil is kept in label and dropped in insert_text.
offset_to_byte
Map a position offset (in the given encoding) into a byte offset into line, 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).