2

I'm writing an extension for Visual Studio Code which features syntax highlighting for a scripting language. I was able to color many important elements via a TextMate grammar file. There are many lines where I would not know if a captured string refers to a user defined class (for a static call, for instance), or an instance of a class/variable until I perform analysis in code.

Is there a way I can dynamically highlight syntax via code in Visual Studio Code or any alternatives for achieving this?

E_net4
  • 27,810
  • 13
  • 101
  • 139
DS7
  • 130
  • 9
  • If you don't mind, can you please share the tmlanguage.json. It will be really helpful for my extension development. – usmanharoon Sep 26 '22 at 16:37

1 Answers1

3

What you are asking for is semantic coloring. It is not supported as of VS Code 1.35. You could try to emulate it using decorators, but the decorators can easily get out of sync with the rest of the highlighting during editing

This VS Code issue tracks adding semantic coloring to VS Code.

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
  • Thank you. I've looked into decorators and came to the same conclusion, it's a bit messy/hacky if I'm trying to match the static grammar file styles, so I'm going to avoid that. I'll be watching the issue for updates. – DS7 May 13 '19 at 07:19
  • 1
    The ticket that Matt mentioned has now been closed: the feature has been released. https://github.com/microsoft/vscode/wiki/Semantic-Highlighting-Overview – Chaouki Dhib Apr 19 '20 at 16:21