normalize-languages 0.3.1

Tree-sitter language support and dynamic grammar loading
Documentation

Language support for normalize.

This crate provides the Language trait and implementations for various programming languages. Each language struct IS its support implementation.

Grammars are loaded dynamically from shared libraries via GrammarLoader. Build grammars with cargo xtask build-grammars.

Feature Flags

Languages are gated behind feature flags for customizability:

  • langs-all (default): All languages
  • langs-core: Common languages (Python, JS, TS, Rust, Go, Java, etc.)
  • langs-functional: Haskell, OCaml, Elixir, etc.
  • langs-config: JSON, YAML, TOML, HCL, etc.
  • lang-*: Individual language flags

Example

use normalize_languages::{Python, Language, support_for_path, GrammarLoader};
use std::path::Path;

// Load grammars
let loader = GrammarLoader::new();
let python_grammar = loader.get("python").expect("grammar not found");

// Static usage (compile-time known language):
println!("Python name: {}", Python.name());

// Dynamic lookup (from file path):
if let Some(support) = support_for_path(Path::new("foo.py")) {
    println!("Language: {}", support.name());
}