Expand description
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 languageslangs-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());
}Re-exports§
pub use query_predicates::satisfies_predicates;pub use ada::Ada;pub use agda::Agda;pub use asciidoc::AsciiDoc;pub use asm::Asm;pub use awk::Awk;pub use bash::Bash;pub use batch::Batch;pub use c::C;pub use caddy::Caddy;pub use capnp::Capnp;pub use clojure::Clojure;pub use cmake::CMake;pub use commonlisp::CommonLisp;pub use cpp::Cpp;pub use csharp::CSharp;pub use css::Css;pub use d::D;pub use dart::Dart;pub use devicetree::DeviceTree;pub use diff::Diff;pub use dockerfile::Dockerfile;pub use dot::Dot;pub use elisp::Elisp;pub use elixir::Elixir;pub use elm::Elm;pub use erlang::Erlang;pub use fish::Fish;pub use fsharp::FSharp;pub use gleam::Gleam;pub use glsl::Glsl;pub use go::Go;pub use graphql::GraphQL;pub use groovy::Groovy;pub use haskell::Haskell;pub use hcl::Hcl;pub use hlsl::Hlsl;pub use html::Html;pub use idris::Idris;pub use ini::Ini;pub use java::Java;pub use javascript::JavaScript;pub use jinja2::Jinja2;pub use jq::Jq;pub use json::Json;pub use julia::Julia;pub use kdl::Kdl;pub use kotlin::Kotlin;pub use lean::Lean;pub use lua::Lua;pub use markdown::Markdown;pub use matlab::Matlab;pub use meson::Meson;pub use nginx::Nginx;pub use ninja::Ninja;pub use nix::Nix;pub use objc::ObjC;pub use ocaml::OCaml;pub use perl::Perl;pub use php::Php;pub use postscript::PostScript;pub use powershell::PowerShell;pub use prolog::Prolog;pub use python::Python;pub use query::Query;pub use r::R;pub use rescript::ReScript;pub use ron::Ron;pub use ruby::Ruby;pub use rust::Rust;pub use scala::Scala;pub use scheme::Scheme;pub use scss::Scss;pub use sparql::Sparql;pub use sql::Sql;pub use sshconfig::SshConfig;pub use starlark::Starlark;pub use svelte::Svelte;pub use swift::Swift;pub use textproto::TextProto;pub use thrift::Thrift;pub use tlaplus::TlaPlus;pub use toml::Toml;pub use typescript::Tsx;pub use typescript::TypeScript;pub use typst::Typst;pub use uiua::Uiua;pub use vb::VB;pub use verilog::Verilog;pub use vhdl::Vhdl;pub use vim::Vim;pub use vue::Vue;pub use wit::Wit;pub use x86asm::X86Asm;pub use xml::Xml;pub use yaml::Yaml;pub use yuri::Yuri;pub use zig::Zig;pub use zsh::Zsh;
Modules§
- ada
- Ada language support.
- agda
- Agda language support.
- asciidoc
- AsciiDoc language support.
- asm
- Assembly language support.
- ast_
grep - ast-grep integration for pattern-based code search.
- awk
- AWK language support.
- bash
- Bash language support.
- batch
- Windows Batch file support.
- c
- C language support.
- caddy
- Caddyfile configuration support.
- capnp
- Cap’n Proto schema support.
- clojure
- Clojure language support.
- cmake
- CMake language support.
- commonlisp
- Common Lisp language support.
- cpp
- C++ language support.
- csharp
- C# language support.
- css
- CSS language support with symbol extraction.
- d
- D language support.
- dart
- Dart language support.
- devicetree
- Device Tree source file support.
- diff
- Diff/patch file support.
- dockerfile
- Dockerfile language support.
- dot
- DOT/Graphviz language support.
- ecmascript
- Shared ECMAScript (JavaScript/TypeScript) support functions.
- elisp
- Emacs Lisp language support.
- elixir
- Elixir language support.
- elm
- Elm language support.
- erlang
- Erlang language support.
- external_
packages - External package resolution - shared types only.
- ffi
- Cross-language FFI binding detection.
- fish
- Fish shell language support.
- fsharp
- F# language support.
- gleam
- Gleam language support.
- glsl
- GLSL (OpenGL Shading Language) support.
- go
- Go language support.
- graphql
- GraphQL language support.
- groovy
- Groovy language support.
- haskell
- Haskell language support.
- hcl
- HCL (HashiCorp Configuration Language) support.
- hlsl
- HLSL (High-Level Shading Language) support.
- html
- HTML language support with symbol extraction.
- idris
- Idris language support.
- ini
- INI configuration file support.
- java
- Java language support.
- javascript
- JavaScript language support.
- jinja2
- Jinja2 template support.
- jq
- jq language support.
- json
- JSON language support.
- julia
- Julia language support.
- kdl
- KDL (KDocument Language) support.
- kotlin
- Kotlin language support.
- lean
- Lean language support.
- lua
- Lua language support.
- markdown
- Markdown language support.
- matlab
- MATLAB language support.
- meson
- Meson build system support.
- nginx
- Nginx configuration file support.
- ninja
- Ninja build system support.
- nix
- Nix language support.
- objc
- Objective-C language support.
- ocaml
- OCaml language support.
- parsers
- Tree-sitter parser singleton and convenience functions.
- perl
- Perl language support.
- php
- PHP language support.
- postscript
- PostScript support.
- powershell
- PowerShell language support.
- prolog
- Prolog language support.
- python
- Python language support.
- query
- Tree-sitter query language support.
- query_
predicates - Predicate evaluation for tree-sitter queries.
- r
- R language support.
- rescript
- ReScript language support.
- ron
- RON (Rusty Object Notation) support.
- ruby
- Ruby language support.
- rust
- Rust language support.
- scala
- Scala language support.
- scheme
- Scheme language support.
- scss
- SCSS language support.
- sparql
- SPARQL query language support.
- sql
- SQL language support.
- sshconfig
- SSH config file support.
- starlark
- Starlark (Bazel/Buck) support.
- svelte
- Svelte language support.
- swift
- Swift language support.
- textproto
- Protocol Buffers text format support.
- thrift
- Apache Thrift IDL support.
- tlaplus
- TLA+ specification language support.
- toml
- TOML language support.
- typescript
- TypeScript language support.
- typst
- Typst language support.
- uiua
- Uiua array programming language support.
- vb
- Visual Basic language support.
- verilog
- Verilog/SystemVerilog support.
- vhdl
- VHDL support.
- vim
- Vim script language support.
- vue
- Vue language support.
- wit
- WebAssembly Interface Types (WIT) support.
- x86asm
- x86 assembly support.
- xml
- XML language support with symbol extraction.
- yaml
- YAML language support.
- yuri
- Yuri language support (tree-sitter-yuri).
- zig
- Zig language support.
- zsh
- Zsh language support.
Structs§
- Container
Body - Location of a container’s body (for prepend/append editing operations)
- Embedded
Block - Embedded content block (e.g., JS in Vue, CSS in HTML)
- Export
- An export declaration
- Grammar
Loader - Dynamic grammar loader with caching.
- Implements
Info - Information about what a class/container implements or extends.
- Import
- An import statement
- Symbol
- A code symbol extracted from source
Enums§
- Grammar
Load Error - Error returned by
GrammarLoader::get. - Symbol
Kind - Symbol kind classification
- Visibility
- Symbol visibility
Traits§
- Language
- Unified language support trait.
- Language
Embedded - Capability trait: language can contain embedded blocks in another language.
- Language
Symbols - Capability trait: language has code symbols (functions, classes, types, etc.).
Functions§
- is_
programming_ language - Check if a path is a programming language (not a data/config format).
- is_
test_ path - Check if a file path is a dedicated test file for its language.
- register
- Register a language in the global registry. Called internally by language modules.
- simple_
function_ symbol - Create a simple function symbol (convenience wrapper).
- simple_
symbol - Create a simple symbol with standard defaults.
- support_
for_ extension - Get language support for a file extension.
- support_
for_ grammar - Get language support by grammar name.
- support_
for_ path - Get language support from a file path.
- supported_
languages - Get all supported languages.
- test_
file_ globs_ for_ path - Get all glob patterns that identify test files for a given language extension.
- validate_
unused_ kinds_ audit - Validate that a language’s unused node kinds audit is complete and accurate.