VScode extension highighting tips

Reusing parts of another grammar

Could be hard to find, but actually it’s pretty simple:

"patterns": [
  {
     "include": "source.mylanguage#action-body", //Here it is
     "name": "meta.mylanguage.another_language"
  }
]

Custom language highlighting in hovers

You need to inject your language into markdown (package.json):

"grammars": [
  "scopeName": "markdown.mylanguage",
  "path": "./syntaxes/mylanguage-markdown-injection.tmLanguage.json",
  "injectTo": [
    "text.html.markdown"
  ],
  "embeddedLanguages": {
    "meta.embedded.block.mylanguage": "mylanguage"
  }
]

(Also see an excellent example).

Comments