tree-sitter-elm
A tree-sitter grammar for the Elm programming language
Repository Health
Technical Analysis
tree-sitter-elm is a tree-sitter grammar for the Elm programming language, maintained under the elm-tooling organization. It parses Elm source into a concrete syntax tree that updates incrementally as code changes, providing fast, error-tolerant parsing for editors, linters, and code-analysis tooling.
Widely used by the Elm language server and editor integrations, the grammar ships bindings for Rust, Node, and other ecosystems along with editor query files for highlighting and structural analysis.
What You Get
- A complete tree-sitter grammar for Elm with a generated C parser
- Language bindings including a Rust crate and an npm package
- Highlight and query files for editor integration
- Incremental, error-tolerant parsing used by Elm editor tooling
Common Use Cases
- Syntax highlighting for Elm in tree-sitter-based editors
- Structural navigation, folding, and selection in IDEs
- Backing the Elm language server with a syntax tree
- Linting, formatting, and static analysis of Elm code
Under The Hood
Architecture - The grammar is authored in grammar.js using tree-sitter’s DSL and compiled to a C parser with an external scanner for Elm’s layout-sensitive constructs. Bindings expose a language() entry point that consumers register with a tree-sitter runtime.
Tech Stack - The grammar definition is JavaScript; the generated parser is C. A Rust crate is published as tree-sitter-elm, and an npm package is available for Node, built with the standard tree-sitter binding toolchain.
Code Quality - Maintained under the elm-tooling organization with a mature release history (v5.x), a parser test corpus, and query files. Its use by the Elm language server means the grammar is exercised heavily in real editor workflows.
API Design - Usage is a single call: import the binding and pass its language object to a tree-sitter parser. Shipped queries reduce editor glue, and consistent crate/npm naming eases adoption.