Contributing
Architecture
src/
extension.ts # thin activation: register providers from the registry
core/ # language-agnostic engine (knows nothing about HCL)
types.ts # LanguageModule / Formatter / FormatOptions contracts
registry.ts # the list of supported languages
formatting/ # provider wiring + formatted-string -> minimal edits
languages/<lang>/ # one self-contained folder per language
manifest.ts # static metadata (id, extensions, grammar, config path)
index.ts # the LanguageModule (exposes createFormatter())
lexer.ts # tokenizer (from Stage 2)
formatter.ts # language-specific passes (from Stage 3)
Dependencies flow one way: languages/ → core/, never the reverse. No
vscode types leak into core/types.ts or language formatters, so the
formatting logic is pure and unit-testable without the editor host.
Adding a new language
- Create
src/languages/<lang>/withmanifest.ts(id, extensions, aliases, grammarscopeName+ path, language-configuration path),index.ts(theLanguageModule), plus itslexer.ts/formatter.ts. - Add a
syntaxes/<lang>.tmLanguage.jsongrammar and alanguage-configuration/<lang>.language-configuration.json. - Append the module to the array in
src/core/registry.ts. - Run
npm run sync-contributesto regeneratepackage.jsoncontributes.languages/contributes.grammarsfrom the registry.
The core/ engine is never modified to add a language.
Adding a new color theme
- Drop the theme JSON into
themes/(the shipped JSONs are the “unified + neutral” look — all chrome surfaces share the editor background). IncludeeditorBracketHighlight.foreground1..6(we set all six to the palette’sopcolor so bracket-pair colorization stays calm) andeditorBracketHighlight.unexpectedBracket.foreground. - Add one entry to
src/themes/manifest.ts(id, pickerlabel,file). - Add the matching palette subset to
src/themes/palettes.ts(bg,bgSide,bgBar,line,dim,accent) — it powers the style-variant overlay (src/themes/variants.ts). - Run
npm run sync-contributesto regeneratecontributes.themes.
Scripts
npm run compile # esbuild bundle -> dist/extension.js
npm run watch # rebuild on change
npm run typecheck # tsc --noEmit
npm run lint # eslint
npm test # unit tests (node:test)
npm run test:grammar # TextMate scope tests
npm run sync-contributes # regenerate package.json contributes from the registry
npm run sweep -- DIR # diff every HCL file under DIR against terraform fmt
npm run build:vsix # vsce package --no-dependencies