tree-sitter / tree-sitter-python

Python grammar for tree-sitter
MIT License
360 stars 132 forks source link

Parameter highlight group doesn't capture references in body #247

Closed psi4j closed 11 months ago

psi4j commented 11 months ago

I use a highlighting color for parameters to help with readability. Rust and many other languages will highlight the parameter inside the parentheses the same color as when it is referenced in the body of the function. This doesn't seem to work with Python. Maybe you know of a quick fix to this issue since you've written the code and know how it all works. I thought it would be worth asking as some people might find this useful. Thank you for your time and work you've put in on this. I know people in open source don't hear that enough.

amaanq commented 11 months ago

Locals can accomplish this, but you're likely looking for semantic highlighting anyways which an LSP provides

psi4j commented 11 months ago

Oh, I think you might be right. Would this then fall under the LSP? It might be that pyright doesn't provide that semantic group of parameter reference for highlighting and the Rust Analyzer does. Or maybe I just don't know how to get it to work.

amaanq commented 11 months ago

pyright doesn't provide semantic tokens

psi4j commented 11 months ago

I see. So how does Pylance get this to work under the hood? I wouldn't abandon Neovim or TreeSitter just for this one feature, but semantic highlighting sure makes it easier to read other languages. I just wish I had a solution for Python. Anyways, thank you for all your work on this.

amaanq commented 11 months ago

who knows, it's closed source, you could use semshi

psi4j commented 11 months ago

Thanks, I'll look into it.