@codemirror/language

Language support infrastructure for the CodeMirror 6 editor: parsing, indentation, code folding, bracket matching, and syntax highlighting.

Library
npm
v6.12.4
32stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture80
Code Quality62
Innovation74
Learning Curve68

@codemirror/language is the language-support layer of the CodeMirror 6 code editor. It defines the core Language and LRLanguage classes that wrap a Lezer parser and expose it to the editor as an incrementally-updated syntax tree, plus the facets and node-prop conventions that let a language attach indentation rules, foldable regions, bracket matching, and syntax highlighting to that tree.

Rather than shipping a specific language mode, the package provides the building blocks that CodeMirror’s per-language packages (@codemirror/lang-javascript, @codemirror/lang-python, etc.) and third-party language extensions are built on top of, along with a StreamLanguage adapter for porting legacy CodeMirror 5-style line-based parsers into the same system.

What You Get

  • Language, LRLanguage, and StreamLanguage classes for defining a language from a Lezer parser or a legacy stream/line parser
  • syntaxTree()/ensureSyntaxTree() APIs for reading the current (or forced) parse tree from editor state
  • An indentation system (indentService, indentNodeProp, continuedIndent, delimitedIndent) for computing per-line indent from the syntax tree
  • Code folding (foldService, foldNodeProp, foldGutter, codeFolding) driven off the same tree
  • Bracket matching (bracketMatching) and tag-based syntax highlighting (HighlightStyle, syntaxHighlighting, defaultHighlightStyle)

Common Use Cases

  • Implementing a new language mode for CodeMirror 6 by wrapping a Lezer grammar in an LRLanguage
  • Adding editor features (indent-on-enter, code folding, bracket matching, syntax-aware theming) that need to read the current syntax tree
  • Porting an existing CodeMirror 5 mode to CodeMirror 6 via the StreamLanguage/StreamParser adapter
  • Building custom tooling (linters, formatters, structural navigation) on top of the live incremental parse tree

Under The Hood

Architecture: The package centers on the Language class (src/language.ts), which pairs a Lezer Parser with a language-data Facet and exposes the parsed document as a StateField-backed syntax tree, kept incrementally up to date by a background ViewPlugin (LanguageState, ParseContext) that reparses only changed regions rather than the whole document. LRLanguage specializes this for Lezer LR grammars, while stream-parser.ts implements a StreamParser/StreamLanguage adapter that wraps CodeMirror 5-style, line-based token parsers into a Lezer-compatible incremental Parser, letting legacy modes plug into the same tree-based pipeline. Everything downstream is built as independent modules that read that shared tree through Lezer NodeProps registered on the grammar: indent.ts computes per-line indentation via an indentService facet and node-prop-driven strategies (continuedIndent, delimitedIndent, flatIndent); fold.ts derives foldable ranges via foldService/foldNodeProp and renders a foldGutter view plugin; matchbrackets.ts walks the tree to find and highlight matching bracket pairs; and highlight.ts maps Lezer highlighting tags to CSS via HighlightStyle/syntaxHighlighting. All of these compose as ordinary CodeMirror 6 Extensions (facets, state fields, view plugins), so a language author only needs to attach node props to their grammar to get indentation, folding, and highlighting largely for free.

Tech Stack: 100% TypeScript, published as dual ESM/CJS (dist/index.js / dist/index.cjs) with bundled .d.ts types via @codemirror/buildhelper. Runtime dependencies are entirely within the CodeMirror/Lezer ecosystem: @codemirror/state and @codemirror/view (^6.x) for the extension/state model, @lezer/common, @lezer/highlight, and @lezer/lr (^1.x) for tree/parser primitives, and style-mod for scoped stylesheet injection. There are no dependencies outside that ecosystem, and the test-only devDependency on @lezer/javascript is used purely as a sample grammar for the test suite. The build/test scripts (cm-buildhelper, cm-runtests) are the same shared tooling used across all CodeMirror 6 monorepo packages, so the package follows CodeMirror’s standard release and versioning conventions.

Code Quality: The test/ directory (three files, ~225 lines) exercises incremental parsing correctness and timing (test-syntax.ts), the stream-parser adapter (test-stream-parser.ts), and folding (test-fold.ts) using the lightweight ist assertion library in a describe/it structure. Coverage is real but narrow relative to the ~2,800 lines of source — there’s no dedicated test file for highlight.ts or matchbrackets.ts in the sampled suite. The source itself is unusually well documented: 233 /// doc comments across the module (used to generate the published API reference at codemirror.net/docs/ref), consistent camelCase naming, and explicit thrown Errors for invalid input (e.g. indentUnit validation) rather than silent failures or fallbacks.

API Design: The entire public surface is re-exported from a single src/index.ts, so consumers get one import path (@codemirror/language) covering language definition, indentation, folding, highlighting, and bracket matching rather than having to reach into submodules. The API follows CodeMirror 6’s own Facet/StateField/NodeProp conventions throughout, which is a low-friction, idiomatic fit for anyone already building on @codemirror/state/@codemirror/view, but represents real boilerplate and a non-trivial ramp-up for newcomers unfamiliar with that extension model. The README supplies one concrete usage example (defining an LRLanguage from a Lezer parser) and links out to the full hosted API reference rather than embedding extensive inline examples.

Used by 64 apps in this directory

Go
72%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

36,573

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
91
Repo Health
76
Technical
67
Dependency
Built with
Go72%
Vue28%
Updated today
TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
94%
MIT

Actual

Invoicing Finance

28,224

Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.

View details
93
Repo Health
85
Technical
77
Dependency
Built with
TypeScript94%
Updated yesterday
Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
TypeScript
69%
Other

Budibase

Low Code Platforms · No Code Platforms

28,220

Build AI agents, automations, and internal apps on a single open-source platform with full self-hosting control.

View details
92
Repo Health
81
Technical
63
Dependency
Built with
TypeScript69%
Svelte26%
Updated today
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
Go
62%
Apache 2.0

Coroot

Analytics · Monitoring

7,877

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
65
Dependency
Built with
Go62%
Vue36%
Updated yesterday
Ruby
62%
GPL 2.0

Discourse

Community

47,672

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby62%
JavaScript31%
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