Skip to main content

LanguageDefinition

Trait LanguageDefinition 

Source
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§

Source

fn id(&self) -> LanguageId

Unique identifier for this language (e.g., “rust”, “python”) Must match the key used in settings.toml

Source

fn name(&self) -> &'static str

Human-readable name (e.g., “Rust”, “Python”)

Source

fn extensions(&self) -> &'static [&'static str]

File extensions this language handles (e.g., [“rs”] for Rust) Extensions should NOT include the dot prefix

Source

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

Source

fn create_behavior(&self) -> Box<dyn LanguageBehavior>

Create a behavior instance for this language Behaviors are lightweight and don’t need configuration

Provided Methods§

Source

fn default_enabled(&self) -> bool

Default enabled state for configuration generation This is used when generating initial configuration files

Source

fn is_enabled(&self, settings: &Settings) -> bool

Check if this language is enabled in settings Default implementation checks settings.languages\[id\].enabled

Implementors§