Skip to main content
A FileFormat for text. Files with a claimed extension import as in-band text documents, editable in the editor and synced across collaborators, and the callbacks below drive the text editor’s intelligence. Documents export as plain blobs, so scripts read them via context:blob(name) at both edit time and runtime. Analysis callbacks are pure functions of (doc, parsed); state lives only in views. parsed carries the cached result of parse, or nil when parse is not implemented.

Fields

name

Display name of the format, e.g. “Markdown”.

extensions

File extensions handled, without dots, e.g. {"md", "markdown"}.

Methods

parse

Optional. Called once per document version; the returned buffer is cached by Rive, keyed to the document’s content, and passed back into every other callback. Within one VM the same buffer object is reused; across VMs the bytes are copied once.

view

Creates the preview for a document on a surface. Each surface gets its own view; a document can be visible on several at once.

highlight

Returns highlight tokens for the document.

diagnostics

Returns problems for the document.

completions

Returns completions at the given position.

hover

Returns hover documentation at the given position, or nil.

format

Returns the fully formatted text, or nil to leave the document unchanged. Rive diffs the result against the current text and applies minimal edits.