npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fazelstudio/codemirror-lang-luau

v0.1.1

Published

Luau language support for the CodeMirror code editor

Downloads

148

Readme

@fazelstudio/codemirror-lang-luau

NPM version

This package implements Luau (.luau) language support for the CodeMirror code editor: a full Lezer grammar covering Luau syntax including all Lua 5.1 features plus Luau-specific additions: gradual typing with type annotations (: Type), type aliases, generic types with variadic packs (T...), union/intersection/optional types (|, &, ?), type casts (:: Type), export type, typeof types, compound assignments (+=, -=, *=, /=, //=, %=, ^=, ..=), continue statement (context-sensitive), string interpolation (backtick `...{expr}...`), if expressions (if cond then a else b with elseif chains), bitwise operators (&, |, ~, <<, >>), extended string escapes (\x, \u, \z), extended numeric literals (hex 0x, binary 0b, underscore separators), and function attributes (@[attribute]).

This code is released under an MIT license.

Features

  • Full Lua 5.1 compatibility (all valid Lua 5.1 code works)
  • Gradual typing: type annotations, export type, typeof, generic types with packs (T...), union/intersection/optional types, named function types ((a: number) -> string), type casts (::), variadic packs (...T, T...)
  • Compound assignment operators (8 variants)
  • continue statement (context-sensitive keyword, disambiguated vs continue = 5 / continue())
  • String interpolation with backticks (`Hello {name} {expr}`) with escapes
  • If expressions with elseif chains (if c then a elseif d then b else c)
  • Correct operator precedence (or < and < if < cmp < .. right < + - < * / // % < & < ~ < | < << >> < ^ right < unary)
  • Bitwise operators, extended literals, function attributes, --!strict directives
  • Syntax highlighting, auto-indent and code folding for all blocks

Usage

import { EditorView, basicSetup } from "codemirror"
import { luau } from "@fazelstudio/codemirror-lang-luau"

new EditorView({
  parent: document.body,
  doc: `local name: string = "World"\nprint(\`Hello, {name}!\`)`,
  extensions: [basicSetup, luau()],
})

API

luau() → LanguageSupport

Create a language support extension for Luau.

import {EditorView, basicSetup} from "codemirror"
import {luau} from "@fazelstudio/codemirror-lang-luau"

new EditorView({
  parent: document.body,
  extensions: [basicSetup, luau()],
  doc: `export type User = { name: string }\nlocal x: number | string = 42`
})

luauLanguage: LRLanguage

The Luau language object. Can be used for custom configuration:

import {luauLanguage} from "@fazelstudio/codemirror-lang-luau"
luauLanguage.data.of({ autocomplete: myCompletions })

Testing

npm run build:grammar  # generate parser from src/luau.grammar
npm run build          # build ESM + CJS + .d.ts via rollup
npm test               # run 104 fixture tests (mocha)
npm pack --dry-run     # verify only dist/ is published

Grammar highlights

  • External tokenizer (src/tokens.js) for block comments (--[=[ ... ]=]), long strings ([=[ ... ]=]), and interpolated strings (backtick, {expr}, escapes) — contextual (stack.canShift) to avoid conflict with normal strings.
  • continue disambiguation via GLR ~cont split: continue is VariableName when followed by =, ,, (, [, ., : and ContinueStatement otherwise.
  • type / export / typeof treated as contextual keywords via ~type GLR, allowing local type = 10 and type{} call vs type Foo = number.
  • String interpolation: `a {b} c {d+e} f`InterpolatedString with InterpContent + Interpolation{ "{" Expression "}" }.
  • Types: UnionType, IntersectionType, OptionalType (?), ParenType ((A, B)), TableType, FunctionType ((a: number) -> string with FuncParam), GenericType (Foo<T>), TypeofType (typeof(x)), TypeParams (<T...>).

Known limitations

  • Type analysis/inference is out of scope — this package only provides syntax highlighting and parsing, not semantic type checking.
  • goto and labels are not supported (Luau doesn't have them).
  • Module/package system (require) is runtime-level, not part of the grammar.
  • Autocomplete for Roblox APIs is out of scope (use a separate language server).