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

Block-local variables with single letter names are highlighted as interpreter variables

Open catniptwinz opened this issue 3 years ago • 5 comments

With highlighting enabled, {|x| x } results in the second x (in the body of the function) being highlighted as if it were a single-letter interpreter variable, whereas {|foo| foo } highlights both foo correctly.

I'm on the current commit, per nvim-treesitter's lockfile.json:

  "supercollider": {
    "revision": "a7201b61779be59ac0fc0d118746c886dbc3edbd"
  },

catniptwinz avatar Jan 16 '22 22:01 catniptwinz

Thanks ! Will look into it

madskjeldgaard avatar Jan 16 '22 22:01 madskjeldgaard

This is actually a harder one to fix than one would think. I'll have to think about this some more since those one letter interepreter variables are kind of magic. hmm...

madskjeldgaard avatar Jan 20 '22 18:01 madskjeldgaard

No worries! Work has me pretty busy right now or I'd have taken a deeper look at it myself. Just wanted to leave a note here as I turned highlighting back on after the last update to see how things had progressed and noticed the issue with single-letter variable names. iirc it's been present all along and is not a regression. Would be nice to fix eventually as foo.do({|x, i| ... }) is such a common idiom.

catniptwinz avatar Jan 20 '22 20:01 catniptwinz

This is indeed tricky. I guess we can probably treat interpreter variable as a regular variable here. It seems that the C tree-sitter parser doesn't distinguish between global and local variables either. IMO, doing this is good enough for a syntax parser.

xunil-cloud avatar Sep 21 '24 10:09 xunil-cloud