-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Python Syntax highlighting for variables, enum and modules #12578
Comments
@Nigel007 : You can write the example code shown in the image so it is easier to copy them to zed to see the difference for those who will work with it. |
@Angelk90 Yeah that makes sense. Here's the code: import os
from enum import Enum
def sum(a, b):
return a + b
m, n = (5, 5)
a = 1
a += 1
for index in range(5):
print(index)
class Test:
def __init__(self):
self.a = 1
self.b = 2
class A(Enum):
a = 1
b = 2
c = 3
a_dict = {A.a: 1, A.b: 2, A.c: 3}
a_list = [1, 2, 3, 4, 5]
print(a_list[0])
print(a_list[-1]) |
@Angelk90 I think you've set the variable colour as white and the foreground as a off-white? If you notice, only variables that are defined for the first time have the bright white colour. All other variables, be it function parameters, reused variables (line 10: |
@Nigel007 : I created a custom theme for Zed, I just wanted to show you how I currently see things, in case anyone needs to see the difference. |
@Angelk90 Oh apologies! I should have also uploaded an image of how it appears for me. I have my variable and attribute colours set to a reddish tone. My foreground colour is white. |
All variables are now highlighted using the @variable property. This covers assignments and reusages, parameters and loop variables. Ref zed-industries#12578
Self references in classes are now highlighted using the @type property. This change was made as they refer to an instance of the class. Ref zed-industries#12578
All modules are now highlighted with the @type property. This includes both import and import_from statements as well as their aliases. Self parameter highlighting has been tweaked to not include variables that are called self. Ref zed-industries#12578
The issues that are still existing seem to be related to semantic highlighting because they require context awareness. That would be beyond the scope of this issue as semantic highlighting pertains to all languages. |
All variables are now highlighted using the @variable property. This covers assignments and reusages, parameters and loop variables. Ref zed-industries#12578
Self references in classes are now highlighted using the @type property. This change was made as they refer to an instance of the class. Ref zed-industries#12578
All modules are now highlighted with the @type property. This includes both import and import_from statements as well as their aliases. Self parameter highlighting has been tweaked to not include variables that are called self. Ref zed-industries#12578
it seems to happen to Rust as well as many other languages, Zed doesn't highlight |
Changed the variable property to act on parameter tokens rather than all identifiers Ref zed-industries#12578
@notmd Thank you for pointing it out. At first I was a bit skeptical about using the After a little trial and error, which mainly involved coming up with custom rules for each case, I discovered that the |
Release Notes: - Improve syntax highlighting in Python #12578 Before: <img width="1181" alt="Screenshot 2024-06-08 at 01 44 54" src="https://github.com/zed-industries/zed/assets/87859239/0b8ab26b-149b-477e-af08-8cd9f2b1c117"> After: <img width="1184" alt="Screenshot 2024-06-10 at 01 02 35" src="https://github.com/zed-industries/zed/assets/87859239/a319a5ea-54b7-4681-951d-130ea26aa390"> --------- Co-authored-by: Joseph T Lyons <JosephTLyons@gmail.com>
Closed via: #12868 |
@nigelmj Hello, what is the theme of this screenshot? |
@ihoey This is a custom theme based on the One Dark Pro theme for VS Code. |
Check for existing issues
Describe the feature
Although variable highlighting for Python was introduced in the current release, it is only available in the case where one variable is defined per line. There are several areas where Python syntax highlighting can be improved in Zed:
If applicable, add mockups / screenshots to help present your vision of the feature
The text was updated successfully, but these errors were encountered: