* feat(perl): highlight hash keys as @variable.member in various contexts

also, injections for s///e should fully re-parse
This commit is contained in:
Veesh Goldman 2025-03-19 10:48:48 +02:00 committed by GitHub
parent 98a3fdd5d9
commit f09a2215b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 33 deletions

View file

@ -243,50 +243,65 @@
; highlights punc vars and also numeric only like $11 ; highlights punc vars and also numeric only like $11
(#lua-match? @variable.builtin "^%A+$")) (#lua-match? @variable.builtin "^%A+$"))
(scalar) @variable
(scalar_deref_expression
[
"$"
"*"
] @variable)
[ [
(scalar)
(array) (array)
(arraylen) (hash)
(glob)
; arraylen's sigil is kinda special b/c it's not a data type
(arraylen
"$#" @operator)
] @variable ] @variable
(array_deref_expression ; all post deref sigils highlighted as operators, and the unrolly star is a special char
(postfix_deref
[ [
"$"
"@" "@"
"*"
] @variable)
(hash) @variable
(hash_deref_expression
[
"%" "%"
"*" "*"
] @variable) "$#"
] @operator
"*" @character.special)
(array_element_expression (slices
array: (_) @variable) [
arrayref: _
hashref: _
]
[
"@"
"%"
] @operator)
(slice_expression ; except for subref deref, b/c that's actually a function call
array: (_) @variable) (amper_deref_expression
[
"&"
"*"
] @function.call)
(keyval_expression ; mark hash or glob keys that are any form of string in any form of access
array: (_) @variable) (_
"{"
[
(autoquoted_bareword)
(_
(string_content))
] @variable.member
"}")
(hash_element_expression ; mark stringies on the LHS of a fat comma as a hash key, b/c that's usually what it
hash: (_) @variable) ; denotes somewhat
(_
(slice_expression [
hash: (_) @variable) (autoquoted_bareword)
(_
(keyval_expression (string_content))
hash: (_) @variable) ] @variable.member
.
"=>"
(_))
(comment) @comment @spell (comment) @comment @spell

View file

@ -11,4 +11,5 @@
; match if there's a single `e` in the modifiers list ; match if there's a single `e` in the modifiers list
(#lua-match? @_modifiers "e") (#lua-match? @_modifiers "e")
(#not-lua-match? @_modifiers "e.*e") (#not-lua-match? @_modifiers "e.*e")
(#set! injection.language "perl")) (#set! injection.language "perl")
(#set! injection.include-children))