Skip to content

haoqixu/codemirror-lang-hcl

Repository files navigation

codemirror-lang-hcl

NPM Version

This package implements HCL language support for the CodeMirror code editor.

The lezer grammar is ported from tree-sitter-hcl.

Getting Started

Installation

npm i codemirror-lang-hcl

Usage

import {EditorView} from '@codemirror/view';
import {EditorState} from '@codemirror/state';
import {hcl} from "codemirror-lang-hcl";

const state = EditorState.create({
	doc: 'my hcl code',
	extensions: [
		hcl(),
	]
});

const view = new EditorView({
	parent: document.querySelector('#editor'),
	state
});

Example

This example is from tree-sitter-hcl.

Theme: https://thememirror.net/tomorrow.

example.png