Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codemirror/lang-cpp

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-cpp

C++ language support for the CodeMirror code editor

  • 6.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @codemirror/lang-cpp?

@codemirror/lang-cpp is a language support package for CodeMirror 6 that provides syntax highlighting, code folding, and other editing features for C++ code.

What are @codemirror/lang-cpp's main functionalities?

Syntax Highlighting

This code sets up a CodeMirror editor with C++ syntax highlighting. The `cpp` function from `@codemirror/lang-cpp` is used to enable C++ language support.

import { cpp } from '@codemirror/lang-cpp';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'int main() { return 0; }',
  extensions: [basicSetup, cpp()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Code Folding

This code sets up a CodeMirror editor with C++ syntax highlighting and code folding capabilities. The `foldGutter` and `foldKeymap` extensions are used to enable code folding.

import { cpp } from '@codemirror/lang-cpp';
import { foldGutter, foldKeymap } from '@codemirror/fold';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'int main() {\n  // code\n  return 0;\n}',
  extensions: [basicSetup, cpp(), foldGutter(), foldKeymap]
});

const view = new EditorView({
  state,
  parent: document.body
});

Autocomplete

This code sets up a CodeMirror editor with C++ syntax highlighting and autocomplete functionality. The `autocompletion` extension is used to provide autocomplete suggestions.

import { cpp } from '@codemirror/lang-cpp';
import { autocompletion } from '@codemirror/autocomplete';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  doc: 'int main() {\n  // code\n  return 0;\n}',
  extensions: [basicSetup, cpp(), autocompletion()]
});

const view = new EditorView({
  state,
  parent: document.body
});

Other packages similar to @codemirror/lang-cpp

Keywords

FAQs

Package last updated on 24 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc