Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 2.42 KB

File metadata and controls

40 lines (28 loc) · 2.42 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What This Is

TextMate grammar files for the Luau programming language, used for syntax highlighting in editors (VS Code, etc.). Forked from TypeScript-TmLanguage.

Commands

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/)

Development Workflow

  1. Edit Luau.YAML-tmLanguage (the single source of truth for the grammar)
  2. Run npm run build:grammar to regenerate Luau.tmLanguage and Luau.tmLanguage.json
  3. Run npm test to run baseline comparison tests
  4. If tests fail due to intentional changes, review with npm run diff then npm 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.

Architecture

  • Luau.YAML-tmLanguage — The grammar definition. Uses variables section for reusable regex patterns (referenced as {{varName}}). These are expanded at build time by build/build.ts.
  • build/build.ts — Reads the YAML grammar, expands {{variables}} in begin/end/match patterns, then writes .tmLanguage (plist) and .tmLanguage.json output 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.

Testing

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).