Omnisharp-vscode: Preprocessor Directive Coloring

Created on 16 May 2018  路  8Comments  路  Source: OmniSharp/omnisharp-vscode

Hello. I am not sure if this is possible(or the right place to ask), but my google skills are failing me :)

I'd like to have preprocessor directives matching the color of comments when they are inactive. Here's what it looks like in visual studio:
visual_studio

and here's vs code:
vs_code

Editor-Syntax Highlighting Resolved-External

Most helpful comment

The vscode-ccptools has a feature like this (https://github.com/Microsoft/vscode-cpptools/issues/1466) maybe this can be adopted for the omnisharp plugin?

All 8 comments

Unfortunately, this is not possible to do with a VS Code extension. Syntax highlighting in VS Code is achieved with regular expressions, which doesn't have the context necessary to perform that level of highlighting.

The vscode-ccptools has a feature like this (https://github.com/Microsoft/vscode-cpptools/issues/1466) maybe this can be adopted for the omnisharp plugin?

Unfortunately, this is not possible to do with a VS Code extension. Syntax highlighting in VS Code is achieved with regular expressions, which doesn't have the context necessary to perform that level of highlighting.

Can't you parse .csproj for <DefineConstants>?

@DustinCampbell C/C++ extension has this feature, how did they achieve it and can this be done for C#?

@ssoher If you are using the latest version of the extension, then you can enable the csharp.semanticHighlighting.enabled flag to turn on Semantic Highlighting. You can then use one of our included Visual Studio 2019 themes or define an editor theme tweak in your settings.json for your theme to set the value of the support.other.excluded scope (#808080 perhaps).

@JoeRobich It works great with the included VS themes. But when I add the support.other.excluded scope to my theme it's not recognized. When I check the scope under cursor at the same point VS themes show that scope but my theme only shows source.cs. What am I missing? Thank you very much.

image

If you maintain your own Theme, you will need to add this line to your theme so that it will use the semantic highlighter.

"semanticHighlighting": true,

If you are making tweaks to a community theme, you will need to add the same to your tokenColorCustomizations - see https://github.com/microsoft/vscode/issues/92740#issuecomment-600100176

Amazing, it works now and I've learned something, thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olfek picture olfek  路  3Comments

mattwoberts picture mattwoberts  路  3Comments

ghost picture ghost  路  3Comments

ZeldaZocker picture ZeldaZocker  路  3Comments

IdeoG picture IdeoG  路  3Comments