Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

@allegro/codemirror-lang-opel

OPEL language support for CodeMirror — syntax highlighting, indentation, folding, autocomplete, and linting.

Installation

npm install @allegro/codemirror-lang-opel

Usage

Quick start

import { opelExtensions } from '@allegro/codemirror-lang-opel';

const extensions = opelExtensions();

With EditorView

import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { opelExtensions } from '@allegro/codemirror-lang-opel';

const state = EditorState.create({
  doc: 'if (true) { val x = 1 }',
  extensions: opelExtensions({
    enableLinter: true,
    includeLintGutter: true,
    warnOnLambdaDefinitions: true,
    runtimeGlobals: ['ctx', 'env'],
  }),
});

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

Available options:

  • enableLinter (default: true)
  • includeLintGutter (default: true)
  • warnOnLambdaDefinitions (default: true) — emits a linter warning for each lambda definition.
  • runtimeGlobals (default: []) — variable names treated as globally available at runtime, so linter does not report them as undeclared.

Development

Prerequisites

Node ≥ 22 and npm ≥ 10.

Start dev mode

npm run dev

This command:

  1. Regenerates the Lezer parser from src/grammar/opel.grammar once at startup.
  2. Starts Storybook at http://localhost:6006 for an interactive playground.
  3. Watches src/grammar/opel.grammar — any grammar change automatically reruns generate-parser, which Vite hot-reloads into the running stories.

Grammar-only watcher

npm run generate-parser:watch

Build

npm run build

Runs parser generation, TypeScript type-check, and Rollup bundling. Output goes to dist/.

Stories

Stories live in examples/storybook/stories/ and import directly from src/, so parser changes are immediately reflected without a separate build step. Each story category file also generates its own Docs page (autodocs), so OPEL/Basic Expressions, OPEL/If Else, etc. have separate category-level documentation.

Story group What it shows
Basic Expressions Arithmetic, string concat, comparisons
Variable Declarations val declarations, scope, duplicate warning
If Else Conditional expressions, nesting
Linting Syntax errors, undeclared variables, warnings

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages