summaryrefslogtreecommitdiff
path: root/syntaxes/lua.tmLanguage.json
blob: d5ac4a983cabdb0531aaf797c8d2fb71965dfbe0 (plain)
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
{
	"name": "Lua",
	"scopeName": "source.lua",
	"patterns": [
		{
			"begin": "\\b(?:(local)\\s+)?(function)\\b",
			"beginCaptures": {
				"1": {
					"name": "keyword.local.lua"
				},
				"2": {
					"name": "keyword.control.lua"
				}
			},
			"end": "(?=(\\()(?:[^\\)]*)(\\)))",
			"endCaptures": {
				"1": {
					"name": "punctuation.definition.parameters.begin.lua"
				},
				"2": {
					"name": "punctuation.definition.parameters.finish.lua"
				}
			},
			"name": "meta.function.lua",
			"patterns": [
				{
					"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*:)",
					"name": "entity.name.class.lua"
				},
				{
					"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
					"name": "entity.name.function.lua"
				}
			]
		},
		{
			"match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(?![pPeE.0-9])",
			"name": "constant.numeric.integer.hexadecimal.lua"
		},
		{
			"match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(\\.[0-9A-Fa-f]+)?([eE]-?\\d*)?([pP][-+]\\d+)?",
			"name": "constant.numeric.float.hexadecimal.lua"
		},
		{
			"match": "(?<![\\w\\d.])\\d+(?![pPeE.0-9])",
			"name": "constant.numeric.integer.lua"
		},
		{
			"match": "(?<![\\w\\d.])\\d+(\\.\\d+)?([eE]-?\\d*)?",
			"name": "constant.numeric.float.lua"
		},
		{
			"begin": "'",
			"beginCaptures": {
				"0": {
					"name": "punctuation.definition.string.begin.lua"
				}
			},
			"end": "'",
			"endCaptures": {
				"0": {
					"name": "punctuation.definition.string.end.lua"
				}
			},
			"name": "string.quoted.single.lua",
			"patterns": [
				{
					"include": "#escaped_char"
				}
			]
		},
		{
			"begin": "\"",
			"beginCaptures": {
				"0": {
					"name": "punctuation.definition.string.begin.lua"
				}
			},
			"end": "\"",
			"endCaptures": {
				"0": {
					"name": "punctuation.definition.string.end.lua"
				}
			},
			"name": "string.quoted.double.lua",
			"patterns": [
				{
					"include": "#escaped_char"
				}
			]
		},
		{
			"begin": "(?<=\\.cdef)\\s*(\\[(=*)\\[)",
			"beginCaptures": {
				"0": {
					"name": "string.quoted.other.multiline.lua"
				},
				"1": {
					"name": "punctuation.definition.string.begin.lua"
				}
			},
			"contentName": "meta.embedded.lua",
			"end": "(\\]\\2\\])",
			"endCaptures": {
				"0": {
					"name": "string.quoted.other.multiline.lua"
				},
				"1": {
					"name": "punctuation.definition.string.end.lua"
				}
			},
			"patterns": [
				{
					"include": "source.c"
				}
			]
		},
		{
			"begin": "(?<!--)\\[(=*)\\[",
			"beginCaptures": {
				"0": {
					"name": "punctuation.definition.string.begin.lua"
				}
			},
			"end": "\\]\\1\\]",
			"endCaptures": {
				"0": {
					"name": "punctuation.definition.string.end.lua"
				}
			},
			"name": "string.quoted.other.multiline.lua"
		},
		{
			"captures": {
				"1": {
					"name": "punctuation.definition.comment.lua"
				}
			},
			"match": "\\A(#!).*$\\n?",
			"name": "comment.line.shebang.lua"
		},
		{
			"begin": "(^[ \\t]+)?(?=--)",
			"beginCaptures": {
				"1": {
					"name": "punctuation.whitespace.comment.leading.lua"
				}
			},
			"end": "(?!\\G)((?!^)[ \\t]+\\n)?",
			"endCaptures": {
				"1": {
					"name": "punctuation.whitespace.comment.trailing.lua"
				}
			},
			"patterns": [
				{
					"begin": "--\\[(=*)\\[",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.comment.begin.lua"
						}
					},
					"end": "\\]\\1\\]",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.comment.end.lua"
						}
					},
					"name": "comment.block.lua"
				},
				{
					"begin": "--",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.comment.lua"
						}
					},
					"end": "\\n",
					"name": "comment.line.double-dash.lua"
				}
			]
		},
		{
			"captures": {
				"1": {
					"name": "keyword.control.goto.lua"
				},
				"2": {
					"name": "string.tag.lua"
				}
			},
			"match": "\\b(goto)\\s+([a-zA-Z_][a-zA-Z0-9_]*)"
		},
		{
			"captures": {
				"1": {
					"name": "punctuation.section.embedded.begin.lua"
				},
				"2": {
					"name": "punctuation.section.embedded.end.lua"
				}
			},
			"match": "(::)\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*(::)",
			"name": "string.tag.lua"
		},
		{
			"match": "\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in)\\b",
			"name": "keyword.control.lua"
		},
		{
			"match": "\\b(local(\\s*\\*toclose)?)\\b",
			"name": "keyword.local.lua"
		},
		{
			"match": "\\b(function)\\b",
			"name": "keyword.control.lua"
		},
		{
			"match": "(?<![^.]\\.|:)\\b(false|nil|true|_G|_VERSION|math\\.(pi|huge)|utf8\\.charpattern|io\\.(stdin|stdout|stderr)|package\\.(cpath|loaded|path|preload|searchers))\\b|(?<![.])\\.{3}(?!\\.)",
			"name": "constant.language.lua"
		},
		{
			"match": "(?<![^.]\\.|:)\\b(self)\\b",
			"name": "variable.language.self.lua"
		},
		{
			"match": "(?<![^.]\\.|:)\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\b(?!\\s*=(?!=))",
			"name": "support.function.lua"
		},
		{
			"match": "(?<![^.]\\.|:)\\b(coroutine\\.(create|isyieldable|kill|resume|running|status|wrap|yield)|string\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)|table\\.(concat|insert|maxn|move|pack|remove|sort|unpack)|math\\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?)|io\\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\.(loadlib|seeall|searchpath)|debug\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|traceback|upvalueid|upvaluejoin)|bit32\\.(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)|utf8\\.(char|codes|codepoint|len|offset))\\b(?!\\s*=(?!=))",
			"name": "support.function.library.lua"
		},
		{
			"match": "\\b(and|or|not)\\b",
			"name": "keyword.operator.lua"
		},
		{
			"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*(?:[({\"']|\\[\\[))",
			"name": "entity.name.function.lua"
		},
		{
			"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*:)",
			"name": "entity.name.class.lua"
		},
		{
			"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
			"name": "variable.other.lua"
		},
		{
			"match": "\\+|-|%|#|\\*|\\/|\\^|==?|~=|<=?|>=?|(?<!\\.)\\.{2}(?!\\.)",
			"name": "keyword.operator.lua"
		}
	],
	"repository": {
		"escaped_char": {
			"patterns": [
				{
					"match": "\\\\[abfnrtvz\\\\\"'\\n]",
					"name": "constant.character.escape.lua"
				},
				{
					"match": "\\\\\\d{1,3}",
					"name": "constant.character.escape.byte.lua"
				},
				{
					"match": "\\\\x[0-9A-Fa-f][0-9A-Fa-f]",
					"name": "constant.character.escape.byte.lua"
				},
				{
					"match": "\\\\u\\{[0-9A-Fa-f]+\\}",
					"name": "constant.character.escape.unicode.lua"
				},
				{
					"match": "\\\\.",
					"name": "invalid.illegal.character.escape.lua"
				}
			]
		}
	}
}