Skip to main content

Module language_host

Module language_host 

Source
Expand description

The language guest→host registration seam (LG.3c).

Design: plugin-languages.md §2.2.

A language-contributing plugin implements the language-plugin world: it imports the language API (register-language) and exports register-languages, which the host calls once to drive declaration. The help-plugin precedent, shape for shape.

§What this module does NOT do

It does not compile the grammar and it does not touch lattice-syntax. The seam collects plain LanguageSpec values — bytes and query strings — and hands them back; lattice-plugin-loader turns them into a real language. That keeps the dependency pointing the way it already does: the loader is the crate that knows about the editor’s native registries, the host is the crate that knows about wasm.

It matters more here than it did for help, because compiling a grammar costs ~100 ms. Doing it inside the guest call would hold the guest’s Store alive across a Cranelift compile for no reason; doing it in the drain, after the store is dropped, is both cheaper and the shape the rest of the loader already has.

§The name is NOT namespaced, unlike help

A help topic is auto-prefixed with the plugin id so a guest cannot squat :help buffers. A language deliberately is not, and the difference is principled rather than an oversight:

  • A language’s name has to match its grammar’s tree_sitter_<name> export and the #+BEGIN_SRC <name> / fenced-code-block identifier users already type. org-plugin.org would match neither.
  • The collision it would defend against is instead refused outright: lattice_syntax rejects any name a bundled language already uses, and rejects a name a different plugin has already claimed. So the property namespacing buys for help is bought here by refusal, which is the right trade when the name is load-bearing rather than decorative.

Structs§

LanguageSpec
One language a guest declared, ready for the loader to compile and register.
WitLanguageSpec
The wire record, as bindgen generates it. Taken whole by validate_language rather than splatted into nine positional arguments — the fields are all String/Option<String>, so a positional signature is exactly the shape a caller silently gets wrong. Everything the host needs to make a language real.

Functions§

validate_language
Validate a guest’s language declaration, or reject it.