EvgeniyPeshkov / syntax-highlighter

Syntax Highlighter extension for Visual Studio Code (VSCode). Based on Tree-sitter.
https://marketplace.visualstudio.com/items?itemName=evgeniypeshkov.syntax-highlighter
MIT License
210 stars 43 forks source link

About macro/struct/Enum/Union and local/global variables #2

Closed Lennon925 closed 5 years ago

Lennon925 commented 5 years ago

@EvgeniyPeshkov Hi , I tried syntax-highlighter and I want to set different colors for macro/strcut/Enum/Union variables and local/global variables. Is there a way to set or change source code to add this new feature?

In addition, I found a bug, maybe you can fix it easily. Capture as below: 1

Look forward to your reply.

EvgeniyPeshkov commented 5 years ago

Hello @Lennon925 , Speaking of bug you've found, I suppose I've fixed it. Have you encountered this output in very short file? Please, check out the latest update. New version is cross-platform, so you can install it from Marketplace (directly from VSCode). Just in case you were using .vsix packages from Github. Regarding your question about different colors. Tree-sitter parser, used by Syntax Highlighter, builds entire syntax tree of source file, in contrast to conventional regex parsers. Therefore, it knows surrounding context and can properly identify syntax terms, overcoming limitations of regex. But it's still only syntax parser, it doesn't know anything about things defined in other project files, this is task for language servers. So it's just impossible to tell either some term is class or struct, syntactically they are equivalent.

Lennon925 commented 5 years ago

Hello @Lennon925 , Speaking of bug you've found, I suppose I've fixed it. Have you encountered this output in very short file? Please, check out the latest update. New version is cross-platform, so you can install it from Marketplace (directly from VSCode). Just in case you were using .vsix packages from Github. Regarding your question about different colors. Tree-sitter parser, used by Syntax Highlighter, builds entire syntax tree of source file, in contrast to conventional regex parsers. Therefore, it knows surrounding context and can properly identify syntax terms, overcoming limitations of regex. But it's still only syntax parser, it doesn't know anything about things defined in other project files, this is task for language servers. So it's just impossible to tell either some term is class or struct, syntactically they are equivalent.

You are right. I tried Syntax Highlighter 0.20 which is downloaded from extension marketplace, it's OK.