Skip to main content

escriba_ts/
lib.rs

1//! `escriba-ts` — tree-sitter host for escriba.
2//!
3//! The tree-sitter host now lives in **`hikari-ts`** (the fleet syntax spine's
4//! tree-sitter backend, self-contained on crates.io). This crate re-exports it
5//! so escriba's consumers keep a stable `escriba_ts::…` surface while the host
6//! itself has exactly one home — the dedup + load-bearing-fix that also breaks
7//! the old `hikari-ts → escriba-ts` dependency inversion (a fleet library must
8//! not depend on an application crate).
9//!
10//! `escriba_ts::Semantic` is `hikari_token::Semantic` (the deduped fleet
11//! vocabulary), carrying the total `From<Semantic> for hikari_core::HlClass`.
12
13extern crate self as escriba_ts;
14
15/// Escriba-local language plugins — the languages the fleet spine does not
16/// ship yet. Moved here with `build_ecosystem`; a language table is language
17/// knowledge, not rendering.
18pub mod langs;
19
20pub use hikari_core::{Ecosystem, Language};
21
22/// The highlight registry escriba renders and reasons through.
23///
24/// **Tree-sitter grammars take precedence** for the languages they cover; the
25/// zero-dep table backend fills every other language; escriba-local tables
26/// register LAST, so an upstream hikari backend for the same language always
27/// wins and a local table retires itself with no edit here.
28///
29/// It lived in `escriba-render::gpu` until 2026-08-08, which put escriba's
30/// language knowledge behind a GPU dependency: the runtime could not ask what
31/// a symbol is without taking on wgpu, and the ratatui face — which needs no
32/// GPU at all — has no syntax highlighting to this day. Registry construction
33/// is not rendering.
34#[must_use]
35pub fn build_ecosystem() -> Ecosystem {
36    let mut eco = Ecosystem::new();
37    let mut covered: Vec<Language> = Vec::new();
38    if let Ok(host) = hikari_ts::TreeSitterHost::builtin() {
39        for p in host.plugins() {
40            covered.push(p.language());
41            eco.register(p);
42        }
43    }
44    for p in hikari_core::langs::builtins() {
45        if !covered.contains(&p.language()) {
46            covered.push(p.language());
47            eco.register(p);
48        }
49    }
50    for p in langs::escriba_local() {
51        if !covered.contains(&p.language()) {
52            eco.register(p);
53        }
54    }
55    eco
56}
57
58pub use hikari_ts::{
59    BufferParser, Grammar, GrammarRegistry, HighlightSpan, Result, Semantic, TreeSitterHighlighter,
60    TreeSitterHost, TreeSitterPlugin, TsEdit, TsError, highlight,
61};