From 8a74ac9aead72ef7a870908f1517b48f2bb25ac7 Mon Sep 17 00:00:00 2001 From: Omar Valdez Date: Mon, 28 Oct 2024 23:45:33 -0700 Subject: [PATCH] feat(python): highlight modules --- queries/python/highlights.scm | 21 ++++++++++++++++++- .../query/highlights/python/future_import.py | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index 2363dc323..77edc7960 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -310,7 +310,7 @@ (future_import_statement "from" @keyword.import - "__future__" @constant.builtin) + "__future__" @module.builtin) (import_from_statement "from" @keyword.import) @@ -323,6 +323,25 @@ (wildcard_import "*" @character.special) +(import_statement + name: (dotted_name + (identifier) @module)) + +(import_statement + name: (aliased_import + name: (dotted_name + (identifier) @module) + alias: (identifier) @module)) + +(import_from_statement + module_name: (dotted_name + (identifier) @module)) + +(import_from_statement + module_name: (relative_import + (dotted_name + (identifier) @module))) + [ "if" "elif" diff --git a/tests/query/highlights/python/future_import.py b/tests/query/highlights/python/future_import.py index 6790b9b6b..065eabfe4 100644 --- a/tests/query/highlights/python/future_import.py +++ b/tests/query/highlights/python/future_import.py @@ -1,4 +1,4 @@ from __future__ import print_function # ^ @keyword.import -# ^ @constant.builtin +# ^ @module.builtin # ^ @keyword.import