@codemirror/lang-rust

Rust language support for the CodeMirror 6 code editor, powered by a Lezer grammar.

Library
npm
v6.0.2
29 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
23 /100 Needs Attention
Development Activity 8
Maintenance 0
Community 12
Maturity 60
Momentum 12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
48 /100 Fair
Architecture 75
Code Quality 50
Innovation 40
Learning Curve 25

@codemirror/lang-rust adds Rust language support to CodeMirror 6, the extensible code-editor component for the web. It plugs a Lezer-based Rust grammar into CodeMirror’s language system, giving editors accurate syntax highlighting, code folding, and indentation for Rust source files through a single rust() extension.

The package is deliberately minimal: it wraps the @lezer/rust parser in an LRLanguage definition, configures indent rules for if-expressions, statements, match arms, and attributes, and sets up code folding for blocks, lists, and block comments. Language data covers Rust’s comment syntax and bracket-closing rules for its b, r, and br string prefixes, so editors get correct behavior for byte strings and raw strings out of the box.

What You Get

  • A ready-to-use rust() extension that adds full Rust language support to any CodeMirror 6 editor instance.
  • Indentation rules tuned for Rust syntax, including if-expressions, match arms, statements, and attribute items.
  • Code folding support for blocks, lists, and block comments via foldNodeProp.
  • Correct handling of Rust’s b, r, and br string prefixes for bracket-closing behavior.

Common Use Cases

  • In-browser Rust playgrounds - online Rust sandboxes or WASM demo pages use it to give visitors syntax-aware editing without shipping a full IDE.
  • Documentation sites with embedded editors - technical docs that let readers edit Rust code snippets inline rely on it for highlighting and indentation.
  • Code review and diff tools built on CodeMirror - tools that render or edit Rust source alongside review comments use it to keep the code readable.
  • Custom developer tools targeting Rust - any CodeMirror-based editor aimed at Rust developers pulls this in as the language layer instead of hand-writing a grammar.

Under The Hood

Architecture The entire package is a single 35-line file, src/rust.ts, that defines rustLanguage via LRLanguage.define, wrapping the @lezer/rust parser and configuring it with indentNodeProp (for IfExpression, Statement/MatchArm, AttributeItem, and suppressing indent inside strings/block comments) and foldNodeProp (folding Block/List-suffixed nodes and BlockComment regions), plus a languageData object covering comment tokens, indent-on-input, and string-prefix-aware bracket closing. A single exported rust() factory wraps this into a LanguageSupport instance consumed directly by a CodeMirror extensions array. This is the standard shape shared across every @codemirror/lang-* package: no internal layering or dependency injection, just a declarative configuration object keyed directly to @lezer/rust’s grammar node names, so the only thing that would break on a core change is a rename of those node types.

Tech Stack Written in TypeScript, published as a dual ESM/CJS package (dist/index.js and dist/index.cjs with matching .d.ts/.d.cts) via the shared @codemirror/buildhelper dev tool. Its only runtime dependencies are @codemirror/language (for LRLanguage, LanguageSupport, and the indent/fold prop helpers) and @lezer/rust (the actual grammar), both pinned to ^6.0.0/^1.0.0. There is no bundler config in this repository; building and testing are delegated entirely to cm-buildhelper and cm-runtests, scripts supplied by the shared CodeMirror tooling package rather than defined locally.

Code Quality The TypeScript is clean and fully typed, with two /// doc comments documenting the two public exports (rust and rustLanguage) in a format the CodeMirror docs generator consumes. No test files exist in this repository — testing is delegated to a shared cm-runtests harness that lives outside this shallow package mirror, so there is no independent evidence of test coverage from this repo alone. No linter or CI config is present in the repo either; those live in the parent CodeMirror monorepo this package was extracted from.

API Design The public surface is exactly two exports: rust() for the common case of dropping Rust support into an editor, and rustLanguage for consumers who want to extend or compose the language definition themselves (e.g. adding custom autocomplete). This mirrors the API shape of every sibling @codemirror/lang-* package, so a developer who has used any other CodeMirror language package already knows this one’s API with zero additional documentation.

Used by 9 apps in this directory

Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 4 days ago
Rust
37%
Other

Hook0

Devops

1,491

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
82
Repo Health
82
Technical
69
Dependency
Built with
Rust 37%
TypeScript 12%
Updated 1 weeks ago
Python
51%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,301

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
66
Dependency
Built with
Python 51%
TypeScript 48%
Updated 5 days ago
Go
60%
MIT

Obot

AI Agents · Mcp

1,071

An open-source MCP platform for organizations — host MCP servers, run MCP registries, monitor usage, and build agents and chatbots on top of the Model Context Protocol from one self-hosted deployment.

View details
87
Repo Health
70
Technical
70
Dependency
Built with
Go 60%
Svelte 26%
TypeScript 13%
Updated 6 days ago
TypeScript
97%
GPL 3.0

OpenKnowledge

Code Editors · Knowledge Management · Note Taking

4,337

A beautiful, local-first markdown IDE that turns any git repo into a live collaborative workspace for humans and AI coding agents like Claude, Codex, and OpenCode.

View details
79
Repo Health
89
Technical
64
Dependency
Built with
TypeScript 97%
Updated 4 days ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 4 days ago
Rust
63%
MIT

PostgresML

AI Development · Databases

6,825

Run ML training and LLM inference natively inside PostgreSQL with GPU acceleration — no data movement required.

View details
51
Repo Health
76
Technical
64
Dependency
Built with
Rust 63%
JavaScript 11%
Updated 1 years ago
TypeScript
97%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

3,952

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
85
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

14,690

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers