1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Tree-sitter syntax classification.
//!
//! Spans come back in document order, and anything they do not cover is
//! unhighlighted text. No color and no rendering here — kinds map to colors
//! through [`SyntaxPalette::color`](theme::SyntaxPalette::color).
//!
//! [`grammars::LANGS`] is one row per cargo feature, fixed at build time;
//! [`grammars::install`] puts it into [`registry`], which also holds the
//! languages this build can name and not paint, and which
//! [`registry::register`] adds to at runtime.
//!
//! A language may carry an injections query marking regions written in another
//! language — `<script>` and `<style>` in html. The injected name is resolved
//! through [`registry`], so it must be one this build can paint.
//!
//! Every language is configured with [`lang::NAMES`]. A `Highlight` index means
//! whatever the layer that produced it was configured with, and an injected
//! parse returns indices of its own.
//!
//! No locals support: that query is passed empty in
//! [`Lang::compile`](lang::Lang).
//!
//! Does not build for `wasm32-unknown-unknown`.
use Range;
use HighlightKind;
/// The exact tree-sitter these grammars were built against. Reach for a
/// `LanguageFn` through here rather than declaring your own tree-sitter, or
/// [`Lang::new`](lang::Lang::new) will not accept it — two versions in the
/// graph are two unrelated types with one name.
pub use tree_sitter;
pub use tree_sitter_language;
/// The wasm engine, which this crate borrows and never builds.
///
/// `tree_sitter::wasmtime` is the only handle that works: wasmtime arrives
/// through tree-sitter, and a second one in the graph is a second `Engine` type.
pub use wasmtime;
static ENGINE: OnceLock = new;
/// Hand this crate the engine wasm grammars are instantiated in. `false` if one
/// was already set, which leaves the first in place.
///
/// The app owns the engine; this keeps a handle so other consumers share it.
/// Until one is set, a [`Grammar::Wasm`](lang::Grammar::Wasm) cannot load.
pub
/// Highlight `source` as `language` (a fence tag — `rs`, `py`, `tsx`, …).
/// `None` when the tag names no language with a grammar in [`registry`], which
/// holds none until [`grammars::install`] or [`registry::register`] adds one.