Skip to content

Commit eb64724

Browse files
committed
feat: add build.mcpp syntax highlighting
1 parent 1a881a1 commit eb64724

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 更新日志
22

3+
## 0.2.3
4+
5+
- 为精确文件名 `build.mcpp` 增加 C++ 语言关联,复用 VS Code 内置 C++ 高亮和现有模块语法注入;不扩大到所有 `*.mcpp` 文件。
6+
37
## 0.2.2
48

59
- 新增 **mcpp: 一键配置模块代码提示**:自动检测匹配的 clangd,缺失时通过 xlings 下载

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
把 mcpp 工程、C++ 模块语法和官方 clangd 扩展接入 VS Code。
88

9-
当前版本为 `0.2.2`。扩展负责工程发现、clangd 配置、模块状态检查以及常用
9+
当前版本为 `0.2.3`。扩展负责工程发现、clangd 配置、模块状态检查以及常用
1010
mcpp CLI 操作;它不实现新的 C++ 语言服务器,也不替代 mcpp 的构建逻辑。
1111

1212
> 当前完整的模块语义能力只支持 LLVM/Clang 工具链。GCC 和 MSVC 工程仍可使用
@@ -17,7 +17,7 @@ mcpp CLI 操作;它不实现新的 C++ 语言服务器,也不替代 mcpp 的
1717
| 能力 | LLVM/Clang | GCC | MSVC |
1818
| --- | --- | --- | --- |
1919
| 识别 mcpp 工程 | 支持 | 支持 | 支持 |
20-
| `.cppm``.ixx``.mpp``.ccm` 文件关联 | 支持 | 支持 | 支持 |
20+
| `build.mcpp``.cppm``.ixx``.mpp``.ccm` 文件关联 | 支持 | 支持 | 支持 |
2121
| `module``export module``import` 语法高亮 | 支持 | 支持 | 支持 |
2222
| 构建、运行、测试、清理命令 | 支持 | 支持 | 支持 |
2323
| 查看、安装或选择 mcpp 工具链 | 支持 | 支持 | 系统检测与选择 |
@@ -35,7 +35,7 @@ mcpp CLI 操作;它不实现新的 C++ 语言服务器,也不替代 mcpp 的
3535
VSIX,然后在 VS Code 中执行 **Extensions: Install from VSIX...**,或者运行:
3636

3737
```sh
38-
code --install-extension /path/to/mcpp-vscode-0.2.2.vsix
38+
code --install-extension /path/to/mcpp-vscode-0.2.3.vsix
3939
```
4040

4141
安装后确认当前 VS Code profile 中同时存在 `mcpp-community.mcpp-vscode`
@@ -80,7 +80,7 @@ xlings 安装。
8080

8181
### C++ 模块语法高亮
8282

83-
-`.cppm``.ixx``.mpp``.ccm` 关联到 VS Code 内置 `cpp` 语言。
83+
-`build.mcpp``.cppm``.ixx``.mpp``.ccm` 关联到 VS Code 内置 `cpp` 语言。
8484
-`source.cpp` 注入模块语法规则。
8585
- 覆盖 `module``export module``import``export import`、模块名和模块分区。
8686
- 支持尚未输入分号的编辑中间态。
@@ -371,8 +371,8 @@ API、状态栏、任务和 clangd 集成。
371371
版本完全一致的 tag:
372372

373373
```sh
374-
git tag -a v0.2.2 -m "mcpp-vscode 0.2.2"
375-
git push origin v0.2.2
374+
git tag -a v0.2.3 -m "mcpp-vscode 0.2.3"
375+
git push origin v0.2.3
376376
```
377377

378378
`.github/workflows/release.yml` 会校验 tag,执行测试和打包,生成 VSIX 与 SHA-256 文件,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mcpp-vscode",
33
"displayName": "mcpp",
44
"description": "mcpp 与 C++ 模块的 VS Code 集成",
5-
"version": "0.2.2",
5+
"version": "0.2.3",
66
"publisher": "mcpp-community",
77
"license": "Apache-2.0",
88
"icon": "images/logo.png",
@@ -134,6 +134,7 @@
134134
},
135135
"configurationDefaults": {
136136
"files.associations": {
137+
"build.mcpp": "cpp",
137138
"*.ccm": "cpp",
138139
"*.cppm": "cpp",
139140
"*.ixx": "cpp",

test/artifacts.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const root = path.resolve(process.cwd());
2424

2525
test("declares the official clangd dependency and mcpp commands", () => {
2626
const manifest = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) as PackageManifest;
27-
assert.equal(manifest.version, "0.2.2");
27+
assert.equal(manifest.version, "0.2.3");
2828
assert.ok(manifest.extensionDependencies?.includes("llvm-vs-code-extensions.vscode-clangd"));
2929
assert.ok(manifest.activationEvents?.includes("workspaceContains:mcpp.toml"));
3030
assert.equal(manifest.capabilities?.untrustedWorkspaces?.supported, "limited");
@@ -52,13 +52,24 @@ test("declares the official clangd dependency and mcpp commands", () => {
5252
assert.ok(manifest.contributes?.configuration?.properties?.["mcpp.path"]);
5353
assert.ok(manifest.contributes?.configuration?.properties?.["mcpp.modulesSupport"]);
5454
assert.deepEqual(manifest.contributes?.configurationDefaults?.["files.associations"], {
55+
"build.mcpp": "cpp",
5556
"*.ccm": "cpp",
5657
"*.cppm": "cpp",
5758
"*.ixx": "cpp",
5859
"*.mpp": "cpp",
5960
});
6061
});
6162

63+
test("associates the build.mcpp file with the C++ language", () => {
64+
const manifest = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) as PackageManifest;
65+
const associations = manifest.contributes?.configurationDefaults?.["files.associations"] as
66+
| Record<string, string>
67+
| undefined;
68+
69+
assert.equal(associations?.["build.mcpp"], "cpp");
70+
assert.equal(associations?.["*.mcpp"], undefined);
71+
});
72+
6273
test("ships an injection grammar with module-specific scopes", () => {
6374
const manifest = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) as PackageManifest;
6475
const grammar = manifest.contributes?.grammars?.find((item) => item.scopeName === "source.cpp.mcpp-modules");

0 commit comments

Comments
 (0)