This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
TextMate grammar files for the Luau programming language, used for syntax highlighting in editors (VS Code, etc.). Forked from TypeScript-TmLanguage.
npm install # Install dependencies
npm run build:grammar # Build grammar (compiles TS, then generates .tmLanguage and .tmLanguage.json from YAML)
npm test # Build everything + run baseline tests (includes build:grammar and build:tests)
npm run diff # Diff baseline changes (compare tests/baselines vs tests/generated)
npm run accept # Accept new baselines (copy tests/generated/* into tests/baselines/)- Edit
Luau.YAML-tmLanguage(the single source of truth for the grammar) - Run
npm run build:grammarto regenerateLuau.tmLanguageandLuau.tmLanguage.json - Run
npm testto run baseline comparison tests - If tests fail due to intentional changes, review with
npm run diffthennpm run accept
Only modify Luau.YAML-tmLanguage — the .tmLanguage and .tmLanguage.json files are autogenerated and must be committed alongside YAML changes. CI checks for uncommitted diffs in generated files.
Luau.YAML-tmLanguage— The grammar definition. Usesvariablessection for reusable regex patterns (referenced as{{varName}}). These are expanded at build time bybuild/build.ts.build/build.ts— Reads the YAML grammar, expands{{variables}}inbegin/end/matchpatterns, then writes.tmLanguage(plist) and.tmLanguage.jsonoutput files.build/index.d.ts— Type definitions for TmGrammar/TmTheme structures.tests/cases/*.luau— Luau source files used as test inputs.tests/baselines/*.baseline.txt— Expected tokenization output (checked into git).tests/build.ts— Test harness that tokenizes case files using vscode-textmate + oniguruma WASM, producing scope output.tests/test.ts— Mocha test runner that compares generated output against baselines.
Tests are baseline/snapshot-style: each .luau file in tests/cases/ is tokenized and the scoped output is compared against the corresponding .baseline.txt file in tests/baselines/. All token scopes must end with .luau (validated by isValidScopeExtension).