georgewfraser / vscode-tree-sitter

Accurate syntax coloring for VSCode using tree-sitter
MIT License
175 stars 25 forks source link

Is it possible to highlight my own language? #29

Closed banacorn closed 4 years ago

banacorn commented 4 years ago

I already have a tree-sitter grammar working on Atom, and I'm trying to port it to VS Code.

截圖 2020-04-23 下午5 52 22

However, after reading the steps in README, I realized that it's probably a bad idea to hardcode and integrate our experimental-ever-changing-toy language into this repo, and pollute everyone's editor.

Is it possible to highlight any tree-sitter grammar in a "plug-and-play" manner?

georgewfraser commented 4 years ago

I think your best bet is to just fork this repo and make your own extension.

banacorn commented 4 years ago

I see, thank you!

I'm wondering if it's a good idea to make this extension language-agnostic. Make tree-sitter grammars standalone extensions, and let user choose which language to highlight by installing this extension and a grammar extension?

georgewfraser commented 4 years ago

You have to compile your grammar into WASM, so hard to see how to make this reusable. Probably better to make a "template" showing the minimal code to tree-sitterize your grammar.

banacorn commented 4 years ago

If I compile my tree-sitter grammar into WASM, and package it as a vscode extension would that make this hypothetical language-agnostic syntax highlighter easier to plug the grammar in?

georgewfraser commented 4 years ago

I'm not sure what you're getting at...if you compile your grammar into WASM and package it as a vscode extension there's not much else you need to do, just use the VSCode syntax coloring API. Most of the complexity in this extension relates to getting the correct colors from the current theme, and VSCode now has an officially supported API for that. I just haven't yet updated this extension to use it---once I do, it will be a very thin shim around tree-sitter.

banacorn commented 4 years ago

I'm just trying to put my tree-sitter grammar to work on VSCode. Thanks for the direction! I'll close this.