rescript-lang/nvim-treesitter-rescript

God bless you!

peterpme opened this issue · 5 comments

I was looking for some treesitter rescript support and even considering contributing back, until I saw the grammar.js file and the C code required to make it happen

Just wanted to thank you for making this!

nkrkv commented

😄 Thank you! God, bless open source and its contributors as well. Without all the code I was able to pick here and there as a template or an example I doubt I could make the grammar. And the help of community contributors is invaluable as well.

nkrkv commented

Oh, and your message made me recall that I’ve totally forgot to tag & publish recent fixes as a new version. Done. Thank you =)

I also want to sum to the blessings. This is nice to have, the syntax highlighting is soo much better.
There seems to be also a reason tree sitter syntax, but it misses a proper wrapper like this.
Would you mind sharing the steps you followed to write this plugin? I would like to give a try wrapping the reason tree-sitter one:
https://github.com/IwanKaramazow/tree-sitter-reason

nkrkv commented

Thanks :)

Steps were, basically: take an existing parser source (I‘ve chosen JavaScript repo for some reason) and adapt it to own needs :)

Please, note this is a technical repo. Besides a boilerplate plugin config it only contains artifacts from the main development repo. I’m not sure whether it was a good idea to separate artifacts in such way or not, but it is how things happened.

In summary:

  • Get the most similar parser and use it as a base
  • The most tricky part might be implementing low-lever scanner in C or C++, so use a base language with similar concepts as yours (comments, whitespace)
  • Then add tests, adjust grammar.js, repeat until you satisfied

Just forked your repo. Knowing that I already found all the artifacts you mentioned, and that this repo is just a wrapper, it looks like an easy task.
I'll let you know how good it goes if I success.