Skip to main content

Crate boltz_language

Crate boltz_language 

Source
Expand description

Minimal tree-sitter language registry + highlight query runner.

Deliberately does NOT port Zed’s language crate (22.9kLOC) — ~70% of it is LanguageServer/Capability/diagnostics glue for LSP, which is out of scope for every phase of this plan (see plans/20260705-1722-zed-ui-component-enrichment/plan.md). Only the rope+tree-sitter binding — the ~30% actually needed for syntax highlighting — is reproduced here, written fresh rather than extracted from Zed’s source (that source is entangled with the LSP types being cut).

Structs§

DefaultLanguageRegistry
The default registry: exactly the grammars compiled in via Cargo features (see this crate’s Cargo.tomllang-rust is on by default as the minimal working example; every other grammar is opt-in so consumers only pay its ~200-300KB binary-size cost if they enable it).
Language
A single language: its tree-sitter grammar plus a compiled highlight query. Construction fails only if highlight_query_source doesn’t parse against grammar — a bug in the bundled query, not user input, so a caller-facing Result would just be unwrapped everywhere; panicking here surfaces the bug immediately in development instead.

Traits§

LanguageRegistry
Resolves a Language by file extension (no leading dot, e.g. "rs"). Intentionally minimal: no shebang detection, no content sniffing — see Zed’s LanguageRegistry for that scope, out of bounds here.

Functions§

highlighted_spans
Returns a flat, non-overlapping list of (byte range, tree-sitter capture name) spans covering every highlighted region of source. Gaps between spans are the caller’s responsibility to render in the buffer’s default text color — this never claims to cover the whole string.