Improve Python syntax highlighting (#25331)

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 <git@maxdeviant.com>
This commit is contained in:
chbk 2025-02-21 21:52:04 +01:00 committed by GitHub
parent 10a6cd00e7
commit 59a153b2e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@
((identifier) @constant ((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z0-9_]*$")) (#match? @constant "^_*[A-Z][A-Z0-9_]*$"))
(identifier) @variable
(attribute attribute: (identifier) @property) (attribute attribute: (identifier) @property)
(type (identifier) @type) (type (identifier) @type)
(generic_type (identifier) @type) (generic_type (identifier) @type)
@ -117,6 +118,12 @@
(#match? @variable.special "^self|cls$") (#match? @variable.special "^self|cls$")
] ]
[
"."
","
":"
] @punctuation.delimiter
[ [
"(" "("
")" ")"
@ -190,6 +197,7 @@
"&" "&"
"%" "%"
"%=" "%="
"@"
"^" "^"
"+" "+"
"->" "->"