Nvim Treesitter support
Not sure if I should post it here, but the tree-sitter build-in neovim doesn't support rescript. It's a great improvement for color highlight and other plugins features ( I think about blankline or telescope preview for example). With the recent release of nvim 0.5, it's now a must have.
If we look at the elm way, they have a dedicated repo: https://github.com/elm-tooling/tree-sitter-elm for the "regular" tree-sitter as a common based, then we can have the slightly different version targeting nvim as explain here: https://github.com/nvim-treesitter/nvim-treesitter/issues/529
Posting it here, as vs code took the opposite way to deprecied tree-sitter so it primaly focus neovim. Also, the current highlight syntax have some issue, it can fixed it at least for neovim, in what it seems to be an easier way than through LSP.
I will probably not have time to take care of it, but I post it here for the record anymway.
Here’s my take https://github.com/nkrkv/nvim-treesitter-rescript
Awesome ! You rock, that's a good start :) First look, one thing is missing is function definition and call. But definitely cool ! Did you submit it to the official nvim tresitter ?
Thank you!
First look, one thing is missing is function definition and call.
:thinking: they are here:
- https://github.com/nkrkv/tree-sitter-rescript/blob/d4329e03a08f303deffe8856e48b0a0b6fdd05e8/grammar.js#L452-L455
- https://github.com/nkrkv/tree-sitter-rescript/blob/d4329e03a08f303deffe8856e48b0a0b6fdd05e8/grammar.js#L338-L348
Or do you mean their highlighting queries?
Did you submit it to the official nvim tresitter ?
No. I wanted to give it some trial among rescripters because I suspect it’s incomplete yet and it would be harder to manage within 3-rd party repo (or how things done, I don’t know).
I mean their highlight yeap
Also, I dunno how things work, but :Telescope treesitter don't show anything. Just to let you know
I mean their highlight yeap
I’m not sure how practical it is for FP-like language:
Array.map(myFunc) // Tree-sitter have no idea that myFunc is a function, so will not highlight
Array.map(myFunc(_)) // The same thing, but will highlight
// ... so the same thing highlights differently
// Another case
let fn1 = (x, y) => { blabla } // Will highlight fn1
let fn2 = someHighOrderFunc(fn1) // Will not highlight fn1
// Another case
let myHof = (fn) => {
let x = fn(1, 2, 3) // Should fn be highlighted as @parameter.reference or @function?
// ...
}
I haven’t found yet a description or discussion on this topic. Things are clear for languages like C where functions live in another land, but not so clear for FP. Need to take a look at parsers for similar langs.
Also, I dunno how things work, but :Telescope treesitter don't show anything. Just to let you know
Another reason for me to finally try Telescope. Thank you!
Array.map(myFunc) // Tree-sitter have no idea that myFunc is a function, so will not highlight
Array.map(myFunc(_)) // The same thing, but will highlight
// ... so the same thing highlights differently
The second is a function call, so it make sense to me that this one is highlight. The first one is a variable, so.. also make sense to me that it's not highlight.
// Another case
let myHof = (fn) => {
let x = fn(1, 2, 3) // Should fn be highlighted as @parameter.reference or @function?
// ...
}
Good catch.. I think like @parameter.reference make more sense.. I guess ? but that's just my opinion..
To be honest, I was only considering:
let f1 = (x) => x
let a = 2
a->f1 (f1 should be highlight)
So I guess we need to think more about it.. Definitely something we should talk about, it's not as obvious as I though.
Maybe have a look at the ocaml way ? code: https://github.com/tree-sitter/tree-sitter-ocaml/blob/master/queries/highlights.scm example: https://github.com/tree-sitter/tree-sitter-ocaml/blob/master/test/highlight/functions.ml