tree-sitter-scala
A tree-sitter grammar for parsing Scala source code into a concrete syntax tree.
Repository Health
Technical Analysis
tree-sitter-scala is a tree-sitter grammar package that teaches the tree-sitter incremental parsing engine how to parse Scala 2 and Scala 3 source code into a concrete syntax tree. It’s consumed as a Rust crate (or via its C, Python, Go, Node, and Swift bindings) by editors, linters, and static-analysis tools that need fast, error-tolerant, incremental parsing of Scala files.
Because tree-sitter parsers are designed for editor-speed reparsing on every keystroke, tree-sitter-scala underpins Scala syntax highlighting, code folding, and structural navigation in tools like Neovim, Helix, and Zed, as well as any custom tooling built on the tree-sitter Rust bindings.
What You Get
- A generated C parser (
src/parser.c) plus scanner for Scala 2/3 syntax, compiled via thetree-sitter-languagecrate binding - Highlight, tag, and injection query files (
queries/) for syntax highlighting and code-navigation integrations - Bindings for Rust, C, Node.js, Python, Go, and Swift so the same grammar can be embedded in tools written in any of those languages
- A test corpus (
test/corpus,test/highlight,test/tags) validating parser correctness against real Scala syntax
Common Use Cases
- Powering Scala syntax highlighting and code folding in editors built on tree-sitter (Neovim, Helix, Zed)
- Building static-analysis, linting, or code-search tools that need a fast incremental Scala parser
- Embedding Scala-aware structural navigation (jump-to-definition-style queries) in custom developer tooling
- Generating syntax trees for Scala source as part of a documentation or refactoring pipeline
Under The Hood
Architecture: The grammar is defined declaratively in grammar.js using tree-sitter’s DSL, then compiled offline into a generated src/parser.c (a table-driven GLR-style parser) plus a hand-written src/scanner.c for context-sensitive tokens (e.g. Scala’s significant indentation and string interpolation); the Rust crate (bindings/rust/lib.rs) links this C code via a build script and exposes the LANGUAGE constant consumed by the tree-sitter crate. Tech Stack: Core grammar logic is C (generated) plus a JS grammar-definition file; the Rust binding depends only on tree-sitter-language and a C build (cc crate) at build time, keeping the runtime dependency surface minimal; parallel bindings exist for Node (npm), Python (setup.py/pyproject.toml), Go (go.mod), and Swift (Package.swift). Code Quality: The test/corpus directory contains extensive example-based grammar tests exercising Scala 2 and Scala 3 syntax edge cases, plus separate test/highlight and test/tags suites verifying the query files produce correct highlighting/tagging output; grammar changes are validated via tree-sitter test in CI across all bindings. API Design: Consumers interact with a single exported LANGUAGE (Rust) or equivalent per-binding export, following tree-sitter’s standard cross-language convention, so switching from one tree-sitter grammar crate to another requires no API relearning.
Used by 4 apps in this directory
Claude Context
AI Code Assistants
An MCP server and VS Code extension by Zilliz that turns your entire codebase into semantically searchable context for Claude Code, Cursor, and Gemini CLI, using vector embeddings and Merkle-tree change detection.
claude-mem
AI Agents · AI Development
Give your AI coding agents persistent memory — claude-mem captures everything that happens during sessions, compresses it with AI, and surfaces the right context in every future session automatically.
cocoindex
Data Engineering · AI Development
An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.
Tabby
AI Code Assistants
Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.