Skip to content

surrealdb/codemirror


SurrealQL Support for CodeMirror


 

     

@surrealdb/codemirror

This library provides full support for the SurrealQL language within your CodeMirror editors.

Some features include:

  • Intelligent SurrealQL highlighting
  • Folding support for blocks, objects, and arrays
  • Automatic indentation support
  • Support for comment toggling
  • Embedded JavaScript highlighting
  • Support for linting of supported syntax based on version

How to install

Install it with:

# using npm
npm i @surrealdb/codemirror
# or using pnpm
pnpm i @surrealdb/codemirror
# or using yarn
yarn add @surrealdb/codemirror

Next, just import it with:

const { surrealql } = require("@surrealdb/codemirror");

or when you use modules:

import { surrealql } from "@surrealdb/codemirror";

Example usage

import { surrealql } from "@surrealdb/codemirror";

const state = EditorState.create({
    doc: "SELECT * FROM table",
    extensions: [
        surrealql()
    ]
});

const editor = new EditorView({
    parent: document.getElementById("editor"),
    state: state,
});
import { surrealql, surrealqlVersionLinter } from "@surrealdb/codemirror";

const state = EditorState.create({
    doc: "SELECT * FROM table",
    extensions: [
        surrealql(),
		surrealqlVersionLinter("2.0.0")
    ]
});

const editor = new EditorView({
    parent: document.getElementById("editor"),
    state: state,
});

@surrealdb/lezer

This package contains the low level Lezer grammar used to perform SurrealQL syntax highlighting.

We recommend using @surrealdb/codemirror as it extends the grammar with additional CodeMirror supported functionality.

About

An addon for supporting SurrealQL within your CodeMirror editors

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

11 stars

Watchers

7 watching

Forks

Contributors