From 9140ff74e75a44d948922ce1fe04eb7459a8bfa1 Mon Sep 17 00:00:00 2001 From: Robin Tweedie Date: Fri, 30 Jan 2026 11:46:16 +0000 Subject: [PATCH] fix(highlights): match constants with digits and leading underscores --- queries/highlights.scm | 2 +- test/highlight/identifiers.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/highlight/identifiers.py diff --git a/queries/highlights.scm b/queries/highlights.scm index af744484..fb644234 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -6,7 +6,7 @@ (#match? @constructor "^[A-Z]")) ((identifier) @constant - (#match? @constant "^[A-Z][A-Z_]*$")) + (#match? @constant "^_*[A-Z][A-Z_0-9]*$")) ; Function calls diff --git a/test/highlight/identifiers.py b/test/highlight/identifiers.py new file mode 100644 index 00000000..a4056cb2 --- /dev/null +++ b/test/highlight/identifiers.py @@ -0,0 +1,35 @@ +MAX_SIZE = 100 +# <- constant + +TOTAL = 50 +# <- constant + +PI = 3.14 +# <- constant + +HTTP2 = "h2" +# <- constant + +SHA256 = "sha256" +# <- constant + +MEMBER2 = 2 +# <- constant + +A85 = "something" +# <- constant + +_PRIVATE = 1 +# <- constant + +__DUNDER = 2 +# <- constant + +X = 1 +# <- constant + +MyClass = None +# <- constructor + +myVar = None +# <- variable