@codemirror/lang-rust

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

Library
npm
v6.0.2
29stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
23/100Needs Attention
Development Activity8
Maintenance0
Community12
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
48/100Fair
Architecture75
Code Quality50
Innovation40
Learning Curve25

@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 8 apps in this directory

Rust
67%
Other

GitButler

Developer Tools · Devops · AI Development

21,624

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
67
Dependency
Built with
Rust67%
TypeScript20%
Svelte11%
Updated yesterday
Rust
37%
Other

Hook0

Devops

1,484

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
Rust37%
TypeScript12%
Updated 4 days ago
Python
51%
AGPL 3.0

LearnHouse

Learning Management · CMS

2,240

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
Python51%
TypeScript48%
Updated yesterday
Go
61%
MIT

Obot

AI Agents

985

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
85
Repo Health
70
Technical
70
Dependency
Built with
Go61%
Svelte29%
Updated 3 days ago
Python
74%
AGPL 3.0

OpenViking

Databases · AI Development

35,793

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

View details
84
Repo Health
75
Technical
65
Dependency
Built with
Python74%
Rust14%
Updated yesterday
Rust
63%
MIT

PostgresML

Databases · AI Development

6,819

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
Rust63%
JavaScript11%
Updated 1 years ago
TypeScript
99%
Other

Sourcebot

Search · Developer Tools · AI Code Assistants

3,930

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
65
Dependency
Built with
TypeScript99%
Updated 2 days ago
TypeScript
92%
Apache 2.0

superset

AI Code Assistants · AI Development

13,825

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
85
Repo Health
80
Technical
67
Dependency
Built with
TypeScript92%
Updated today

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

Search