aboutsummaryrefslogtreecommitdiffstats
path: root/queries/perl/highlights.scm
blob: a6405c948a1b43e396dcc3edb697b3c28517057f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
((source_file
  .
  (comment) @keyword.directive)
  (#lua-match? @keyword.directive "^#!/"))

[
  "use"
  "no"
  "require"
] @keyword.import

[
  "if"
  "elsif"
  "unless"
  "else"
] @keyword.conditional

(conditional_expression
  [
    "?"
    ":"
  ] @keyword.conditional.ternary)

[
  "while"
  "until"
  "for"
  "foreach"
] @keyword.repeat

"return" @keyword.return

"sub" @keyword.function

[
  "map"
  "grep"
  "sort"
] @function.builtin

"package" @keyword.import

[
  "do"
  "my"
  "our"
  "local"
  "state"
  "last"
  "next"
  "redo"
  "goto"
  "undef"
] @keyword

(_
  operator: _ @operator)

"\\" @operator

(yadayada) @keyword.exception

(phaser_statement
  phase: _ @keyword.phaser)

[
  "or"
  "and"
  "eq"
  "ne"
  "cmp"
  "lt"
  "le"
  "ge"
  "gt"
  "isa"
] @keyword.operator

(eof_marker) @keyword.directive

(data_section) @comment

(pod) @none

[
  (number)
  (version)
] @number

[
  (string_literal)
  (interpolated_string_literal)
  (quoted_word_list)
  (command_string)
  (heredoc_content)
  (replacement)
  (transliteration_content)
] @string

[
  (heredoc_token)
  (command_heredoc_token)
  (heredoc_end)
] @label

[
  (escape_sequence)
  (escaped_delimiter)
] @string.escape

(_
  modifiers: _ @character.special)

[
  (quoted_regexp)
  (match_regexp)
  (regexp_content)
] @string.regexp

(autoquoted_bareword) @string.special

(use_statement
  (package) @type)

(package_statement
  (package) @type)

(require_expression
  (bareword) @type)

(subroutine_declaration_statement
  name: (bareword) @function)

(attribute_name) @attribute

(attribute_value) @string

(label) @label

(statement_label
  label: _ @label)

(relational_expression
  operator: "isa"
  right: (bareword) @type)

(function_call_expression
  (function) @function.call)

(method_call_expression
  (method) @function.method.call)

(method_call_expression
  invocant: (bareword) @type)

(func0op_call_expression
  function: _ @function.builtin)

(func1op_call_expression
  function: _ @function.builtin)

; this was a regex for the CLI
([
  (function)
  (expression_statement
    (bareword))
] @function.builtin
  (#any-of? @function.builtin "accept" "atan2" "bind" "binmode" "bless" "crypt" "chmod" "chown" "connect" "die" "dbmopen" "exec" "fcntl" "flock" "formline" "getpriority" "getprotobynumber" "gethostbyaddr" "getnetbyaddr" "getservbyname" "getservbyport" "getsockopt" "glob" "index" "ioctl" "join" "kill" "link" "listen" "mkdir" "msgctl" "msgget" "msgrcv" "msgsend" "open" "opendir" "print" "printf" "push" "pack" "pipe" "return" "rename" "rindex" "read" "recv" "reverse" "say" "select" "seek" "semctl" "semget" "semop" "send" "setpgrp" "setpriority" "seekdir" "setsockopt" "shmctl" "shmread" "shmwrite" "shutdown" "socket" "socketpair" "split" "sprintf" "splice" "substr" "system" "symlink" "syscall" "sysopen" "sysseek" "sysread" "syswrite" "tie" "truncate" "unlink" "unpack" "utime" "unshift" "vec" "warn" "waitpid"))

(function) @function

(_
  "{" @punctuation.special
  (varname)
  "}" @punctuation.special)

(varname
  (block
    "{" @punctuation.special
    "}" @punctuation.special))

([
  (varname)
  (filehandle)
] @variable.builtin
  (#any-of? @variable.builtin "ENV" "ARGV" "INC" "ARGVOUT" "SIG" "STDIN" "STDOUT" "STDERR" "a" "b" "_"))

((varname) @variable.builtin
  ; highlights all the reserved ^ vars like ${^THINGS}
  (#lua-match? @variable.builtin "%^"))

((varname) @variable.builtin
  ; highlights punc vars and also numeric only like $11
  (#lua-match? @variable.builtin "^%A+$"))

(scalar) @variable.scalar

(scalar_deref_expression
  [
    "$"
    "*"
  ] @variable.scalar)

[
  (array)
  (arraylen)
] @variable.array

(array_deref_expression
  [
    "@"
    "*"
  ] @variable.array)

(hash) @variable.hash

(hash_deref_expression
  [
    "%"
    "*"
  ] @variable.hash)

(array_element_expression
  array: (_) @variable.array)

(slice_expression
  array: (_) @variable.array)

(keyval_expression
  array: (_) @variable.array)

(hash_element_expression
  hash: (_) @variable.hash)

(slice_expression
  hash: (_) @variable.hash)

(keyval_expression
  hash: (_) @variable.hash)

(comment) @comment

([
  "=>"
  ","
  ";"
  "->"
] @punctuation.delimiter)

([
  "["
  "]"
  "{"
  "}"
  "("
  ")"
] @punctuation.bracket
  ; priority hack so nvim + ts-cli behave the same
  (#set! "priority" 90))