0

I'm developing a custom VS Code language support to support some proprietary equipment programming language. The language itself is very similar to C++ (it actually compiles into C++ and then into the executable files). So I thought of some kind of extension that would implement syntax highlighting on top of the default c++ syntax. For example, I have a line of code: SET_HEADER "<path to file>" and I would like to make C++ extension treat it like #inlude.

So I began with injecting TextMate like this in package.json:

     "grammars": [
      {
        "path": "./syntaxes/custom.tmLanguage.json",
        "scopeName": "source.cpp",
        "injectTo": [
          "source.custom"
        ]
      }

and this in my tmLanguage:

{
    "scopeName": "source.cpp",
    "injectionSelector" : "L:keyword.control.directive",
    "name": "Custom",
    "patterns": [
        {
            "include": "#head-file"
        }
    ],
    "repository": {
        "head-file": {
            "name": "keyword.control.directive.include.cpp",
            "match": "SET_HEADER"
        }
    }
}

This event highlights the desired line of code like an include, but it gets immidately overriden by cpp semantic highlighting: enter image description here Could you suggest how to approach this? Is there a way for this to behave like a cpp files with some addons? If I will need to develop a custom language server I will probably abandon this project of mine.

Secret-guy
  • 148
  • 1
  • 7

0 Answers0