Hi folks! After NeoVim 0.5.0 was finally released last month I tried syntax highlighting based on Tree-sitter and—wow—it definitely delivers a new level of comfort. Different things have different colors based on the semantic of a language. This makes source code easier to scan and reduces cognitive load.
I haven’t tried Tree-sitter based movements yet but suspect they are awesome too.
So, to have the same comfort as built-in languages provide, I made a Tree-sitter parser for ReScript. You can grab it here:
For a quick comparison take a look of my Vim with stock nvim-rescript
and with extra nvim-treesitter-rescript
:
Before
After
The parser is imperfect yet. Some stuff is missing. Notably, module meta-vodoo (functors, etc) and expressions inside template strings. Some precedences might be messed up and I didn’t optimize performance yet (albeit it parses at orders of a few ms on my typical files). It is because I still don’t understand how Tree-sitter works and made the grammar basically this way:
Contributions are welcome. I’d like the repos to be eventually merged/acquired by nvim-rescript
and tree-sitter
itself.