Four new CodeMirror 6 language packages: C, Lua, Luau, and Scala

Hi everyone!

I’ve recently created four new language packages for CodeMirror 6:

  • @fazelstudio/codemirror-lang-c — C language support

  • @fazelstudio/codemirror-lang-lua — Lua 5.4 language support

  • @fazelstudio/codemirror-lang-luau — Luau language support

  • @fazelstudio/codemirror-lang-scala — Scala 3 language support

All four packages use native Lezer grammars and are designed specifically for CodeMirror 6.

C

@fazelstudio/codemirror-lang-c provides C17 syntax support with:

  • Syntax highlighting

  • Incremental parsing

  • Code indentation

  • Code folding

  • Preprocessor directive recognition

  • Support for several commonly used compiler extensions such as __attribute__, __declspec, typeof, and asm

The parser primarily targets ISO C17, with selected C11/C23 features.

GitHub: GitHub - fazel-studio/codemirror-lang-c: C language support for the CodeMirror code editor · GitHub

Lua

@fazelstudio/codemirror-lang-lua targets Lua 5.4 and includes:

  • Full Lua 5.4 syntax

  • Syntax highlighting

  • Autocomplete with Lua standard-library and keyword completions

  • Snippets

  • Automatic indentation

  • Code folding

  • Bracket matching

  • Long strings and comments

  • Labels and goto

  • Lua 5.4 attributes such as <const> and <close>

GitHub: GitHub - fazel-studio/codemirror-lang-lua: Lua language support for CodeMirror 6 · GitHub

Luau

@fazelstudio/codemirror-lang-luau supports Luau syntax, including Lua 5.1 compatibility and Luau-specific features such as:

  • Gradual typing and type annotations

  • Type aliases and generic types

  • Union, intersection, and optional types

  • Type casts

  • export type

  • String interpolation

  • If expressions

  • Compound assignment operators

  • Bitwise operators

  • continue

  • Function attributes

  • Syntax highlighting

  • Automatic indentation

  • Code folding

GitHub: GitHub - fazel-studio/codemirror-lang-luau: Luau language support for the CodeMirror code editor · GitHub

Scala

@fazelstudio/codemirror-lang-scala provides Scala 3 language support, including:

  • Classes, traits, objects, enums, and case classes

  • Pattern matching

  • For-comprehensions

  • Significant indentation / optional braces

  • String interpolation

  • XML literals

  • Generic types with variance

  • Union and intersection types

  • Type lambdas

  • given / using

  • Extension methods

  • Opaque types

  • Scaladoc comments

GitHub: GitHub - fazel-studio/codemirror-lang-scala: Scala language support for the CodeMirror code editor · GitHub

All four packages are released under the MIT license.

The packages are available on npm:

  • @fazelstudio/codemirror-lang-c

  • @fazelstudio/codemirror-lang-lua

  • @fazelstudio/codemirror-lang-luau

  • @fazelstudio/codemirror-lang-scala

I’d really appreciate feedback from the CodeMirror community, especially regarding grammar coverage, parsing edge cases, highlighting, indentation, and areas where these language packages could be improved.

Thanks!

Wow, they just keep coming. Are you LLM-coding these, or are you just really good at writing grammars by this point?

I am currently building a code editor application that uses CodeMirror 6 as its engine. You can check it out at github/fazel-studio.

I created it for my own application’s needs, but I decided to publish it so others can use it as well.