Repository navigation
feat: 12-dialect TextMate syntax highlighting - #17
Merged
Merged
Conversation
Generate dialect-aware TextMate grammars for all 12 registered language
IDs (sql/hive/mysql/spark/flinksql/postgresql/bigquery/sqlite/starrocks/
sqlserver/plsql/dameng). Highlighting activates on file open via the
renderer process - no extension activation, no new activationEvents.
- src/grammar/: grammarBuilder consumes each dialect formatter's
tokenizerOptions directly (keyword classes, quote rules, comment
config) - single source of truth, no hand-maintained keyword lists.
Rule order faithfully mirrors Tokenizer.ts's battle-tested priority
sequence (TextMate first-match-wins is isomorphic to it).
- scripts/generate-grammars.ts: CLI generator with oniguruma
compatibility + regex validity validation; fails non-zero on bad data.
- syntaxes/*.tmLanguage.json x12: committed build artifacts (192K).
- Covers keywords (multi-word phrases first), data types, built-in
functions (colored only when followed by "(" to avoid column-name
false positives), TRUE/FALSE/NULL, numbers (hex/sci-notation),
comments, strings incl. dialect forms (PG dollar-quoting, BigQuery
triple quotes, Oracle q'' as cross-line begin/end structures),
variables (@var, ${var}, :bind, &sub), parameter placeholders
(?, :name, @PARAM, :1), operators (incl. <=>, ::, ->), delimiters.
- Adds a uniform AS-alias rule (PG/StarRocks keyword lists omit AS
because the formatter handles aliases via identAlias post-processing).
- .sql now colored by our dialect grammar instead of the VSCode built-in
(rollback = delete the sql entry in contributes.grammars).
- Tests: grammar.test.ts - 19 cases incl. real tokenization smoke tests
via vscode-textmate + vscode-oniguruma (VSCode's own engine,
devDependencies only, excluded from VSIX).
- generate-grammars wired into vscode:prepublish/esbuild chains;
out/grammar/** added to .vscodeignore dead-code exclusions.
Co-Authored-By: Claude Code <noreply@anthropic.com>
- Add .npmrc with legacy-peer-deps: typescript@7 vs typescript-eslint peer range (>=4.8.4 <6.1.0) has been failing npm ci in CI since v2.32.1 - every CI run on main since then failed at the install step (releases were cut with red CI). This matches how the local node_modules was installed. - Declare oxlint/oxfmt/tsx in devDependencies: scripts.lint, scripts.format:check, and the generate-* / esbuild chains invoke them, but they were never declared - the lint step could not run from a clean install. All are excluded from the VSIX via .vscodeignore (verified: 0 devDep files in vsce ls output). - Apply oxfmt to package.json and the two PRD docs (the remaining 19 format issues are pre-existing on main and untouched). Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/grammar/(grammarBuilder + dialectGrammarConfigs)与scripts/generate-grammars.ts:直接消费各方言 formatter 的tokenizerOptions(关键字分类、引号规则、注释配置),零手工清单、零数据漂移(golden 测试保证)syntaxes/*.tmLanguage.json× 12 入库(192K),contributes.grammars注册,generate-grammars接入vscode:prepublish/esbuild脚本链docs/prd/023-语法高亮功能.md(对应 017 规划 F-12,目标 v2.35.0)Test plan
npx tsc --noEmit通过npx oxlint src无告警src/test/grammar.test.ts19 用例全通过(结构/一致性/golden + vscode-textmate + vscode-oniguruma 真实 tokenize 冒烟:规则顺序、词边界、跨行注释/字符串、方言特有引号与占位符)npm run generate-grammars后git diff为空npx vsce ls:12 份语法进包,textmate 测试引擎 devDeps 确认不进包.sql覆盖内置语法后的人工目检(明/暗主题,Developer: Inspect Editor Tokens and Scopes)——如不满意可删除contributes.grammars中sql条目回滚🤖 Generated with Claude Code