tree-sitter-rescript icon indicating copy to clipboard operation
tree-sitter-rescript copied to clipboard

Function highlight ?

Open kinooyume opened this issue 4 years ago • 4 comments

As we discuss here : https://github.com/rescript-lang/vim-rescript/issues/49#issuecomment-905650526

should we highlight functions ?

kinooyume avatar Aug 25 '21 16:08 kinooyume

@nkrkv i'm playing with the tree sitter, I added some highlights. I don't know the status of this project, but if you wish I can open a PR.

Demo: image

aspeddro avatar Nov 16 '21 16:11 aspeddro

Thanks! I’ve read that the idea of Tree-sitter based highlighting is to color the same symbols using the same colors. So that if you see several pink words in random places, you know they refer to the same thing. From that point of view, highlighting function use and not highlighting its declaration is incorrect. And in a language like ReScript where all functions are lambdas the true way is hardly applicable at all.

I might be mistaken. Let’s leave the issue floating… If more people would like the call-only highlight… well, it would be worth doing so.

nkrkv avatar Nov 17 '21 10:11 nkrkv

Thanks for the answer. The declaration can be highlighted as @function, an example:

(let_binding
  (value_identifier) @function
  (function))

I don't know if this one covers everything

image

aspeddro avatar Nov 17 '21 11:11 aspeddro

So, the missing case is when we have higher order function ? Seems good enough to me. Not sure if tree-sitter will/can detect that in the future, probably not :/

kinooyume avatar Nov 18 '21 19:11 kinooyume