Skip to content

feat: language configuration for all 12 dialects (comment toggle, bracket matching, auto-closing) - #19

Merged
BryceQin merged 1 commit into
mainfrom
feat/language-configuration
Oct 22, 2026
Merged

BryceQin merged 1 commit into
mainfrom
feat/language-configuration

Conversation

@BryceQin

Copy link
Copy Markdown
Owner

问题

contributes.languages 注册了 12 个语言 ID 但均无语言配置 —— .hql / .mysql / .sparksql 等文件上 Cmd+/ 无反应,括号匹配与引号自动闭合缺失(.sql 可用仅因 VSCode 内置 SQL 扩展自带配置)。

方案

与 v2.35.0 语法高亮同构的生成管线(单一数据源,零手工清单,零漂移):

dialectGrammarConfigs (12 方言 tokenizerOptions)
    → languageConfigBuilder.ts (生成器)
    → language-configurations/*.json × 12 (入库)
    → package.json contributes.languages[].configuration (挂接)
  • src/grammar/languageConfigBuilder.ts:从 lineCommentTypes 派生注释符(-- / /* */)、extraParens ∪ identTypes 派生方括号、stringTypes ∪ identTypes 派生引号自动闭合(含 notIn: ["string", "comment"])
  • scripts/generate-language-configs.ts:构建脚本,接入 vscode:prepublish / esbuild 链
  • language-configurations/ × 12:生成物入库(构建环境可能没有完整工具链),golden 测试防漂移
  • src/test/languageConfig.test.ts:5 个新测试(结构 / golden / package.json 一致性 / 全方言断言 / 方言差异快照)
  • docs/prd/025-语言配置.md:PRD 文档(仓库惯例)

方言差异(自动派生)

  • 方括号 []:Hive / Spark / PostgreSQL / BigQuery / SQLite(经 extraParens)、SQL Server(经 identTypes)
  • 反引号:MySQL 系 8 方言
  • MySQL/BigQuery/StarRocks 的 # 注释保持语法着色但不参与 Cmd+/(VSCode 仅支持单一行注释符,取 SQL 标准 --)
  • 有意不生成 onEnterRules / indentationRules / wordPattern:无数据来源,错误的缩进规则比缺失更糟

验证

  • ✅ tsc --noEmit / oxlint / oxfmt --check / vscode:prepublish 完整打包链
  • ✅ 24/24 测试(新增 5 个 languageConfig + 既有 19 个 grammar 无破坏)
  • ℹ️ 本地 vscode-test 全量运行受沙箱限制(Electron 启动被 SIGKILL),目标测试套件经 mocha TDD 直跑验证;CI 将做全量验证

🤖 Generated with Claude Code

…cket matching, auto-closing)

Problem: contributes.languages registered 12 language IDs but none carried a
language configuration — Cmd+/ did nothing on .hql/.mysql/.sparksql files,
and bracket matching / quote auto-closing were missing (.sql only worked
because VSCode's built-in SQL extension ships its own config).

Generated pipeline (same architecture as the v2.35.0 TextMate grammar work):
- src/grammar/languageConfigBuilder.ts derives comments / brackets /
  autoClosingPairs / surroundingPairs directly from each dialect's
  tokenizerOptions (lineCommentTypes, extraParens, identTypes, stringTypes)
  — single data source, zero manual lists, zero drift from the formatter.
- scripts/generate-language-configs.ts writes 12
  language-configurations/<langId>.language-configuration.json files,
  committed to git; script wired into vscode:prepublish / esbuild chains.
- package.json: contributes.languages[].configuration wired for all 12.

Dialect-aware derivation:
- [] brackets where extraParens or identTypes use them (hive, spark,
  postgresql, bigquery, sqlite, sqlserver); backtick auto-close for the
  mysql-family; quote chars collected from actual stringTypes/identTypes.
- MySQL/BigQuery/StarRocks # comments stay syntax-highlighted only (VSCode
  supports a single lineComment, standard -- wins Cmd+/ toggling).
- Deliberately NOT generated: onEnterRules / indentationRules / wordPattern
  — no data source for them; wrong indentation is worse than none.

Verification: tsc --noEmit, oxlint, oxfmt --check, vscode:prepublish chain,
24/24 tests (5 new languageConfig golden/consistency/derivation tests +
19 grammar tests re-run clean).

Co-Authored-By: Claude Code <noreply@anthropic.com>
@BryceQin
BryceQin merged commit f0a447e into main Oct 22, 2026
1 check passed
@BryceQin
BryceQin deleted the feat/language-configuration branch October 27, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant