Skip to content

feature: C++26 reflection / splice support (^^, splice_specifier) #367

Description

@iliaskarim

Did you check the tree-sitter docs?

Is your feature request related to a problem? Please describe.

Helix's cpp highlight query (runtime/queries/cpp/highlights.scm) already targets C++26 reflection and splice syntax, but tree-sitter-cpp v0.23.4 does not define the corresponding tokens or node types.

When we vendor that query against the published grammar, query compilation fails with TSQueryErrorNodeType. In our case the error offset pointed at the "^^" literal. The splice_specifier node type is also missing from node-types.json.

Because query compilation fails entirely, syntax highlighting breaks for all C/C++ files until the incompatible patterns are removed manually. This affects any downstream tool that vendors Helix queries rather than maintaining its own.

Describe the solution you'd like

Add C++26 reflection and splice support to the tree-sitter-cpp grammar so highlight/locals queries can reference them:

  • Reflection operator: ^^ (reflect_expression or equivalent node type)
  • Splice brackets: [: ... :] (splice_specifier; possibly also splice_type_specifier)

These should appear in node-types.json as valid query targets, similar to how "<=>" is already a grammar token today.

Helix patterns we need the grammar to support:

"^^" ; C++26 reflection operator (reflect_expression)

(splice_specifier ["[:" ":]"] @punctuation.bracket)

Describe alternatives you've considered

  • Strip C++26 patterns from vendored Helix queries before bundling (what we do today). Restores highlighting but loses coverage for reflection/splice when that syntax appears in real code.

  • Vendor upstream tree-sitter-cpp queries only instead of Helix. Avoids the compile error but gives sparser highlighting than Helix.

  • Wait for Helix to gate C++26 query patterns on a newer grammar version. Does not help consumers pinned to the current published tree-sitter-cpp release.

  • Fork and maintain our own cpp highlight query. More ongoing work and diverges from the ecosystem.

Additional context

Environment:

  • tree-sitter-cpp: 0.23.4 (revision f41e1a0)
  • tree-sitter runtime: 0.25.x (via swift-tree-sitter)

Helix cpp highlights (includes C++26 patterns):
https://github.com/helix-editor/helix/blob/master/runtime/queries/cpp/highlights.scm

Upstream tree-sitter-cpp highlights (no C++26 patterns today):
https://github.com/tree-sitter/tree-sitter-cpp/blob/master/queries/highlights.scm

C++26 reflection / splice proposal:
https://wg21.link/p2996

Current v0.23.4 gaps:

  • "^^" is not in src/node-types.json
  • splice_specifier is not a node type in the grammar

Happy to test a branch or help validate node names once there is a draft.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions