Improve Python syntax highlighting (#25331)
chbk
and
Marshall Bowers
created
Release Notes:
- Improved Python syntax highlighting.
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `identifier`: `variable`
- `.`, `,`, `:`: `punctuation.delimiter`
- `@`: `operator`, for matrix multiplication
```python
class Mat(list):
def __matmul__(self, b):
...
a, b = Mat(), Mat()
identifier = a @ b
IDENTIFIER = True
```
---------
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Change summary
crates/languages/src/python/highlights.scm | 8 ++++++++
1 file changed, 8 insertions(+)
Detailed changes
@@ -8,6 +8,7 @@
((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z0-9_]*$"))
+(identifier) @variable
(attribute attribute: (identifier) @property)
(type (identifier) @type)
(generic_type (identifier) @type)
@@ -117,6 +118,12 @@
(#match? @variable.special "^self|cls$")
]
+[
+ "."
+ ","
+ ":"
+] @punctuation.delimiter
+
[
"("
")"
@@ -190,6 +197,7 @@
"&"
"%"
"%="
+ "@"
"^"
"+"
"->"