aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeesh Goldman <rabbiveesh@gmail.com>2025-03-19 10:48:48 +0200
committerGitHub <noreply@github.com>2025-03-19 09:48:48 +0100
commitf09a2215b8fed4c2e86f2dd1912e14166958c06a (patch)
tree24974d4c2d04eb02a7258775b1a971651dda7ed3
parentbot(lockfile): update query, vimdoc (diff)
downloadnvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.tar
nvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.tar.gz
nvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.tar.bz2
nvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.tar.lz
nvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.tar.xz
nvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.tar.zst
nvim-treesitter-f09a2215b8fed4c2e86f2dd1912e14166958c06a.zip
* feat(perl): highlight hash keys as `@variable.member` in various contexts
also, injections for s///e should fully re-parse
-rw-r--r--queries/perl/highlights.scm77
-rw-r--r--queries/perl/injections.scm3
2 files changed, 48 insertions, 32 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)
+; except for subref deref, b/c that's actually a function call
+(amper_deref_expression
+ [
+ "&"
+ "*"
+ ] @function.call)
-(slice_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
+ "}")
-(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
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))