#[non_exhaustive]pub struct LanguageSpec {
pub name: CompactString,
pub language: Language,
pub extensions: SmallVec<[CompactString; 4]>,
pub tags_query: Option<Cow<'static, str>>,
pub injections_query: Option<Cow<'static, str>>,
pub merge_adjacent_same_name_definitions: bool,
pub imports: Option<ImportSpec>,
}Expand description
Parsing and query metadata for one registered language.
Create specifications with LanguageSpec::new and its builder methods.
The struct is non-exhaustive so hosts can keep registering custom grammars
when Hearth adds optional language metadata.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: CompactStringWire-stable lowercase language name.
language: LanguageTree-sitter grammar.
extensions: SmallVec<[CompactString; 4]>File extensions recognized for this language, without leading dots.
Tree-sitter tags query used for symbol extraction.
injections_query: Option<Cow<'static, str>>Tree-sitter injection query used to find embedded source languages.
Injected language names resolve against other entries in the same registry. Their symbols and imports retain containing-file locations.
merge_adjacent_same_name_definitions: boolMerge adjacent same-name definitions emitted for one logical symbol.
This is intended for grammars such as Haskell, where each equation of one function is represented by a separate definition node.
imports: Option<ImportSpec>Import extraction strategy, when available.
Implementations§
Source§impl LanguageSpec
impl LanguageSpec
Sourcepub fn new<I, E>(
name: impl Into<CompactString>,
language: Language,
extensions: I,
) -> Self
pub fn new<I, E>( name: impl Into<CompactString>, language: Language, extensions: I, ) -> Self
Creates a language specification with no symbol or import queries.
Extensions must not include a leading dot. Optional behavior can be enabled with the builder methods without coupling hosts to every field.
Configures the tree-sitter tags query used for symbol extraction.
Sourcepub fn with_injections_query(
self,
injections_query: impl Into<Cow<'static, str>>,
) -> Self
pub fn with_injections_query( self, injections_query: impl Into<Cow<'static, str>>, ) -> Self
Configures the tree-sitter query used to locate embedded languages.
Sourcepub const fn with_merge_adjacent_same_name_definitions(
self,
enabled: bool,
) -> Self
pub const fn with_merge_adjacent_same_name_definitions( self, enabled: bool, ) -> Self
Configures whether adjacent same-name definitions form one symbol.
Sourcepub fn with_imports(self, imports: ImportSpec) -> Self
pub fn with_imports(self, imports: ImportSpec) -> Self
Configures import extraction for the language.