pub trait LanguageDefinition: Send + Sync {
// Required methods
fn id(&self) -> LanguageId;
fn name(&self) -> &'static str;
fn extensions(&self) -> &'static [&'static str];
fn create_parser(
&self,
settings: &Settings,
) -> IndexResult<Box<dyn LanguageParser>>;
fn create_behavior(&self) -> Box<dyn LanguageBehavior>;
// Provided methods
fn default_enabled(&self) -> bool { ... }
fn is_enabled(&self, settings: &Settings) -> bool { ... }
}Expand description
Trait for language modules to implement
Each language provides a static definition that the registry uses for discovery and instantiation. This trait follows zero-cost principles by returning borrowed static data.
Required Methods§
Sourcefn id(&self) -> LanguageId
fn id(&self) -> LanguageId
Unique identifier for this language (e.g., “rust”, “python”) Must match the key used in settings.toml
Sourcefn extensions(&self) -> &'static [&'static str]
fn extensions(&self) -> &'static [&'static str]
File extensions this language handles (e.g., [“rs”] for Rust) Extensions should NOT include the dot prefix
Sourcefn create_parser(
&self,
settings: &Settings,
) -> IndexResult<Box<dyn LanguageParser>>
fn create_parser( &self, settings: &Settings, ) -> IndexResult<Box<dyn LanguageParser>>
Create a parser instance for this language Takes borrowed Settings to access language-specific configuration
Sourcefn create_behavior(&self) -> Box<dyn LanguageBehavior>
fn create_behavior(&self) -> Box<dyn LanguageBehavior>
Create a behavior instance for this language Behaviors are lightweight and don’t need configuration
Provided Methods§
Sourcefn default_enabled(&self) -> bool
fn default_enabled(&self) -> bool
Default enabled state for configuration generation This is used when generating initial configuration files
Sourcefn is_enabled(&self, settings: &Settings) -> bool
fn is_enabled(&self, settings: &Settings) -> bool
Check if this language is enabled in settings
Default implementation checks settings.languages\[id\].enabled