From ba59e6631474899e8b61075a16351770743ebd83 Mon Sep 17 00:00:00 2001 From: Nigel Jose Date: Tue, 18 Jun 2024 19:21:18 +0300 Subject: [PATCH] Improve Python syntax highlighting (#12868) Release Notes: - Improve syntax highlighting in Python #12578 Before: Screenshot 2024-06-08 at 01 44 54 After: Screenshot 2024-06-10 at 01 02 35 --------- Co-authored-by: Joseph T Lyons --- crates/languages/src/python/highlights.scm | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/crates/languages/src/python/highlights.scm b/crates/languages/src/python/highlights.scm index c31b64b10c..df6b60466c 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