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

The highlighter doesn't work #30

Closed Fallensouls closed 5 years ago

Fallensouls commented 5 years ago

Hello! I tried to use this extension to highlight my Go files on latest VSCode but it didn't work. I followed the guide and set workbench.colorCustomizations, there was nothing changed. QQ图片20190805130149

I have no idea what's wrong, any advice?

EvgeniyPeshkov commented 5 years ago

Hello @Fallensouls , Is Go extension installed in your VSCode? Without this extension VSCode doesn't recognize .go files (they are treated as plaintext) and initialization of {Syntax Highlighter} isn't triggered.

Fallensouls commented 5 years ago

@EvgeniyPeshkov Yeah, I am sure the go extension is installed and I use gopls. Actually, the highlighter seems not work when I open .py files, either. (I have also installed the python extension to test it) If I change editor.tokenColorCustomizations, there is something different but obviously not I want.

QQ图片20190805232843

Do you have any idea about this? Thx : )

EvgeniyPeshkov commented 5 years ago

Hmmm... This is really strange. It's the first time extension doesn't work at all. Could you please check syntax.highlightLanguages in your settings.json? Just in case. This is the only setting that can disable Syntax Highlighter. Also, could you kindly say your OS?

Fallensouls commented 5 years ago

I check it and it is default value. I don't know why workbench.colorCustomizations can't change color but editor.tokenColorCustomizations can, they are using the same analysis tool, right? I am working on Windows x64.

EvgeniyPeshkov commented 5 years ago

workbench.colorCustomizations allows to customize UI colors, while editor.tokenColorCustomizations defines colors of syntax tokens. I've embedded color settings of Syntax Highlighter into workbench.colorCustomizations simply because VSCode extension API do not provide access to token colors. It is strange question, but maybe you have VSCode installed on D:\ drive, or your user folder is not on C:\ drive?

Fallensouls commented 5 years ago

@EvgeniyPeshkov Yeah, actually I have VSCode installed on D:\ drive. When I reinstall it on C:\ drive, the highlighter works correctly. Could you please tell me the reason? Thank you very much!

EvgeniyPeshkov commented 5 years ago

The reason has a long story (=. The main cause is this line in tree-sitter-web implementation. Basically, it checks that provided path is absolute, but in a strange way. It assumes that no protocol must be specified. On Windows though absolute paths have form C:/Users/..., so C is treated as protocol and everything goes wrong. So for Windows I made workaround removing drive letter and using paths of form /Users/... when loading parser's wasm. By default such path points to file on C:\ drive. This fix is so ugly, that I haven't even pushed it to the repo. So this worked in general, not many people install VSCode on secondary drives. Fortunately, the bug is already fixed in this commit. So today I'll publish the new version that will work when VSCode is installed on any drive (=. Thank you very much for discovering this issue.

Fallensouls commented 5 years ago

Thanks for your explanation. Since the new version has fixed the bug, I think we can close the issue.