Expand description
Language support for moss.
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 function kinds: {:?}", Python.function_kinds());
// Dynamic lookup (from file path):
if let Some(support) = support_for_path(Path::new("foo.py")) {
println!("Language: {}", support.name());
}Re-exports§
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.
- c_cpp
- Shared C/C++ external package resolution.
- 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 (parse only, minimal skeleton).
- 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 (parse only, minimal skeleton).
- 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.
- 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.
- 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.
- yaml
- YAML language support.
- yuri
- Yuri language support (tree-sitter-yuri).
- zig
- Zig language support.
- zsh
- Zsh language support.
Structs§
- Embedded
Block - Embedded content block (e.g., JS in Vue, CSS in HTML)
- Export
- An export declaration
- Grammar
Loader - Dynamic grammar loader with caching.
- Import
- An import statement
- Package
Source - A source of packages to index.
- Symbol
- A code symbol extracted from source
Enums§
- Package
Source Kind - How to traverse a package source directory.
- Symbol
Kind - Symbol kind classification
- Visibility
- Symbol visibility
- Visibility
Mechanism - How a language determines symbol visibility
Traits§
- Language
- Unified language support trait.
Functions§
- has_
extension - Check if name has one of the given extensions
- 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.
- skip_
dotfiles - Check if name is a dotfile/dotdir (starts with ‘.’)
- 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.
- validate_
unused_ kinds_ audit - Validate that a language’s unused node kinds audit is complete and accurate.