feat: add opt-in code completion for mcpp.toml by Ximiaw · Pull Request #4 · mcpp-community/mcpp-vscode · GitHub
Skip to content

feat: add opt-in code completion for mcpp.toml - #4

Closed
Ximiaw wants to merge 8 commits into
mcpp-community:mainfrom
Ximiaw:feat/mcpp-toml-completion
Closed

feat: add opt-in code completion for mcpp.toml#4
Ximiaw wants to merge 8 commits into
mcpp-community:mainfrom
Ximiaw:feat/mcpp-toml-completion

Conversation

@Ximiaw

@Ximiaw Ximiaw commented Aug 7, 2026

Copy link
Copy Markdown
Member

概要

mcpp.toml 增加代码补全(默认关闭,经 mcpp.tomlCompletion 设置开启)。
字段表对齐 mcpp 主仓库文档:docs/zh/05-mcpp-toml.md 为主,并覆盖
02-pack-and-release.md([pack])、03-toolchains.md([toolchain] 平台 pin、
[build].target、linkage 取值)、06-workspace.md([workspace]、
[package].namespace、依赖 spec 的 workspace 继承键)。

补全内容

  • 段头:[package]、[targets.]、[workspace]、[pack] 等 22 个段,
    参数化段插入 snippet 占位符
  • 字段键:按当前段给出,字符串/数组/布尔分别带 "$1" / [$1] / $1 占位
  • 枚举与布尔值:standard、kind、cxx_runtime、cache、c_standard、
    platforms、default_profile/profile、linkage、opt 及布尔键
  • 内联表 spec 键:依赖(version/path/git/features/tools/host-module/
    reexport/workspace 等)与 feature(defines/implies/sources/requires 等)
  • per-glob 旗标键:[build].flags / feature flags 条目内的
    glob/cflags/cxxflags/asmflags/defines
  • 写法模板:[dependencies]、[features] 等开放词汇段的常用写法 snippet
  • 条件段归属:[target.'cfg(...)'.build] 等正确归入对应组;
    未识别的自定义段不提供建议(附录 A:不支持包自定义键)

实现

  • 补全逻辑为不依赖 vscode API 的纯模块(src/mcppTomlCompletion.ts),
    extension.ts 只做 CompletionItem 映射;段头建议覆盖已输入的 [ 前缀
  • 仅绑定 mcpp-toml 语言(精确文件名 mcpp.toml),不影响其他文件
  • 新增 onLanguage:mcpp-toml 激活事件
  • 新增 mcpp.tomlCompletion 设置(resource 作用域,默认 false):
    该功能尚不完善,字段表可能滞后于 mcpp 演进,故默认关闭

测试

  • 新增 26 个 node:test 用例,覆盖段头/键/值/内联表/模板/条件段/
    点式选择器键/未知段等场景
  • 全量 122 个测试通过

Ximiaw added 8 commits August 7, 2026 17:41
Suggest section headers, per-section keys, and enum/boolean values
aligned with docs/zh/05-mcpp-toml.md, plus long-form spec keys inside
dependency and feature inline tables. Registered for the mcpp-toml
language with onLanguage activation; completion logic is a pure module
covered by node:test cases.
Empty positions in [dependencies], [features], [generated_files],
[capabilities], [xlings.workspace], [xlings.envs] and [tools.overrides]
now offer snippet templates of the common forms instead of nothing.
Also use Folder/EnumMember/Snippet completion item kinds so section,
key and value suggestions render with fitting icons.
Add key completions for [build.cxx_runtime] (default/tests),
[resources.version-info] and [runtime."<cap>"] (provider), and the
[build].profile alias of default-profile, all per docs/zh/05-mcpp-toml.md.
Offer glob/cflags/cxxflags/asmflags/defines inside [build].flags and
feature flags inline-table entries (docs/zh/05-mcpp-toml.md section
2.3/2.8). SectionSpec no longer carries key data; section lookup reads
SECTION_GROUPS only.
Bare dotted dependency keys (capi.lua, imgui.backend.glfw_opengl3)
now parse as key=value positions instead of falling back to template
suggestions. Sections are tri-state: document top offers section
headers, unknown custom sections offer nothing (appendix A: custom
toml keys are unsupported), known groups offer their keys.
The mcpp.toml field set spans more than docs/zh/05-mcpp-toml.md:
- [workspace] members/exclude and [workspace.dependencies] with
  namespace subtables (06-workspace.md)
- [package].namespace and the dependency spec workspace = true
  inheritance key (06-workspace.md)
- [toolchain] per-platform pins linux/macos/windows and
  [build].target with the documented target vocabulary
  (03-toolchains.md)
- linkage = "dynamic" alongside static (03-toolchains.md)
[pack] default_mode/include/exclude and [pack.bundle-project]
also_skip/force_bundle per docs/zh/02-pack-and-release.md. All zh docs
(00-10) are now swept for mcpp.toml sections; no others define new
manifest tables.
New mcpp.tomlCompletion boolean setting (resource scope, default
false); the completion provider returns nothing until it is enabled.
@wellwei

wellwei commented Aug 7, 2026

Copy link
Copy Markdown
Member

@Ximiaw

Ximiaw commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@Ximiaw Ximiaw closed this Aug 8, 2026
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.

2 participants