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

fix: Python highlighting issues #236

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rennsax
Copy link
Contributor

@rennsax rennsax commented Aug 22, 2023

TL;DR: Go to "Detailed Changes"

This PR reverts disapproved #223, improves Python semantic highlighting features, with #232 finished. #223 happened to remove the highlight of self keyword, which is mentioned in #233.

The syntax highlighting and semantic highlighting work together to provide the developers with more recognizable tokens. Semantic highlighting is more powerful, and generally more precise. It's highly recommended to turn on semantic highlighting features in VS Code.

To enable it, install the corresponding language support extension (typically a language server, for example, Pylance for Python), and configure in your settings.json:
    "editor.semanticHighlighting.enabled": true

This setting entry is true by default, in case someone unexpectedly set it to false.

No semantic:
no-semantic

With semantic:
with-semantic

In addition, since semantic highlighting overrides common syntax highlighting, it also offers the abilities to customize the token color with much flexibility. See this example.

Therefore, this PR expands the semantic highlighting feature on Python language. I've made the changes for one more months, and I didn't detect any side effects (like accidentally changing other language's highlighting color).

Detailed Changes

  1. Fix the self keyword problem. This is done by reverting Customize the color of specific object types in python #218 #223 and add rules into "semanticTokenColors".
    image

  2. Add additional highlighting to Python function decorators.
    decorator

PS:

Thanks for your checking! @wesbos @palashmon

@SmitAkbari26
Copy link
Contributor

@Eitheages In mine vs code no difference make with semantic or without semantic.

image

image

image

image

And at same time it's not solve issue which pr is merged.

image

image

@rennsax
Copy link
Contributor Author

rennsax commented Aug 23, 2023

@SmitAkbari26 Have you installed and enabled Pylance?

@SmitAkbari26
Copy link
Contributor

@Eitheages I install it and with semantic and with your changes

code

Previously it was look like this after i remove mine merged pr with semantic

code

And this without semantic

code

This is after mine pr is merged without semantic sorry for i not set self scope

code

And this is with semantic

code

This is i make some little bit change in mine previous changes with semantic

code

And without semantic

code

Why you need to make that much changes to do same things?

@rennsax
Copy link
Contributor Author

rennsax commented Aug 25, 2023

@SmitAkbari26 I've emailed you a comment because I think it's better to communicate more with you :)

@SmitAkbari26
Copy link
Contributor

SmitAkbari26 commented Aug 26, 2023 via email

This reverts commit be43d3c, reversing
changes made to 280f561.
Add entries to "semanticTokenColors", which are related to Python.

Support Python function declaration.
@rennsax rennsax force-pushed the feat/python-semantic branch from 9f2e06d to 597f2dd Compare February 27, 2024 02:09
@Sanqui
Copy link

Sanqui commented Jun 12, 2024

Chiming in: I would like to see this merged (to have self differentiated again).

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

Successfully merging this pull request may close these issues.

3 participants