Debian Codegraph @

runtime/queries/pkl/highlights.scm

raw symbols SCIP
1 ; Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
2 ;
3 ; Licensed under the Apache License, Version 2.0 (the "License");
4 ; you may not use this file except in compliance with the License.
5 ; You may obtain a copy of the License at
6 ;
7 ; https://www.apache.org/licenses/LICENSE-2.0
8 ;
9 ; Unless required by applicable law or agreed to in writing, software
10 ; distributed under the License is distributed on an "AS IS" BASIS,
11 ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 ; See the License for the specific language governing permissions and
13 ; limitations under the License.
14
15 ; this definition is imprecise in that
16 ; * any qualified or unqualified call to a method named "Regex" is considered a regex
17 ; * string delimiters are considered part of the regex
18
19 ; Operators
20
21 [
22 "??"
23 "@"
24 "="
25 "<"
26 ">"
27 "!"
28 "=="
29 "!="
30 "<="
31 ">="
32 "&&"
33 "||"
34 "+"
35 "-"
36 "**"
37 "*"
38 "/"
39 "~/"
40 "%"
41 "|>"
42 ] @keyword.operator
43
44 [
45 "?"
46 "|"
47 "->"
48 ] @operator.type
49
50 [
51 ","
52 ":"
53 "."
54 "?."
55 ] @punctuation.delimiter
56
57 [
58 "("
59 ")"
60 "]"
61 "{"
62 "}"
63 ; "[" @punctuation.bracket TODO: FIGURE OUT HOW TO REFER TO CUSTOM TOKENS
64 ] @punctuation.bracket
65
66 ; Keywords
67
68 [
69 "abstract"
70 "amends"
71 "as"
72 "class"
73 "extends"
74 "external"
75 "function"
76 "hidden"
77 "import"
78 "import*"
79 "in"
80 "let"
81 "local"
82 "module"
83 "new"
84 "open"
85 "out"
86 "typealias"
87 "when"
88 ] @keyword
89
90 [
91 "if"
92 "is"
93 "else"
94 ] @keyword.control.conditional
95
96 [
97 "for"
98 ] @keyword.control.repeat
99
100 (importExpr "import" @keyword.control.import)
101 (importGlobExpr "import*" @keyword.control.import)
102
103 "read" @function.builtin
104 "read?" @function.builtin
105 "read*" @function.builtin
106 "throw" @function.builtin
107 "trace" @function.builtin
108
109 (moduleExpr "module" @type.builtin)
110 "nothing" @type.builtin
111 "unknown" @type.builtin
112
113 (outerExpr) @variable.builtin
114 "super" @variable.builtin
115 (thisExpr) @variable.builtin
116
117 [
118 (falseLiteral)
119 (nullLiteral)
120 (trueLiteral)
121 ] @constant.builtin
122
123 ; Literals
124
125 (stringConstant) @string
126 (slStringLiteral) @string
127 (mlStringLiteral) @string
128
129 (escapeSequence) @constant.character.escape
130
131 (intLiteral) @constant.numeric.integer
132 (floatLiteral) @constant.numeric.float
133
134 (interpolationExpr
135 "\\(" @punctuation.special
136 ")" @punctuation.special) @embedded
137
138 (interpolationExpr
139 "\\#(" @punctuation.special
140 ")" @punctuation.special) @embedded
141
142 (interpolationExpr
143 "\\##(" @punctuation.special
144 ")" @punctuation.special) @embedded
145
146 (lineComment) @comment
147 (blockComment) @comment
148 (docComment) @comment
149
150 ; Identifiers
151
152 (identifier) @variable
153
154 (classProperty (identifier) @variable.other.member)
155 (objectProperty (identifier) @variable.other.member)
156 ; Property access `o.field` (methodCallExpr below handles `o.method()`).
157 (propertyCallExpr (identifier) @variable.other.member)
158
159 (parameterList (typedIdentifier (identifier) @variable.parameter))
160 (objectBodyParameters (typedIdentifier (identifier) @variable.parameter))
161
162 ; Method definitions
163
164 (classMethod (methodHeader (identifier)) @function.method)
165 (objectMethod (methodHeader (identifier)) @function.method)
166
167 ; Method calls
168
169 (methodCallExpr
170 (identifier) @function.method)
171
172 ; Types
173
174 (clazz (identifier) @type)
175 (typeAlias (identifier) @type)
176 ((identifier) @type
177 (#match? @type "^[A-Z]"))
178
179 (typeArgumentList
180 "<" @punctuation.bracket
181 ">" @punctuation.bracket)