@codemirror/lang-cpp

C++ language support for the CodeMirror 6 code editor, with syntax highlighting, indentation, and code folding.

Library
npm
v6.0.3
11stars
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 →
41/100Fair
Architecture70
Code Quality40
Innovation30
Learning Curve25

@codemirror/lang-cpp adds C++ language support to the CodeMirror 6 code editor. It wraps the Lezer C++ grammar in an LRLanguage definition, layering on indentation rules for blocks, case labels, and control statements, code folding for declaration lists and block comments, and language data for comment tokens and bracket-closing behavior around C++‘s prefixed string literals (L, u, U, u8, R, and their raw-string variants).

The package exports two symbols: cppLanguage, the underlying language provider, and cpp(), a LanguageSupport wrapper ready to drop into an editor’s extensions array alongside basicSetup. It follows the same minimal, single-purpose pattern as CodeMirror’s other lang-* packages, delegating parsing to a dedicated Lezer grammar so the language module itself stays a thin configuration layer over indentation and folding behavior.

What You Get

  • cpp() extension - a ready-made LanguageSupport instance you add directly to an editor’s extensions array
  • cppLanguage provider - the underlying LRLanguage definition for building custom language configurations on top of it
  • Indentation rules - continued-statement, case-label, and brace-delimited indentation tuned for C++ control flow
  • Code folding - folding support for declaration lists, compound statements, enumerator lists, field lists, and block comments
  • Prefixed-string awareness - bracket-closing configured for C++‘s L/u/U/u8/R string literal prefixes and raw strings

Common Use Cases

  • Embedding a C++ code viewer - documentation sites or admin tools that need read-only, syntax-highlighted C++ snippets
  • Building a browser-based C++ IDE - online compilers or coding-exercise platforms that need real indentation and folding while editing C++
  • Multi-language code editor - apps built on @codemirror/language-data or a custom language switcher that need a drop-in C++ mode alongside other lang-* packages
  • Teaching tools and code playgrounds - interactive tutorials that highlight and format C++ code samples in-browser

Under The Hood

Architecture The entire module is a single file, src/cpp.ts, exporting cppLanguage and cpp(). cppLanguage is built with LRLanguage.define, configuring the imported @lezer/cpp parser with an indentNodeProp map (continuedIndent for IfStatement/TryStatement, flatIndent for LabeledStatement, a computed indent for CaseStatement, delimitedIndent for CompoundStatement) and a foldNodeProp map covering declaration/enumerator/field/initializer lists plus BlockComment. cpp() then wraps that provider in a LanguageSupport instance. There is no layering beyond this: the package is a thin configuration surface over a parser it does not implement itself, and the only thing that would break if the core abstraction (LRLanguage/LanguageSupport from @codemirror/language) changed is this exact configuration call.

Tech Stack Written in TypeScript, published as dual ESM/CJS (dist/index.js and dist/index.cjs) with generated .d.ts/.d.cts typings. Runtime dependencies are @codemirror/language (^6.0.0) for the LRLanguage/LanguageSupport/indentNodeProp/foldNodeProp APIs and @lezer/cpp (^1.0.0) for the actual C++ grammar. The only devDependency is @codemirror/buildhelper, which provides both the build step (cm-buildhelper src/cpp.ts) and the test runner (cm-runtests) shared across CodeMirror’s language packages, so there is no bespoke bundler or test framework configuration in this repo.

Code Quality No test files exist in this repository; testing is delegated to cm-runtests, a shared harness from @codemirror/buildhelper whose fixtures live outside this package, so behavior can’t be verified from this repo alone. No CI workflow file is present in this GitHub mirror (the README notes the canonical repo has moved to a self-hosted Gitea instance, which may host CI separately). The source itself is small, typed, and consistently named, following the same shape as CodeMirror’s other lang-* packages, but the lack of visible tests or CI in this repo is a real gap for auditability.

What Makes It Unique There is nothing novel here beyond the general Lezer/CodeMirror language-extension pattern already established across the ecosystem — this package is valuable for exactly what it is (a maintained, correct C++ mode) rather than for any distinctive technical approach. It’s a standard, well-worn shape: parser dependency in, indentation/folding config out.

Used by 7 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
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