Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Improve Python syntax highlighting (#12868)

Nigel Joseba59e6631474
diff --git a/crates/languages/src/python/highlights.scm b/crates/languages/src/python/highlights.scm
index c31b64b10cf..df6b60466cd 100644
--- a/crates/languages/src/python/highlights.scm
+++ b/crates/languages/src/python/highlights.scm
@@ -1,6 +1,25 @@
+(parameter (identifier) @variable)
(attribute attribute: (identifier) @property)
(type (identifier) @type)
+; Module imports
+
+(import_statement
+ (dotted_name (identifier) @type))
+
+(import_statement
+ (aliased_import
+ name: (dotted_name (identifier) @type)
+ alias: (identifier) @type))
+
+(import_from_statement
+ (dotted_name (identifier) @type))
+
+(import_from_statement
+ (aliased_import
+ name: (dotted_name (identifier) @type)
+ alias: (identifier) @type))
+
; Function calls
(decorator) @function
@@ -44,9 +63,13 @@
(float)
] @number
-; Variables
-(assignment
- left: (identifier) @variable)
+; Self references
+
+[
+ (parameters (identifier) @variable.special)
+ (attribute (identifier) @variable.special)
+ (#match? @variable.special "^self$")
+]
(comment) @comment
(string) @string