Sublime Forum

Extending C++ syntax with more types

#1

I’m trying to extend the syntax for C++ to include a few extra variables, but to otherwise use the out-of-the-box syntax. When I create a syntax like this

contexts:
  main:
    - match: \b(int32|int64|float32|float64)\b
      scope: storage.type.c

it highlights the types I want fine. To make it use the default C++ highlighting otherwise, I changed it to this.

contexts:
  main:
    - match: \b(int32|int64|float32|float64)\b
      scope: storage.type.c
    - match: .
      push: "Packages/C++/C++.sublime-syntax"

However, this leads to my types not getting highlighted anymore. It also makes it so the // SYNTAX TEST "filename" at the start of my testing file doesn’t get highlighted as a comment.

Based on this, I think my problem is with the - match: ., but I’m not sure how to solve this. Basically, I want to apply C++ syntax everywhere except onto the types I’m concerned with (though I don’t actually mind the scopes C++ adds by default, just that it’s presently making the scopes I add go away).

0 Likes