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.

[lang::LANGS] is one row per cargo feature, fixed at build time; it seeds 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.

Re-exports§

pub use tree_sitter;
pub use tree_sitter_language;

Modules§

lang
The languages bezel can highlight: a row per grammar — the fence aliases it answers to, the tree-sitter grammar, and its highlights query. Each row is behind the feature of the same name.
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.