Skip to main content

Crate syntax

Crate syntax 

Source
Expand description

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.

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.

Does not build for wasm32-unknown-unknown.

Re-exports§

pub use tree_sitter;
pub use tree_sitter_language;

Modules§

document
A source kept parsed across edits.
grammars
The grammars this crate links in, each behind the feature of its name.
lang
A language row: the fence aliases it answers to, the tree-sitter grammar, and its highlights query.
registry
Which languages this process can name, and which of those it can paint.
session
Where a parse happens: one parser, and the queries compiled against it.

Functions§

highlight
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.