-
Notifications
You must be signed in to change notification settings - Fork 92
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
Positron should better recognize and highlight Python keywords #3731
Comments
Thanks for logging this, this is as a result of the token types from of the Jedi-based language server in use in Positron's Python LSP. |
Is there anyway to use Pylang, which is much better? |
@ntluong95 I can't find any info on a "Pylang" syntax highlighter. Do you mean Pylance? |
Yes sorry I meant Pylance. Fortunately I found this one, which serve my need. Maybe something you can consider to integrate into Positron as I know Pylance is only for VSCode. |
Here is the result after installing the package. However, the |
Thank you for pointing out basedpyright, we'll look into it! Aside from the Quarto issue you mentioned, how well does basedpyright currently work in Positron? At the very least, we may be able to iron some of those issues so that users can choose alternative language servers – although it is worth noting that completions would no longer be aware of your session's variables and would not benefit from other Positron-specific language server features in future. |
It works well, excepted that in the Outlines, you will see 2 language servers. I think if you can look at their code and cherry-pick the part that help to recognize Python module keywords, and also attach it to Quarto, the problem will be solved. Just my naive idea |
Could you please share a screenshot of the 2 language servers in Outlines? |
But is there any plan to support display syntax highlighting of Python code for Quarto too? |
+1 for this change. Tried to switch from VScode but too much of my python code has no syntax highlighting |
The ruff team is "considering" semantic highlighting "but not in the near future" (see astral-sh/ruff-vscode#438 (comment)). Tracking issue: astral-sh/ruff-lsp#237 |
Same here. Are there any news? It's such a pity to drop Positron because of this. |
Unfortunately this isn't a priority at the moment, but I did spend a little time seeing what it would take to support semantic highlighting with Jedi on the 3731-investigate-jedi-lsp-semantic-tokens branch if anyone is interested in pursuing this further. That should get basic semantic highlighting. From my understanding, it's easy with Jedi to classify declarations (e.g. in The language server protocol also supports updating semantic tokens given edits to the document (rather than starting from scratch each time). I haven't looked into whether that's necessary (or possible) with Jedi. Looking at this comment, Jedi's parser It would be helpful to know from you all which token types are the most important, and we can look into the feasibility of getting that to work with Jedi. |
I don't have the knowledge on this, but this document might be helpful to know all of the token type. For prioritizing purpose, for me at least module keywords, class methods, function parameters, |
@seeM how is the progress. I think Jedi is quite good in general but hope Positron can implement something like customized Jedi like Microsoft did with Pylance, which improve a lot of UX |
I tested and it works quite well. May be add also "variable.declaration", "property.declaration" and "function.builtin". Those are something I have set syntax highlighting when using Pylance. The problem is it doesn't work on Jupyter notebook. But Pylance doesn't work on Quarto document. I think the current highlighting is good enough for me at least to move forward, as long as Jupyter Notebook and Quarto document support for it, I may not need Pylance. I can use Ruff for type checking and linting |
I found this one, could be helpful: https://gitee.com/guanyusheng/semshi/blob/master/rplugin/python3/semshi/parser.py |
Currently, module keywords such as pandas, pd, etc. are not highlighted. See the example below
In Vscode
In Positron
The text was updated successfully, but these errors were encountered: