Skip to main content

Crate escriba_vm

Crate escriba_vm 

Source
Expand description

escriba-vm — escriba’s embedded tatara-lisp runtime.

Hosts a tatara_lisp_eval::Interpreter parameterized over EscribaHost. Lisp code runs the full language (arithmetic, lists, if/let/lambda/begin via install_primitives) and interacts with the editor through native functions:

  • reads (cursor-line, current-line, editor-mode, …) answer from a EditorSnapshot captured before eval, so the host owns no borrows and satisfies Interpreter<H>’s H: 'static bound;
  • writes (message, insert, set-option, run-command) push typed HostEffects onto an accumulating log.

The effect boundary is the sandbox seam (the “terreiro”): Lisp can never corrupt editor state directly — it can only request typed, validated mutations that the runtime applies after eval. It is also the seam through which polyglot WASM/WASI plugins are hosted: a plugin authored in any language is driven by the same tatara-lisp host and emits the same typed effects, so the editor’s apply path is identical regardless of plugin language.

This is the imperative tier of escriba’s two-tier programmability model — the declarative tier is escriba-lisp’s def-forms.

Structs§

EditorSnapshot
Read-side snapshot of editor state, captured before eval so Lisp can query without borrowing live state. Integer fields are i64 to marshal directly to the Lisp Int value.
EscribaHost
The Lisp host: a read snapshot + an accumulating effect log. Owned (no borrows) so it satisfies Interpreter<H>’s H: 'static; passed by &mut per eval call.
EscribaVm
escriba’s embedded tatara-lisp runtime. Build once, eval many times; the registered native fns (the editor capability surface) persist across calls.

Enums§

HostEffect
A typed, validated editor mutation requested by Lisp code. The runtime drains these after eval and applies them — Lisp never touches EditorState directly. New capabilities are one variant here + one native fn in [register_editor_fns] + one apply arm in the runtime; nothing else.
VmError