Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvim Treesitter support #49

Open
kiuKisas opened this issue Aug 4, 2021 · 7 comments
Open

Nvim Treesitter support #49

kiuKisas opened this issue Aug 4, 2021 · 7 comments

Comments

@kiuKisas
Copy link

kiuKisas commented Aug 4, 2021

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: nvim-treesitter/nvim-treesitter#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.

@nkrkv
Copy link

nkrkv commented Aug 25, 2021

Here’s my take https://github.com/nkrkv/nvim-treesitter-rescript

@kiuKisas
Copy link
Author

kiuKisas commented Aug 25, 2021

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 ?

@nkrkv
Copy link

nkrkv commented Aug 25, 2021

Thank you!

First look, one thing is missing is function definition and call.

🤔 they are here:

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).

@kiuKisas
Copy link
Author

I mean their highlight yeap

@kiuKisas
Copy link
Author

kiuKisas commented Aug 25, 2021

Also, I dunno how things work, but :Telescope treesitter don't show anything. Just to let you know

@nkrkv
Copy link

nkrkv commented Aug 25, 2021

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!

@kiuKisas
Copy link
Author

kiuKisas commented Aug 25, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants