Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/replit/codemirror-lang-solidity

CodeMirror 6 extension for Solidity language support and syntax highlighting
https://github.com/replit/codemirror-lang-solidity

codemirror editor solidity

Last synced: 3 months ago
JSON representation

CodeMirror 6 extension for Solidity language support and syntax highlighting

Awesome Lists containing this project

README

        

# CodeMirror Solidity Language Support

Run on Replit badge
NPM version badge

A CodeMirror extension that provides Solidity syntax highlighting and language support.

![Screenshot](public/cm-solidity-support.png)

### Usage

```ts
import { basicSetup } from 'codemirror';
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { solidity } from '@replit/codemirror-lang-solidity';

const doc = `
pragma solidity ^0.8.10;

contract EtherWallet {
address payable public owner;

constructor() {
owner = payable(msg.sender);
}

receive() external payable {}

function withdraw(uint _amount) external {
require(msg.sender == owner, "caller is not owner");
payable(msg.sender).transfer(_amount);
}

function getBalance() external view returns (uint) {
return address(this).balance;
}
}
`

new EditorView({
state: EditorState.create({
doc,
extensions: [
basicSetup,
solidity,
],
}),
parent: document.querySelector('#editor'),
});
```