feat: add opt-in code completion for mcpp.toml - #4
Conversation
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.
|
维护者结论:这个 PR 暂时保留,不关闭,但当前不合并。补全功能有用户价值,默认关闭和 resource 级设置也合理;主要问题是当前实现把快速演进的 mcpp manifest schema 复制成扩展内约 659 行手写表,提交时已经与权威解析器发生漂移。继续逐项补字段之前,应先确定可维护的数据来源和功能范围。 当前确认的问题:
建议先补一个需求/设计 Issue,在以下方向中作出选择:
不建议把“默认关闭”作为生成无效配置的兼容策略。如果继续当前手写 schema 路线,至少需要逐项对齐当前 mcpp parser,并增加 provider 层和 parser 契约测试。 我在该提交上独立复核了 |
|
Superseded by #9 |
概要
为
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 继承键)。
补全内容
参数化段插入 snippet 占位符
platforms、default_profile/profile、linkage、opt 及布尔键
reexport/workspace 等)与 feature(defines/implies/sources/requires 等)
glob/cflags/cxxflags/asmflags/defines
未识别的自定义段不提供建议(附录 A:不支持包自定义键)
实现
extension.ts 只做 CompletionItem 映射;段头建议覆盖已输入的
[前缀onLanguage:mcpp-toml激活事件mcpp.tomlCompletion设置(resource 作用域,默认 false):该功能尚不完善,字段表可能滞后于 mcpp 演进,故默认关闭
测试
点式选择器键/未知段等场景