jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
154 stars 29 forks source link

Highligting logical operator keywords #570

Closed bitsauce closed 3 years ago

bitsauce commented 3 years ago

I may be doing something wrong here, but I am unable to get VSCode to highlight any logical operator keywords in my cpp files. I've found that the and, or, not keywords can be recolored using the keyword.operator scope, however, this also colors other operators, such as =/+/etc..

Similar issue for lua: https://github.com/microsoft/vscode/issues/71504

EDIT: Forgot to mention I'm using the Dark+ theme

The code with a problem is:

if (not a and (b or c)) { ... }

It looks like:

logical_operators

It should look like:

and, or and not should be purple like the preceding if (or some other color).

jeff-hykin commented 3 years ago

Try running the ">Developer: Inspect Editor Tokens and Scopes" in the command pallet (cmd/ctrl+P) it'll show you all the scopes then you can get the full name instead of just keyword.operator

jeff-hykin commented 3 years ago

Screen Shot 2021-10-04 at 2 29 29 PM

jeff-hykin commented 3 years ago

there's a scope called keyword.operator.wordlike that is probably the one you want to use. It'll work for operators like new too

bitsauce commented 3 years ago

Thanks Jeff! Got it working now by specifying keyword.operator.and.cpp, keyword.operator.or.cpp, etc. 🙂

One question though, do you know if there is a reason these keywords don't work out of the box? Or did I just mess up my dev environment somehow maybe?

jeff-hykin commented 3 years ago

a reason these keywords don't work out of the box?

It sounds like the theme just chooses not to highlight operators . They might consider that a bug but they could consider it a feature

I personally recommend any theme other than the default theme. (and I really mean ANY theme) Here are some pretty good ones: