Skip to content

Commit

Permalink
Improve Python syntax highlighting (#25331)
Browse files Browse the repository at this point in the history
Release Notes:

  - Improved Python syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/3d8830c9-23cd-437d-88a6-258bcfba5f50)
|
![Image](https://github.com/user-attachments/assets/fd34ca38-c105-4f27-9979-98ab8d616c51)
|

- `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 <[email protected]>
  • Loading branch information
chbk and maxdeviant authored Feb 21, 2025
1 parent 10a6cd0 commit 59a153b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/languages/src/python/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -117,6 +118,12 @@
(#match? @variable.special "^self|cls$")
]

[
"."
","
":"
] @punctuation.delimiter

[
"("
")"
Expand Down Expand Up @@ -190,6 +197,7 @@
"&"
"%"
"%="
"@"
"^"
"+"
"->"
Expand Down

0 comments on commit 59a153b

Please sign in to comment.