From abf24bd2ef93acf06e7a599da916c0bfd1e72a2a Mon Sep 17 00:00:00 2001 From: Yuriy Date: Tue, 1 Nov 2022 18:01:01 +0100 Subject: [PATCH 1/2] Add syntax highlighting for Python pattern matching Add syntax highlighting for `match` and `case` keywords in Python (https://peps.python.org/pep-0636/). --- runtime/queries/python/highlights.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm index a94d7cafa144..70b91efbe65b 100644 --- a/runtime/queries/python/highlights.scm +++ b/runtime/queries/python/highlights.scm @@ -2,7 +2,7 @@ (dotted_name (identifier)* @namespace) - + (aliased_import alias: (identifier) @namespace) @@ -67,7 +67,7 @@ (parameters (dictionary_splat_pattern ; **kwargs (identifier) @variable.parameter)) - + (lambda_parameters (identifier) @variable.parameter) @@ -97,7 +97,7 @@ (#match? @constant "^[A-Z_]{2,}$")) ((identifier) @type - (#match? @type "^[A-Z]")) + (#match? @type "^[A-Z]")) (attribute attribute: (identifier) @variable.other.member) (identifier) @variable @@ -168,6 +168,8 @@ "if" "elif" "else" + "match" + "case" ] @keyword.control.conditional [ From 11da51e0a57fea0d9600a44d8e6ab5f98a3f4c2e Mon Sep 17 00:00:00 2001 From: Yuriy Date: Tue, 1 Nov 2022 18:49:33 +0100 Subject: [PATCH 2/2] Add indentation for Python pattern matching Add indentation for `match` and `case`. --- runtime/queries/python/indents.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runtime/queries/python/indents.scm b/runtime/queries/python/indents.scm index b7b499c07ae9..743971adb8d2 100644 --- a/runtime/queries/python/indents.scm +++ b/runtime/queries/python/indents.scm @@ -9,6 +9,8 @@ (while_statement) (with_statement) (try_statement) + (match_statement) + (case_clause) (import_from_statement) (parenthesized_expression) @@ -33,6 +35,8 @@ (while_statement) (with_statement) (try_statement) + (match_statement) + (case_clause) (function_definition) (class_definition)