pub struct ManifestSpec {
pub filename: &'static str,
pub name_key: &'static str,
pub self_names: &'static [&'static str],
pub normalize: fn(&str) -> String,
}Expand description
A language is data: a grammar, a capture query, and comment node kinds.
The engine consumes only this struct — adding a language adds a row here
and a .scm file, never engine code.
Query capture contract (the universal primitives):
@def.<kind>whole definition node;<kind>must parse viaSymbolKind::from_str_opt. A definition also scopes what it contains.@namethe definition’s (or scope’s) name node, same match.@qualifieroptional extra scope prefix from the same match (e.g. a Go method receiver type).@scopea node that scopes names but is not itself a symbol (e.g. a Rustimplblock); pairs with@name.@ref.<rel>a reference site;<rel>in {call, use} maps to the relation an eventual binding would carry.@importan imported path; quotes are stripped.@import.module+@import.name— from-style imports (from util import helper,import { helper } from "./util"): the engine joins them with the language’s first path separator so the import binds the item, not just the module.@import.aliaslocal rebinding (asclauses, Go dot imports).@import.starglob semantics: with@import.module(Python*) or alongside a plain@import(bashsource), every top-level name of the module binds.@local(+@local.type) — shadowing bindings, optionally typed.@embedembedded/promoted type members (Go).@trait+@trait.impl— an impl block (@trait.impl) naming the trait it implements (@trait): dynamic-dispatch pairing input.@doca node whose text IS the definition’s doc (Python docstrings): attached to the smallest containing definition, overriding any sibling-comment doc.
Standard tree-sitter text predicates (#eq?, #any-of?, …) are
evaluated by the tree-sitter crate itself and may be used freely
(bash isolates source from ordinary commands this way).
A package manifest declares the mapping between a package’s name
(what imports say) and its directory (what module paths say) — a
naming root the file tree alone cannot reveal. Reading it is
evidence, exactly like reading an import statement. Pure data; the
engine never branches on language.
Fields§
§filename: &'static strManifest file basename (“Cargo.toml”, “go.mod”).
name_key: &'static strKey whose value is the package name (“name” for name = "x",
“module” for module x).
self_names: &'static [&'static str]Path-head aliases meaning “this package’s root” (“crate”).
normalize: fn(&str) -> StringNormalizes the declared name to reference form (dashes to underscores for Rust).