From f09a2215b8fed4c2e86f2dd1912e14166958c06a Mon Sep 17 00:00:00 2001 From: Veesh Goldman Date: Wed, 19 Mar 2025 10:48:48 +0200 Subject: * feat(perl): highlight hash keys as `@variable.member` in various contexts also, injections for s///e should fully re-parse --- queries/perl/highlights.scm | 79 +++++++++++++++++++++++++++------------------ queries/perl/injections.scm | 3 +- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/queries/perl/highlights.scm b/queries/perl/highlights.scm index 554743b32..d52baab44 100644 --- a/queries/perl/highlights.scm +++ b/queries/perl/highlights.scm @@ -243,50 +243,65 @@ ; highlights punc vars and also numeric only like $11 (#lua-match? @variable.builtin "^%A+$")) -(scalar) @variable - -(scalar_deref_expression - [ - "$" - "*" - ] @variable) - [ + (scalar) (array) - (arraylen) + (hash) + (glob) + ; arraylen's sigil is kinda special b/c it's not a data type + (arraylen + "$#" @operator) ] @variable -(array_deref_expression +; all post deref sigils highlighted as operators, and the unrolly star is a special char +(postfix_deref [ + "$" "@" + "%" "*" - ] @variable) - -(hash) @variable + "$#" + ] @operator + "*" @character.special) -(hash_deref_expression +(slices + [ + arrayref: _ + hashref: _ + ] [ + "@" "%" - "*" - ] @variable) - -(array_element_expression - array: (_) @variable) + ] @operator) -(slice_expression - array: (_) @variable) - -(keyval_expression - array: (_) @variable) - -(hash_element_expression - hash: (_) @variable) - -(slice_expression - hash: (_) @variable) +; except for subref deref, b/c that's actually a function call +(amper_deref_expression + [ + "&" + "*" + ] @function.call) -(keyval_expression - hash: (_) @variable) +; mark hash or glob keys that are any form of string in any form of access +(_ + "{" + [ + (autoquoted_bareword) + (_ + (string_content)) + ] @variable.member + "}") + +; mark stringies on the LHS of a fat comma as a hash key, b/c that's usually what it +; denotes somewhat +(_ + [ + (autoquoted_bareword) + (_ + (string_content)) + ] @variable.member + . + "=>" + (_)) (comment) @comment @spell diff --git a/queries/perl/injections.scm b/queries/perl/injections.scm index 48e6363b9..ec11e9013 100644 --- a/queries/perl/injections.scm +++ b/queries/perl/injections.scm @@ -11,4 +11,5 @@ ; match if there's a single `e` in the modifiers list (#lua-match? @_modifiers "e") (#not-lua-match? @_modifiers "e.*e") - (#set! injection.language "perl")) + (#set! injection.language "perl") + (#set! injection.include-children)) -- cgit v1.2.3-70-g09d2