From 59a153b2e182b6da082d86ad9601a875074934cf Mon Sep 17 00:00:00 2001 From: chbk Date: Fri, 21 Feb 2025 21:52:04 +0100 Subject: [PATCH] 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 --- crates/languages/src/python/highlights.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/languages/src/python/highlights.scm b/crates/languages/src/python/highlights.scm index e3e38aafedf52ac9212d6392377d225c8246c4b7..a6c20cd6bc666867558778066960e086d342964a 100644 --- a/crates/languages/src/python/highlights.scm +++ b/crates/languages/src/python/highlights.scm @@ -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 @@ "&" "%" "%=" + "@" "^" "+" "->"