Socket
Socket
Sign inDemoInstall

@codemirror/lang-rust

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-rust

Rust language support for the CodeMirror code editor


Version published
Weekly downloads
121K
decreased by-19.85%
Maintainers
2
Weekly downloads
 
Created

What is @codemirror/lang-rust?

@codemirror/lang-rust is a language support package for the CodeMirror 6 code editor, specifically designed to provide syntax highlighting, code folding, and other language-specific features for the Rust programming language.

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

Syntax Highlighting

This feature provides syntax highlighting for Rust code. The code sample demonstrates how to set up a CodeMirror editor with Rust syntax highlighting.

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

const state = EditorState.create({
  doc: 'fn main() { println!("Hello, world!"); }',
  extensions: [basicSetup, rust()]
});

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

Code Folding

This feature allows for code folding in Rust code. The code sample shows how to set up a CodeMirror editor with Rust syntax highlighting and code folding capabilities.

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

const state = EditorState.create({
  doc: 'fn main() { println!("Hello, world!"); }',
  extensions: [basicSetup, rust(), foldGutter()]
});

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

Auto-completion

This feature provides auto-completion for Rust code. The code sample demonstrates how to set up a CodeMirror editor with Rust syntax highlighting and auto-completion.

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

const state = EditorState.create({
  doc: 'fn main() { println!("Hello, world!"); }',
  extensions: [basicSetup, rust(), autocompletion()]
});

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

Other packages similar to @codemirror/lang-rust

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