pub struct WitLanguageSpec {
pub name: String,
pub extensions: Vec<String>,
pub grammar_name: Option<String>,
pub grammar: Vec<u8>,
pub highlights: Option<String>,
pub folds: Option<String>,
pub injections: Option<String>,
pub indents: Option<String>,
pub textobjects: Option<String>,
pub conceal_rules: Vec<ConcealRule>,
}Expand description
The wire record, as bindgen generates it. Taken whole by
validate_language rather than splatted into nine positional
arguments — the fields are all String/Option<String>, so a
positional signature is exactly the shape a caller silently gets wrong.
Everything the host needs to make a language real.
Fields§
§name: StringThe grammar’s tree-sitter name — org for tree_sitter_org.
Becomes the language id :set filetype and :describe-buffer
report, and the key its queries are cached under. MUST match the
grammar’s exported entry point or the module loads with nothing
to call.
A name that collides with a bundled language is REFUSED, not
shadowed: a plugin silently replacing rust would be a miserable
thing to debug. Claiming a bundled extension is allowed but never
wins, because the native table is consulted first.
extensions: Vec<String>["org"] — extensions that select this language, matched
case-insensitively, with or without a leading dot. A language with
none can never be selected and is refused as a manifest mistake.
grammar_name: Option<String>The grammar’s own entry-point name, when it differs from name.
load_language finds a grammar by its tree_sitter_<x> export, and
that is not always what users call the language. lattice’s own
bundled sql is the case in point: the grammar is
tree-sitter-sequel and exports tree_sitter_sequel, while the
language everyone types is sql. Absent means “same as name”,
which is the common case.
grammar: Vec<u8>The grammar, compiled to wasm. tree-sitter build --wasm produces
one; so does scripts/build-wasm-grammar.sh with nothing but clang
and a rustup toolchain.
highlights: Option<String>Tree-sitter queries, as source. Absent means that feature is simply unavailable for this language — never an error.
All of these compile at REGISTRATION, not first use. A malformed
query is the plugin author’s mistake and must surface at load with
the offending query named; compiling lazily would turn a typo in
folds.scm into “folding silently does nothing”, which is
indistinguishable from the feature not existing and surfaces days
later.
folds: Option<String>§injections: Option<String>§indents: Option<String>§textobjects: Option<String>§conceal_rules: Vec<ConcealRule>H.2: what to hide when rendering this language, empty for most languages.
A refused rule is dropped, not fatal — deliberately unlike a
malformed query above, which rejects the whole language. The
asymmetry is the proportionality: a broken folds.scm means the
language cannot fold at all, and silence there is
indistinguishable from the feature not existing; a broken conceal
rule means one pattern does not hide, the others are unaffected,
and the language is otherwise entirely usable. Losing a language
over a typo in a cosmetic regex would cost far more than it
protects.
Trait Implementations§
Source§impl Clone for LanguageSpec
impl Clone for LanguageSpec
Source§fn clone(&self) -> LanguageSpec
fn clone(&self) -> LanguageSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl ComponentType for LanguageSpec
Source§impl Debug for LanguageSpec
impl Debug for LanguageSpec
impl Lift for LanguageSpec
impl Lower for LanguageSpec
Auto Trait Implementations§
impl Freeze for LanguageSpec
impl RefUnwindSafe for LanguageSpec
impl Send for LanguageSpec
impl Sync for LanguageSpec
impl Unpin for LanguageSpec
impl UnsafeUnpin for LanguageSpec
impl UnwindSafe for LanguageSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more