* 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
(#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
(hash_deref_expression
[
"%"
"*"
] @variable)
"$#"
] @operator
"*" @character.special)
(array_element_expression
array: (_) @variable)
(slices
[
arrayref: _
hashref: _
]
[
"@"
"%"
] @operator)
(slice_expression
array: (_) @variable)
; except for subref deref, b/c that's actually a function call
(amper_deref_expression
[
"&"
"*"
] @function.call)
(keyval_expression
array: (_) @variable)
; mark hash or glob keys that are any form of string in any form of access
(_
"{"
[
(autoquoted_bareword)
(_
(string_content))
] @variable.member
"}")
(hash_element_expression
hash: (_) @variable)
(slice_expression
hash: (_) @variable)
(keyval_expression
hash: (_) @variable)
; 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

View file

@ -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))