npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@exercism/codemirror-lang-cpp

v1.0.2

Published

C, C++ and Objective-C language support for the CodeMirror code editor, with autocompletion

Readme

@codemirror/lang-cpp NPM version

Exercism's fork

This is Exercism's fork of @codemirror/lang-cpp. Exercism uses it in the C, C++ and Objective-C editors on exercism.org. It is published on npm as @exercism/codemirror-lang-cpp. Our changes are on the exercism branch, and the main branch follows upstream. Below this section, the README is upstream's.

The fork adds autocomplete to the upstream package. Use cpp() for C++ and c() for C. Both use the same parser, @exercism/lezer-cpp, and offer different names.

  • cpp() offers C++ keywords, fundamental types and literals, the fixed-width integer types, and snippets for main, functions, if, the loops (including range for), switch, classes, structs, enum class, namespaces, try/catch, lambdas, templates, #include, #define, include guards and #pragma once. After std:: it offers the common members of the standard library. If the file says using namespace std;, it offers them without the prefix too.
  • c() offers C99 keywords and types, bool, true, false and NULL, the common functions, types and macros of the C standard library, and snippets for main, functions, if, the loops, switch, structs, typedef struct, enums, #include, #define and include guards.
  • Inside #include <...>, both offer the standard header names.
  • Both offer the names declared in the file that are in scope at the cursor: functions, structs, classes, unions, enums and their enumerators, typedefs and using aliases, template parameters, fields (inside the class), namespaces, macros, parameters, and local, loop and catch variables. A local variable is offered only after its declaration.

objc() gives Objective-C support. It uses the parser's objc dialect, which adds classes, protocols, methods, properties, message sends, @ literals and blocks to C.

  • It offers C's keywords and library, Objective-C's keywords and types (self, nil, YES, id, instancetype, BOOL, NSInteger and others), and the common Foundation classes, functions and constants.
  • When the word starts with @, it offers the @ directives, with snippets for @interface, @implementation, @protocol, @property, @try/@catch, @autoreleasepool, @selector and the array and dictionary literals.
  • Its other snippets cover C's constructs, #import, for ... in, instance and class methods, init, NS_ENUM and blocks.
  • Where a message names its method, as in [list add|, it offers the common Foundation selectors and the selectors of the methods declared in the file. Completing setObject:forKey: inserts setObject:.
  • It offers the names declared in the file where they are in scope: classes, protocols, NS_ENUM types and their values, properties and their _name instance variables, instance variables, C functions and variables, for ... in loop variables, and the parameters of methods, blocks and functions.
  • Inside #import <...>, it offers Foundation/Foundation.h and the C headers.

Completion stays quiet in strings and comments, and after ., -> or :: (apart from std::).

Install

npm install @exercism/codemirror-lang-cpp

Building and testing

To build and test it from a checkout, run npm install (which also builds the package), then npm test.

Contributing

Contributions to this fork follow the Exercism Code of Conduct. Please read about how to contribute to Exercism.


[ WEBSITE | ISSUES | FORUM | CHANGELOG ]

This package implements C++ language support for the CodeMirror code editor.

The project page has more information, a number of examples and the documentation.

This code is released under an MIT license.

We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.

Usage

import {EditorView, basicSetup} from "codemirror"
import {cpp} from "@exercism/codemirror-lang-cpp"

const view = new EditorView({
  parent: document.body,
  doc: `for (int i = 0; i < 1024; i++)\n  cout << elt[i] << "\\n";`,
  extensions: [basicSetup, cpp()]
})

API Reference