@enjoys/context-engine 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/commands/dockerfile.json +66 -0
- package/data/commands/lua.json +66 -0
- package/data/commands/manifest.json +54 -24
- package/data/commands/sql.json +34 -0
- package/data/completion/caddy.json +1589 -0
- package/data/completion/dockerfile.json +1062 -313
- package/data/completion/lua.json +2283 -617
- package/data/completion/nginx.json +804 -1
- package/data/completion/redis-cli.json +3405 -0
- package/data/completion/sql.json +2684 -552
- package/data/defination/caddy.json +428 -0
- package/data/defination/dockerfile.json +211 -29
- package/data/defination/lua.json +875 -125
- package/data/defination/nginx.json +164 -1
- package/data/defination/redis-cli.json +1853 -0
- package/data/defination/sql.json +998 -326
- package/data/hover/caddy.json +458 -0
- package/data/hover/dockerfile.json +180 -42
- package/data/hover/lua.json +775 -69
- package/data/hover/nginx.json +760 -0
- package/data/hover/redis-cli.json +1088 -0
- package/data/hover/sql.json +1119 -76
- package/data/manifest.json +27 -3
- package/package.json +1 -1
package/data/completion/lua.json
CHANGED
|
@@ -1,11 +1,1212 @@
|
|
|
1
1
|
{
|
|
2
2
|
"language": "lua",
|
|
3
3
|
"completions": [
|
|
4
|
+
{
|
|
5
|
+
"label": "for numeric",
|
|
6
|
+
"kind": 15,
|
|
7
|
+
"detail": "Numeric for loop",
|
|
8
|
+
"documentation": {
|
|
9
|
+
"value": "Standard numeric for loop.\n\n```lua\nfor i = 1, 10 do\n print(i)\nend\n```"
|
|
10
|
+
},
|
|
11
|
+
"insertText": "for ${1:i} = ${2:1}, ${3:10} do\n\t$0\nend",
|
|
12
|
+
"insertTextRules": 4,
|
|
13
|
+
"sortText": "00_for_numeric"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"label": "for pairs",
|
|
17
|
+
"kind": 15,
|
|
18
|
+
"detail": "Generic for loop (pairs)",
|
|
19
|
+
"documentation": {
|
|
20
|
+
"value": "Iterate over all key-value pairs.\n\n```lua\nfor k, v in pairs(t) do\n print(k, v)\nend\n```"
|
|
21
|
+
},
|
|
22
|
+
"insertText": "for ${1:k}, ${2:v} in pairs(${3:t}) do\n\t$0\nend",
|
|
23
|
+
"insertTextRules": 4,
|
|
24
|
+
"sortText": "00_for_pairs"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"label": "for ipairs",
|
|
28
|
+
"kind": 15,
|
|
29
|
+
"detail": "Generic for loop (ipairs)",
|
|
30
|
+
"documentation": {
|
|
31
|
+
"value": "Iterate over integer-keyed array elements.\n\n```lua\nfor i, v in ipairs(list) do\n print(i, v)\nend\n```"
|
|
32
|
+
},
|
|
33
|
+
"insertText": "for ${1:i}, ${2:v} in ipairs(${3:list}) do\n\t$0\nend",
|
|
34
|
+
"insertTextRules": 4,
|
|
35
|
+
"sortText": "00_for_ipairs"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"label": "for next",
|
|
39
|
+
"kind": 15,
|
|
40
|
+
"detail": "Generic for loop (next)",
|
|
41
|
+
"documentation": {
|
|
42
|
+
"value": "Low-level iteration using next.\n\n```lua\nfor k, v in next, t do\n print(k, v)\nend\n```"
|
|
43
|
+
},
|
|
44
|
+
"insertText": "for ${1:k}, ${2:v} in next, ${3:t} do\n\t$0\nend",
|
|
45
|
+
"insertTextRules": 4,
|
|
46
|
+
"sortText": "00_for_next"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"label": "while",
|
|
50
|
+
"kind": 15,
|
|
51
|
+
"detail": "While loop",
|
|
52
|
+
"documentation": {
|
|
53
|
+
"value": "Loop that repeats while a condition is true.\n\n```lua\nwhile condition do\n -- body\nend\n```"
|
|
54
|
+
},
|
|
55
|
+
"insertText": "while ${1:condition} do\n\t$0\nend",
|
|
56
|
+
"insertTextRules": 4,
|
|
57
|
+
"sortText": "00_while"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"label": "repeat until",
|
|
61
|
+
"kind": 15,
|
|
62
|
+
"detail": "Repeat-until loop",
|
|
63
|
+
"documentation": {
|
|
64
|
+
"value": "Loop that executes at least once, repeating until the condition is true.\n\n```lua\nrepeat\n -- body\nuntil condition\n```"
|
|
65
|
+
},
|
|
66
|
+
"insertText": "repeat\n\t$0\nuntil ${1:condition}",
|
|
67
|
+
"insertTextRules": 4,
|
|
68
|
+
"sortText": "00_repeat_until"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"label": "if",
|
|
72
|
+
"kind": 15,
|
|
73
|
+
"detail": "If statement",
|
|
74
|
+
"documentation": {
|
|
75
|
+
"value": "Conditional execution.\n\n```lua\nif condition then\n -- body\nend\n```"
|
|
76
|
+
},
|
|
77
|
+
"insertText": "if ${1:condition} then\n\t$0\nend",
|
|
78
|
+
"insertTextRules": 4,
|
|
79
|
+
"sortText": "00_if"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"label": "if else",
|
|
83
|
+
"kind": 15,
|
|
84
|
+
"detail": "If-else statement",
|
|
85
|
+
"documentation": {
|
|
86
|
+
"value": "Conditional with alternative.\n\n```lua\nif condition then\n -- true branch\nelse\n -- false branch\nend\n```"
|
|
87
|
+
},
|
|
88
|
+
"insertText": "if ${1:condition} then\n\t${2:-- body}\nelse\n\t$0\nend",
|
|
89
|
+
"insertTextRules": 4,
|
|
90
|
+
"sortText": "00_if_else"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"label": "if elseif else",
|
|
94
|
+
"kind": 15,
|
|
95
|
+
"detail": "If-elseif-else statement",
|
|
96
|
+
"documentation": {
|
|
97
|
+
"value": "Multi-branch conditional.\n\n```lua\nif cond1 then\n ...\nelseif cond2 then\n ...\nelse\n ...\nend\n```"
|
|
98
|
+
},
|
|
99
|
+
"insertText": "if ${1:cond1} then\n\t${2:-- body}\nelseif ${3:cond2} then\n\t${4:-- body}\nelse\n\t$0\nend",
|
|
100
|
+
"insertTextRules": 4,
|
|
101
|
+
"sortText": "00_if_elseif_else"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"label": "do end",
|
|
105
|
+
"kind": 15,
|
|
106
|
+
"detail": "Do-end block",
|
|
107
|
+
"documentation": {
|
|
108
|
+
"value": "Creates a new scope block.\n\n```lua\ndo\n local x = 1\n -- x is scoped here\nend\n```"
|
|
109
|
+
},
|
|
110
|
+
"insertText": "do\n\t$0\nend",
|
|
111
|
+
"insertTextRules": 4,
|
|
112
|
+
"sortText": "00_do_end"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"label": "function",
|
|
116
|
+
"kind": 15,
|
|
117
|
+
"detail": "Function declaration",
|
|
118
|
+
"documentation": {
|
|
119
|
+
"value": "Declares a named function.\n\n```lua\nfunction greet(name)\n print(\"Hello, \" .. name)\nend\n```"
|
|
120
|
+
},
|
|
121
|
+
"insertText": "function ${1:name}(${2:params})\n\t$0\nend",
|
|
122
|
+
"insertTextRules": 4,
|
|
123
|
+
"sortText": "00_function"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"label": "local function",
|
|
127
|
+
"kind": 15,
|
|
128
|
+
"detail": "Local function declaration",
|
|
129
|
+
"documentation": {
|
|
130
|
+
"value": "Declares a local function visible only in the current scope.\n\n```lua\nlocal function helper(x)\n return x * 2\nend\n```"
|
|
131
|
+
},
|
|
132
|
+
"insertText": "local function ${1:name}(${2:params})\n\t$0\nend",
|
|
133
|
+
"insertTextRules": 4,
|
|
134
|
+
"sortText": "00_local_function"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"label": "anonymous function",
|
|
138
|
+
"kind": 15,
|
|
139
|
+
"detail": "Anonymous function",
|
|
140
|
+
"documentation": {
|
|
141
|
+
"value": "Creates an anonymous function value.\n\n```lua\nlocal fn = function(x) return x + 1 end\n```"
|
|
142
|
+
},
|
|
143
|
+
"insertText": "function(${1:params})\n\t$0\nend",
|
|
144
|
+
"insertTextRules": 4,
|
|
145
|
+
"sortText": "00_anonymous_function"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"label": "variadic function",
|
|
149
|
+
"kind": 15,
|
|
150
|
+
"detail": "Variadic function",
|
|
151
|
+
"documentation": {
|
|
152
|
+
"value": "Function accepting variable number of arguments.\n\n```lua\nfunction printf(fmt, ...)\n io.write(string.format(fmt, ...))\nend\n```"
|
|
153
|
+
},
|
|
154
|
+
"insertText": "function ${1:name}(${2:...})\n\tlocal args = {...}\n\t$0\nend",
|
|
155
|
+
"insertTextRules": 4,
|
|
156
|
+
"sortText": "00_variadic_function"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"label": "function return",
|
|
160
|
+
"kind": 15,
|
|
161
|
+
"detail": "Function with return",
|
|
162
|
+
"documentation": {
|
|
163
|
+
"value": "Function that returns a value.\n\n```lua\nfunction square(x)\n return x * x\nend\n```"
|
|
164
|
+
},
|
|
165
|
+
"insertText": "function ${1:name}(${2:params})\n\treturn ${0:value}\nend",
|
|
166
|
+
"insertTextRules": 4,
|
|
167
|
+
"sortText": "00_function_return"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"label": "method (colon)",
|
|
171
|
+
"kind": 15,
|
|
172
|
+
"detail": "Method using colon syntax",
|
|
173
|
+
"documentation": {
|
|
174
|
+
"value": "Defines a method on a table using colon syntax. Implicitly receives `self`.\n\n```lua\nfunction MyClass:greet()\n print(self.name)\nend\n```"
|
|
175
|
+
},
|
|
176
|
+
"insertText": "function ${1:Class}:${2:method}(${3:params})\n\t$0\nend",
|
|
177
|
+
"insertTextRules": 4,
|
|
178
|
+
"sortText": "00_method_(colon)"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"label": "closure",
|
|
182
|
+
"kind": 15,
|
|
183
|
+
"detail": "Closure / factory function",
|
|
184
|
+
"documentation": {
|
|
185
|
+
"value": "A function that returns another function capturing upvalues.\n\n```lua\nfunction counter(start)\n local n = start\n return function()\n n = n + 1\n return n\n end\nend\n```"
|
|
186
|
+
},
|
|
187
|
+
"insertText": "function ${1:factory}(${2:params})\n\tlocal ${3:state} = ${4:init}\n\treturn function(${5:})\n\t\t$0\n\tend\nend",
|
|
188
|
+
"insertTextRules": 4,
|
|
189
|
+
"sortText": "00_closure"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"label": "IIFE",
|
|
193
|
+
"kind": 15,
|
|
194
|
+
"detail": "Immediately invoked function expression",
|
|
195
|
+
"documentation": {
|
|
196
|
+
"value": "Executes an anonymous function immediately.\n\n```lua\nlocal result = (function()\n return 42\nend)()\n```"
|
|
197
|
+
},
|
|
198
|
+
"insertText": "(function()\n\t$0\nend)()",
|
|
199
|
+
"insertTextRules": 4,
|
|
200
|
+
"sortText": "00_IIFE"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"label": "local function recursive",
|
|
204
|
+
"kind": 15,
|
|
205
|
+
"detail": "Local recursive function",
|
|
206
|
+
"documentation": {
|
|
207
|
+
"value": "Pattern for a recursive local function.\n\n```lua\nlocal function factorial(n)\n if n <= 1 then return 1 end\n return n * factorial(n - 1)\nend\n```"
|
|
208
|
+
},
|
|
209
|
+
"insertText": "local function ${1:name}(${2:n})\n\tif ${3:base_case} then return ${4:base_value} end\n\treturn ${0:recursive_call}\nend",
|
|
210
|
+
"insertTextRules": 4,
|
|
211
|
+
"sortText": "00_local_function_recursive"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"label": "table empty",
|
|
215
|
+
"kind": 15,
|
|
216
|
+
"detail": "Empty table constructor",
|
|
217
|
+
"documentation": {
|
|
218
|
+
"value": "Creates an empty table.\n\n```lua\nlocal t = {}\n```"
|
|
219
|
+
},
|
|
220
|
+
"insertText": "local ${1:t} = {}",
|
|
221
|
+
"insertTextRules": 4,
|
|
222
|
+
"sortText": "00_table_empty"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"label": "table array",
|
|
226
|
+
"kind": 15,
|
|
227
|
+
"detail": "Array-style table",
|
|
228
|
+
"documentation": {
|
|
229
|
+
"value": "Creates a table with sequential integer keys.\n\n```lua\nlocal list = {1, 2, 3, 4, 5}\n```"
|
|
230
|
+
},
|
|
231
|
+
"insertText": "local ${1:list} = {${2:items}}",
|
|
232
|
+
"insertTextRules": 4,
|
|
233
|
+
"sortText": "00_table_array"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"label": "table hash",
|
|
237
|
+
"kind": 15,
|
|
238
|
+
"detail": "Hash-style table",
|
|
239
|
+
"documentation": {
|
|
240
|
+
"value": "Creates a table with named keys.\n\n```lua\nlocal obj = {\n name = \"Lua\",\n version = 5.4,\n}\n```"
|
|
241
|
+
},
|
|
242
|
+
"insertText": "local ${1:obj} = {\n\t${2:key} = ${3:value},\n\t$0\n}",
|
|
243
|
+
"insertTextRules": 4,
|
|
244
|
+
"sortText": "00_table_hash"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"label": "table mixed",
|
|
248
|
+
"kind": 15,
|
|
249
|
+
"detail": "Mixed table (array + hash)",
|
|
250
|
+
"documentation": {
|
|
251
|
+
"value": "Table with both sequential and named keys.\n\n```lua\nlocal t = {\n \"first\",\n name = \"mixed\",\n 42,\n}\n```"
|
|
252
|
+
},
|
|
253
|
+
"insertText": "local ${1:t} = {\n\t${2:array_val},\n\t${3:key} = ${4:value},\n\t$0\n}",
|
|
254
|
+
"insertTextRules": 4,
|
|
255
|
+
"sortText": "00_table_mixed"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"label": "table nested",
|
|
259
|
+
"kind": 15,
|
|
260
|
+
"detail": "Nested table",
|
|
261
|
+
"documentation": {
|
|
262
|
+
"value": "Table containing other tables.\n\n```lua\nlocal config = {\n db = { host = \"localhost\", port = 5432 },\n app = { debug = true },\n}\n```"
|
|
263
|
+
},
|
|
264
|
+
"insertText": "local ${1:config} = {\n\t${2:key} = {\n\t\t${3:inner_key} = ${4:inner_value},\n\t},\n\t$0\n}",
|
|
265
|
+
"insertTextRules": 4,
|
|
266
|
+
"sortText": "00_table_nested"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"label": "metatable __index",
|
|
270
|
+
"kind": 15,
|
|
271
|
+
"detail": "Metatable with __index",
|
|
272
|
+
"documentation": {
|
|
273
|
+
"value": "Sets a metatable with __index for prototype-based lookup.\n\n```lua\nlocal mt = { __index = proto }\nsetmetatable(obj, mt)\n```"
|
|
274
|
+
},
|
|
275
|
+
"insertText": "local ${1:mt} = { __index = ${2:proto} }\nsetmetatable(${3:obj}, $1)",
|
|
276
|
+
"insertTextRules": 4,
|
|
277
|
+
"sortText": "00_metatable___index"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"label": "metatable __newindex",
|
|
281
|
+
"kind": 15,
|
|
282
|
+
"detail": "Metatable with __newindex",
|
|
283
|
+
"documentation": {
|
|
284
|
+
"value": "Sets a metatable with __newindex to intercept assignments.\n\n```lua\nlocal mt = {\n __newindex = function(t, k, v)\n rawset(t, k, v)\n end\n}\n```"
|
|
285
|
+
},
|
|
286
|
+
"insertText": "local ${1:mt} = {\n\t__newindex = function(${2:t}, ${3:k}, ${4:v})\n\t\t$0\n\tend\n}",
|
|
287
|
+
"insertTextRules": 4,
|
|
288
|
+
"sortText": "00_metatable___newindex"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"label": "metatable __tostring",
|
|
292
|
+
"kind": 15,
|
|
293
|
+
"detail": "Metatable with __tostring",
|
|
294
|
+
"documentation": {
|
|
295
|
+
"value": "Custom string representation.\n\n```lua\nlocal mt = {\n __tostring = function(self)\n return string.format(\"Obj(%s)\", self.name)\n end\n}\n```"
|
|
296
|
+
},
|
|
297
|
+
"insertText": "local ${1:mt} = {\n\t__tostring = function(${2:self})\n\t\treturn ${0:string.format(\"${3:Obj(%s)}\", $2.${4:name})}\n\tend\n}",
|
|
298
|
+
"insertTextRules": 4,
|
|
299
|
+
"sortText": "00_metatable___tostring"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"label": "metatable __call",
|
|
303
|
+
"kind": 15,
|
|
304
|
+
"detail": "Metatable with __call",
|
|
305
|
+
"documentation": {
|
|
306
|
+
"value": "Makes a table callable.\n\n```lua\nlocal mt = {\n __call = function(self, ...)\n return self:new(...)\n end\n}\n```"
|
|
307
|
+
},
|
|
308
|
+
"insertText": "local ${1:mt} = {\n\t__call = function(${2:self}, ${3:...})\n\t\t$0\n\tend\n}",
|
|
309
|
+
"insertTextRules": 4,
|
|
310
|
+
"sortText": "00_metatable___call"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"label": "metatable __add",
|
|
314
|
+
"kind": 15,
|
|
315
|
+
"detail": "Metatable with __add",
|
|
316
|
+
"documentation": {
|
|
317
|
+
"value": "Overloads the `+` operator.\n\n```lua\nlocal mt = {\n __add = function(a, b)\n return Vector(a.x + b.x, a.y + b.y)\n end\n}\n```"
|
|
318
|
+
},
|
|
319
|
+
"insertText": "local ${1:mt} = {\n\t__add = function(${2:a}, ${3:b})\n\t\treturn $0\n\tend\n}",
|
|
320
|
+
"insertTextRules": 4,
|
|
321
|
+
"sortText": "00_metatable___add"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"label": "metatable __eq",
|
|
325
|
+
"kind": 15,
|
|
326
|
+
"detail": "Metatable with __eq",
|
|
327
|
+
"documentation": {
|
|
328
|
+
"value": "Overloads the `==` operator.\n\n```lua\nlocal mt = {\n __eq = function(a, b)\n return a.id == b.id\n end\n}\n```"
|
|
329
|
+
},
|
|
330
|
+
"insertText": "local ${1:mt} = {\n\t__eq = function(${2:a}, ${3:b})\n\t\treturn $0\n\tend\n}",
|
|
331
|
+
"insertTextRules": 4,
|
|
332
|
+
"sortText": "00_metatable___eq"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"label": "metatable __len",
|
|
336
|
+
"kind": 15,
|
|
337
|
+
"detail": "Metatable with __len",
|
|
338
|
+
"documentation": {
|
|
339
|
+
"value": "Overloads the `#` (length) operator.\n\n```lua\nlocal mt = {\n __len = function(self)\n return self.count\n end\n}\n```"
|
|
340
|
+
},
|
|
341
|
+
"insertText": "local ${1:mt} = {\n\t__len = function(${2:self})\n\t\treturn ${0:self.count}\n\tend\n}",
|
|
342
|
+
"insertTextRules": 4,
|
|
343
|
+
"sortText": "00_metatable___len"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"label": "metatable __concat",
|
|
347
|
+
"kind": 15,
|
|
348
|
+
"detail": "Metatable with __concat",
|
|
349
|
+
"documentation": {
|
|
350
|
+
"value": "Overloads the `..` (concatenation) operator.\n\n```lua\nlocal mt = {\n __concat = function(a, b)\n return tostring(a) .. tostring(b)\n end\n}\n```"
|
|
351
|
+
},
|
|
352
|
+
"insertText": "local ${1:mt} = {\n\t__concat = function(${2:a}, ${3:b})\n\t\treturn $0\n\tend\n}",
|
|
353
|
+
"insertTextRules": 4,
|
|
354
|
+
"sortText": "00_metatable___concat"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
"label": "metatable __lt",
|
|
358
|
+
"kind": 15,
|
|
359
|
+
"detail": "Metatable with __lt",
|
|
360
|
+
"documentation": {
|
|
361
|
+
"value": "Overloads the `<` operator for ordering.\n\n```lua\nlocal mt = {\n __lt = function(a, b)\n return a.value < b.value\n end\n}\n```"
|
|
362
|
+
},
|
|
363
|
+
"insertText": "local ${1:mt} = {\n\t__lt = function(${2:a}, ${3:b})\n\t\treturn $0\n\tend\n}",
|
|
364
|
+
"insertTextRules": 4,
|
|
365
|
+
"sortText": "00_metatable___lt"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"label": "metatable __gc",
|
|
369
|
+
"kind": 15,
|
|
370
|
+
"detail": "Metatable with __gc (finalizer)",
|
|
371
|
+
"documentation": {
|
|
372
|
+
"value": "Finalizer called when a userdata/table is garbage collected (Lua 5.2+).\n\n```lua\nlocal mt = {\n __gc = function(self)\n self:close()\n end\n}\n```"
|
|
373
|
+
},
|
|
374
|
+
"insertText": "local ${1:mt} = {\n\t__gc = function(${2:self})\n\t\t$0\n\tend\n}",
|
|
375
|
+
"insertTextRules": 4,
|
|
376
|
+
"sortText": "00_metatable___gc"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"label": "class pattern",
|
|
380
|
+
"kind": 15,
|
|
381
|
+
"detail": "OOP class pattern",
|
|
382
|
+
"documentation": {
|
|
383
|
+
"value": "Basic class/prototype pattern using metatables.\n\n```lua\nlocal MyClass = {}\nMyClass.__index = MyClass\n\nfunction MyClass.new(name)\n return setmetatable({ name = name }, MyClass)\nend\n\nfunction MyClass:greet()\n print(\"Hello, \" .. self.name)\nend\n```"
|
|
384
|
+
},
|
|
385
|
+
"insertText": "local ${1:MyClass} = {}\n$1.__index = $1\n\nfunction $1.new(${2:params})\n\treturn setmetatable({${3:fields}}, $1)\nend\n\nfunction $1:${4:method}(${5:})\n\t$0\nend",
|
|
386
|
+
"insertTextRules": 4,
|
|
387
|
+
"sortText": "00_class_pattern"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"label": "inheritance pattern",
|
|
391
|
+
"kind": 15,
|
|
392
|
+
"detail": "OOP inheritance pattern",
|
|
393
|
+
"documentation": {
|
|
394
|
+
"value": "Single inheritance using metatables.\n\n```lua\nlocal Child = setmetatable({}, { __index = Parent })\nChild.__index = Child\n\nfunction Child.new(...)\n local self = Parent.new(...)\n return setmetatable(self, Child)\nend\n```"
|
|
395
|
+
},
|
|
396
|
+
"insertText": "local ${1:Child} = setmetatable({}, { __index = ${2:Parent} })\n$1.__index = $1\n\nfunction $1.new(${3:params})\n\tlocal self = $2.new(${4:params})\n\treturn setmetatable(self, $1)\nend\n\n$0",
|
|
397
|
+
"insertTextRules": 4,
|
|
398
|
+
"sortText": "00_inheritance_pattern"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"label": "mixin pattern",
|
|
402
|
+
"kind": 15,
|
|
403
|
+
"detail": "Mixin pattern",
|
|
404
|
+
"documentation": {
|
|
405
|
+
"value": "Copies methods from a mixin table into a target.\n\n```lua\nlocal function mixin(target, ...)\n for _, mix in ipairs({...}) do\n for k, v in pairs(mix) do\n target[k] = v\n end\n end\n return target\nend\n```"
|
|
406
|
+
},
|
|
407
|
+
"insertText": "local function mixin(${1:target}, ...)\n\tfor _, mix in ipairs({...}) do\n\t\tfor k, v in pairs(mix) do\n\t\t\t$1[k] = v\n\t\tend\n\tend\n\treturn $1\nend\n$0",
|
|
408
|
+
"insertTextRules": 4,
|
|
409
|
+
"sortText": "00_mixin_pattern"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"label": "local",
|
|
413
|
+
"kind": 15,
|
|
414
|
+
"detail": "Local variable declaration",
|
|
415
|
+
"documentation": {
|
|
416
|
+
"value": "Declares a local variable.\n\n```lua\nlocal x = 42\n```"
|
|
417
|
+
},
|
|
418
|
+
"insertText": "local ${1:name} = ${0:value}",
|
|
419
|
+
"insertTextRules": 4,
|
|
420
|
+
"sortText": "00_local"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"label": "local multiple",
|
|
424
|
+
"kind": 15,
|
|
425
|
+
"detail": "Local multiple assignment",
|
|
426
|
+
"documentation": {
|
|
427
|
+
"value": "Assigns multiple local variables at once.\n\n```lua\nlocal x, y, z = 1, 2, 3\n```"
|
|
428
|
+
},
|
|
429
|
+
"insertText": "local ${1:a}, ${2:b} = ${3:val1}, ${4:val2}",
|
|
430
|
+
"insertTextRules": 4,
|
|
431
|
+
"sortText": "00_local_multiple"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"label": "local destructure",
|
|
435
|
+
"kind": 15,
|
|
436
|
+
"detail": "Local destructure from function return",
|
|
437
|
+
"documentation": {
|
|
438
|
+
"value": "Captures multiple return values.\n\n```lua\nlocal ok, err = pcall(fn)\n```"
|
|
439
|
+
},
|
|
440
|
+
"insertText": "local ${1:ok}, ${2:err} = ${0:pcall(fn)}",
|
|
441
|
+
"insertTextRules": 4,
|
|
442
|
+
"sortText": "00_local_destructure"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
"label": "module pattern",
|
|
446
|
+
"kind": 15,
|
|
447
|
+
"detail": "Module pattern (return table)",
|
|
448
|
+
"documentation": {
|
|
449
|
+
"value": "Standard Lua module that returns a table.\n\n```lua\nlocal M = {}\n\nfunction M.greet(name)\n return \"Hello, \" .. name\nend\n\nreturn M\n```"
|
|
450
|
+
},
|
|
451
|
+
"insertText": "local ${1:M} = {}\n\n$0\n\nreturn $1",
|
|
452
|
+
"insertTextRules": 4,
|
|
453
|
+
"sortText": "00_module_pattern"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"label": "require",
|
|
457
|
+
"kind": 15,
|
|
458
|
+
"detail": "Require module",
|
|
459
|
+
"documentation": {
|
|
460
|
+
"value": "Load and cache a module.\n\n```lua\nlocal json = require(\"dkjson\")\n```"
|
|
461
|
+
},
|
|
462
|
+
"insertText": "local ${1:mod} = require(\"${2:modname}\")",
|
|
463
|
+
"insertTextRules": 4,
|
|
464
|
+
"sortText": "00_require"
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
"label": "module with local",
|
|
468
|
+
"kind": 15,
|
|
469
|
+
"detail": "Module with local cache",
|
|
470
|
+
"documentation": {
|
|
471
|
+
"value": "Module pattern caching frequently used functions locally.\n\n```lua\nlocal M = {}\nlocal format = string.format\n\nfunction M.hello(name)\n return format(\"Hello, %s!\", name)\nend\n\nreturn M\n```"
|
|
472
|
+
},
|
|
473
|
+
"insertText": "local ${1:M} = {}\nlocal ${2:format} = string.${3:format}\n\n$0\n\nreturn $1",
|
|
474
|
+
"insertTextRules": 4,
|
|
475
|
+
"sortText": "00_module_with_local"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"label": "string.find",
|
|
479
|
+
"kind": 15,
|
|
480
|
+
"detail": "string.find usage",
|
|
481
|
+
"documentation": {
|
|
482
|
+
"value": "Find a pattern in a string.\n\n```lua\nlocal s, e = string.find(str, pattern)\n```"
|
|
483
|
+
},
|
|
484
|
+
"insertText": "local ${1:s}, ${2:e} = string.find(${3:str}, \"${4:pattern}\")",
|
|
485
|
+
"insertTextRules": 4,
|
|
486
|
+
"sortText": "00_string.find"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"label": "string.match",
|
|
490
|
+
"kind": 15,
|
|
491
|
+
"detail": "string.match usage",
|
|
492
|
+
"documentation": {
|
|
493
|
+
"value": "Extract the first match of a pattern.\n\n```lua\nlocal result = string.match(str, pattern)\n```"
|
|
494
|
+
},
|
|
495
|
+
"insertText": "local ${1:result} = string.match(${2:str}, \"${3:pattern}\")",
|
|
496
|
+
"insertTextRules": 4,
|
|
497
|
+
"sortText": "00_string.match"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"label": "string.gmatch",
|
|
501
|
+
"kind": 15,
|
|
502
|
+
"detail": "string.gmatch iteration",
|
|
503
|
+
"documentation": {
|
|
504
|
+
"value": "Iterate over all pattern matches.\n\n```lua\nfor word in string.gmatch(str, \"%S+\") do\n print(word)\nend\n```"
|
|
505
|
+
},
|
|
506
|
+
"insertText": "for ${1:match} in string.gmatch(${2:str}, \"${3:pattern}\") do\n\t$0\nend",
|
|
507
|
+
"insertTextRules": 4,
|
|
508
|
+
"sortText": "00_string.gmatch"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"label": "string.gsub",
|
|
512
|
+
"kind": 15,
|
|
513
|
+
"detail": "string.gsub replacement",
|
|
514
|
+
"documentation": {
|
|
515
|
+
"value": "Replace pattern occurrences.\n\n```lua\nlocal result = string.gsub(str, pattern, repl)\n```"
|
|
516
|
+
},
|
|
517
|
+
"insertText": "local ${1:result} = string.gsub(${2:str}, \"${3:pattern}\", ${4:repl})",
|
|
518
|
+
"insertTextRules": 4,
|
|
519
|
+
"sortText": "00_string.gsub"
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
"label": "string.format",
|
|
523
|
+
"kind": 15,
|
|
524
|
+
"detail": "string.format usage",
|
|
525
|
+
"documentation": {
|
|
526
|
+
"value": "Format a string.\n\n```lua\nlocal s = string.format(\"%s = %d\", name, value)\n```"
|
|
527
|
+
},
|
|
528
|
+
"insertText": "local ${1:s} = string.format(\"${2:%s}\", ${3:args})",
|
|
529
|
+
"insertTextRules": 4,
|
|
530
|
+
"sortText": "00_string.format"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"label": "coroutine.create",
|
|
534
|
+
"kind": 15,
|
|
535
|
+
"detail": "Create a coroutine",
|
|
536
|
+
"documentation": {
|
|
537
|
+
"value": "Creates a new coroutine from a function.\n\n```lua\nlocal co = coroutine.create(function()\n coroutine.yield(1)\n return 2\nend)\n```"
|
|
538
|
+
},
|
|
539
|
+
"insertText": "local ${1:co} = coroutine.create(function(${2:})\n\t$0\nend)",
|
|
540
|
+
"insertTextRules": 4,
|
|
541
|
+
"sortText": "00_coroutine.create"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"label": "coroutine.wrap",
|
|
545
|
+
"kind": 15,
|
|
546
|
+
"detail": "Wrap a coroutine",
|
|
547
|
+
"documentation": {
|
|
548
|
+
"value": "Creates a coroutine wrapped as a callable function.\n\n```lua\nlocal gen = coroutine.wrap(function()\n coroutine.yield(1)\n coroutine.yield(2)\nend)\nprint(gen()) -- 1\nprint(gen()) -- 2\n```"
|
|
549
|
+
},
|
|
550
|
+
"insertText": "local ${1:gen} = coroutine.wrap(function(${2:})\n\t$0\nend)",
|
|
551
|
+
"insertTextRules": 4,
|
|
552
|
+
"sortText": "00_coroutine.wrap"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"label": "coroutine resume/yield",
|
|
556
|
+
"kind": 15,
|
|
557
|
+
"detail": "Coroutine resume/yield pattern",
|
|
558
|
+
"documentation": {
|
|
559
|
+
"value": "Basic producer-consumer with resume and yield.\n\n```lua\nlocal co = coroutine.create(function()\n for i = 1, 5 do\n coroutine.yield(i)\n end\nend)\n\nwhile true do\n local ok, val = coroutine.resume(co)\n if not ok then break end\n print(val)\nend\n```"
|
|
560
|
+
},
|
|
561
|
+
"insertText": "local ${1:co} = coroutine.create(function()\n\tfor ${2:i} = ${3:1}, ${4:n} do\n\t\tcoroutine.yield(${5:i})\n\tend\nend)\n\nwhile true do\n\tlocal ok, val = coroutine.resume($1)\n\tif not ok then break end\n\t$0\nend",
|
|
562
|
+
"insertTextRules": 4,
|
|
563
|
+
"sortText": "00_coroutine_resume/yield"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
"label": "producer-consumer",
|
|
567
|
+
"kind": 15,
|
|
568
|
+
"detail": "Producer-consumer coroutine pattern",
|
|
569
|
+
"documentation": {
|
|
570
|
+
"value": "Coroutine-based producer-consumer.\n\n```lua\nlocal function producer()\n return coroutine.wrap(function()\n while true do\n local item = produce()\n coroutine.yield(item)\n end\n end)\nend\n\nfor item in producer() do\n consume(item)\nend\n```"
|
|
571
|
+
},
|
|
572
|
+
"insertText": "local function ${1:producer}()\n\treturn coroutine.wrap(function()\n\t\t${2:-- produce items}\n\t\tcoroutine.yield(${3:item})\n\tend)\nend\n\nfor ${4:item} in $1() do\n\t$0\nend",
|
|
573
|
+
"insertTextRules": 4,
|
|
574
|
+
"sortText": "00_producer-consumer"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"label": "io.open read",
|
|
578
|
+
"kind": 15,
|
|
579
|
+
"detail": "Read file with io.open",
|
|
580
|
+
"documentation": {
|
|
581
|
+
"value": "Open a file for reading and read its contents.\n\n```lua\nlocal f = io.open(\"file.txt\", \"r\")\nif f then\n local content = f:read(\"*a\")\n f:close()\nend\n```"
|
|
582
|
+
},
|
|
583
|
+
"insertText": "local ${1:f} = io.open(\"${2:filename}\", \"r\")\nif $1 then\n\tlocal ${3:content} = $1:read(\"*a\")\n\t$1:close()\n\t$0\nend",
|
|
584
|
+
"insertTextRules": 4,
|
|
585
|
+
"sortText": "00_io.open_read"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"label": "io.open write",
|
|
589
|
+
"kind": 15,
|
|
590
|
+
"detail": "Write file with io.open",
|
|
591
|
+
"documentation": {
|
|
592
|
+
"value": "Open a file for writing.\n\n```lua\nlocal f = io.open(\"file.txt\", \"w\")\nif f then\n f:write(\"Hello\\n\")\n f:close()\nend\n```"
|
|
593
|
+
},
|
|
594
|
+
"insertText": "local ${1:f} = io.open(\"${2:filename}\", \"w\")\nif $1 then\n\t$1:write(${3:data})\n\t$1:close()\n\t$0\nend",
|
|
595
|
+
"insertTextRules": 4,
|
|
596
|
+
"sortText": "00_io.open_write"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"label": "io.open append",
|
|
600
|
+
"kind": 15,
|
|
601
|
+
"detail": "Append to file with io.open",
|
|
602
|
+
"documentation": {
|
|
603
|
+
"value": "Open a file for appending.\n\n```lua\nlocal f = io.open(\"log.txt\", \"a\")\nif f then\n f:write(os.date() .. \" entry\\n\")\n f:close()\nend\n```"
|
|
604
|
+
},
|
|
605
|
+
"insertText": "local ${1:f} = io.open(\"${2:filename}\", \"a\")\nif $1 then\n\t$1:write(${3:data})\n\t$1:close()\n\t$0\nend",
|
|
606
|
+
"insertTextRules": 4,
|
|
607
|
+
"sortText": "00_io.open_append"
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
"label": "io.lines",
|
|
611
|
+
"kind": 15,
|
|
612
|
+
"detail": "Iterate lines of a file",
|
|
613
|
+
"documentation": {
|
|
614
|
+
"value": "Read a file line by line.\n\n```lua\nfor line in io.lines(\"file.txt\") do\n print(line)\nend\n```"
|
|
615
|
+
},
|
|
616
|
+
"insertText": "for ${1:line} in io.lines(\"${2:filename}\") do\n\t$0\nend",
|
|
617
|
+
"insertTextRules": 4,
|
|
618
|
+
"sortText": "00_io.lines"
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
"label": "io.read stdin",
|
|
622
|
+
"kind": 15,
|
|
623
|
+
"detail": "Read from stdin",
|
|
624
|
+
"documentation": {
|
|
625
|
+
"value": "Read a line from standard input.\n\n```lua\nio.write(\"Enter name: \")\nlocal name = io.read()\n```"
|
|
626
|
+
},
|
|
627
|
+
"insertText": "io.write(\"${1:prompt: }\")\nlocal ${2:input} = io.read(${3:\"*l\"})",
|
|
628
|
+
"insertTextRules": 4,
|
|
629
|
+
"sortText": "00_io.read_stdin"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"label": "os.execute",
|
|
633
|
+
"kind": 15,
|
|
634
|
+
"detail": "Execute a shell command",
|
|
635
|
+
"documentation": {
|
|
636
|
+
"value": "Execute a command in the OS shell.\n\n```lua\nos.execute(\"ls -la\")\n```"
|
|
637
|
+
},
|
|
638
|
+
"insertText": "os.execute(\"${1:command}\")",
|
|
639
|
+
"insertTextRules": 4,
|
|
640
|
+
"sortText": "00_os.execute"
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"label": "os.clock",
|
|
644
|
+
"kind": 15,
|
|
645
|
+
"detail": "Measure elapsed CPU time",
|
|
646
|
+
"documentation": {
|
|
647
|
+
"value": "Returns CPU time used by the program.\n\n```lua\nlocal start = os.clock()\n-- work\nprint(string.format(\"Elapsed: %.3f s\", os.clock() - start))\n```"
|
|
648
|
+
},
|
|
649
|
+
"insertText": "local ${1:start} = os.clock()\n$0\nprint(string.format(\"Elapsed: %.3f s\", os.clock() - $1))",
|
|
650
|
+
"insertTextRules": 4,
|
|
651
|
+
"sortText": "00_os.clock"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"label": "os.time",
|
|
655
|
+
"kind": 15,
|
|
656
|
+
"detail": "Get current time",
|
|
657
|
+
"documentation": {
|
|
658
|
+
"value": "Returns the current time as a number (epoch seconds).\n\n```lua\nlocal now = os.time()\n```"
|
|
659
|
+
},
|
|
660
|
+
"insertText": "local ${1:now} = os.time()",
|
|
661
|
+
"insertTextRules": 4,
|
|
662
|
+
"sortText": "00_os.time"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"label": "os.date",
|
|
666
|
+
"kind": 15,
|
|
667
|
+
"detail": "Format date/time",
|
|
668
|
+
"documentation": {
|
|
669
|
+
"value": "Format a date/time string.\n\n```lua\nprint(os.date(\"%Y-%m-%d %H:%M:%S\"))\n```"
|
|
670
|
+
},
|
|
671
|
+
"insertText": "os.date(\"${1:%Y-%m-%d %H:%M:%S}\"${2:, os.time()})",
|
|
672
|
+
"insertTextRules": 4,
|
|
673
|
+
"sortText": "00_os.date"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
"label": "pcall",
|
|
677
|
+
"kind": 15,
|
|
678
|
+
"detail": "Protected call",
|
|
679
|
+
"documentation": {
|
|
680
|
+
"value": "Call a function in protected mode.\n\n```lua\nlocal ok, result = pcall(function()\n -- code that may error\nend)\nif not ok then\n print(\"Error: \" .. result)\nend\n```"
|
|
681
|
+
},
|
|
682
|
+
"insertText": "local ${1:ok}, ${2:result} = pcall(function()\n\t$0\nend)\nif not $1 then\n\tprint(\"Error: \" .. tostring($2))\nend",
|
|
683
|
+
"insertTextRules": 4,
|
|
684
|
+
"sortText": "00_pcall"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"label": "xpcall",
|
|
688
|
+
"kind": 15,
|
|
689
|
+
"detail": "Extended protected call",
|
|
690
|
+
"documentation": {
|
|
691
|
+
"value": "Call a function in protected mode with error handler.\n\n```lua\nlocal ok, result = xpcall(function()\n error(\"oops\")\nend, debug.traceback)\n```"
|
|
692
|
+
},
|
|
693
|
+
"insertText": "local ${1:ok}, ${2:result} = xpcall(function()\n\t$0\nend, ${3:debug.traceback})",
|
|
694
|
+
"insertTextRules": 4,
|
|
695
|
+
"sortText": "00_xpcall"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"label": "error",
|
|
699
|
+
"kind": 15,
|
|
700
|
+
"detail": "Raise an error",
|
|
701
|
+
"documentation": {
|
|
702
|
+
"value": "Terminates the last protected call with the error message.\n\n```lua\nerror(\"something went wrong\", 2)\n```"
|
|
703
|
+
},
|
|
704
|
+
"insertText": "error(\"${1:message}\"${2:, ${3:level}})",
|
|
705
|
+
"insertTextRules": 4,
|
|
706
|
+
"sortText": "00_error"
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"label": "assert",
|
|
710
|
+
"kind": 15,
|
|
711
|
+
"detail": "Assert a condition",
|
|
712
|
+
"documentation": {
|
|
713
|
+
"value": "Raises an error if the value is falsy.\n\n```lua\nlocal f = assert(io.open(filename, \"r\"))\n```"
|
|
714
|
+
},
|
|
715
|
+
"insertText": "assert(${1:value}, \"${2:assertion failed}\")",
|
|
716
|
+
"insertTextRules": 4,
|
|
717
|
+
"sortText": "00_assert"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"label": "debug.traceback",
|
|
721
|
+
"kind": 15,
|
|
722
|
+
"detail": "Get stack traceback",
|
|
723
|
+
"documentation": {
|
|
724
|
+
"value": "Returns a string with a traceback of the call stack.\n\n```lua\nprint(debug.traceback(\"Error occurred\", 2))\n```"
|
|
725
|
+
},
|
|
726
|
+
"insertText": "debug.traceback(\"${1:message}\", ${2:2})",
|
|
727
|
+
"insertTextRules": 4,
|
|
728
|
+
"sortText": "00_debug.traceback"
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"label": "debug.getinfo",
|
|
732
|
+
"kind": 15,
|
|
733
|
+
"detail": "Get function information",
|
|
734
|
+
"documentation": {
|
|
735
|
+
"value": "Returns a table with information about a function.\n\n```lua\nlocal info = debug.getinfo(1, \"Sln\")\nprint(info.short_src, info.currentline)\n```"
|
|
736
|
+
},
|
|
737
|
+
"insertText": "local ${1:info} = debug.getinfo(${2:1}, \"${3:Sln}\")",
|
|
738
|
+
"insertTextRules": 4,
|
|
739
|
+
"sortText": "00_debug.getinfo"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"label": "math.random range",
|
|
743
|
+
"kind": 15,
|
|
744
|
+
"detail": "Random number in range",
|
|
745
|
+
"documentation": {
|
|
746
|
+
"value": "Generate a random integer in a range.\n\n```lua\nlocal n = math.random(1, 100)\n```"
|
|
747
|
+
},
|
|
748
|
+
"insertText": "math.random(${1:1}, ${2:100})",
|
|
749
|
+
"insertTextRules": 4,
|
|
750
|
+
"sortText": "00_math.random_range"
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
"label": "math.floor division",
|
|
754
|
+
"kind": 15,
|
|
755
|
+
"detail": "Floor division",
|
|
756
|
+
"documentation": {
|
|
757
|
+
"value": "Integer division using math.floor.\n\n```lua\nlocal q = math.floor(a / b)\n```"
|
|
758
|
+
},
|
|
759
|
+
"insertText": "math.floor(${1:a} / ${2:b})",
|
|
760
|
+
"insertTextRules": 4,
|
|
761
|
+
"sortText": "00_math.floor_division"
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
"label": "math.max min clamp",
|
|
765
|
+
"kind": 15,
|
|
766
|
+
"detail": "Clamp value to range",
|
|
767
|
+
"documentation": {
|
|
768
|
+
"value": "Clamp a value between min and max.\n\n```lua\nlocal clamped = math.max(lo, math.min(hi, value))\n```"
|
|
769
|
+
},
|
|
770
|
+
"insertText": "math.max(${1:lo}, math.min(${2:hi}, ${3:value}))",
|
|
771
|
+
"insertTextRules": 4,
|
|
772
|
+
"sortText": "00_math.max_min_clamp"
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
"label": "iterator stateless",
|
|
776
|
+
"kind": 15,
|
|
777
|
+
"detail": "Stateless iterator",
|
|
778
|
+
"documentation": {
|
|
779
|
+
"value": "A stateless custom iterator function.\n\n```lua\nlocal function squares(max, i)\n i = i + 1\n if i > max then return nil end\n return i, i * i\nend\n\nfor i, sq in squares, 5, 0 do\n print(i, sq)\nend\n```"
|
|
780
|
+
},
|
|
781
|
+
"insertText": "local function ${1:iter}(${2:invariant}, ${3:control})\n\t$3 = $3 + 1\n\tif $3 > $2 then return nil end\n\treturn $3, ${0:value}\nend",
|
|
782
|
+
"insertTextRules": 4,
|
|
783
|
+
"sortText": "00_iterator_stateless"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"label": "iterator stateful",
|
|
787
|
+
"kind": 15,
|
|
788
|
+
"detail": "Stateful iterator (closure)",
|
|
789
|
+
"documentation": {
|
|
790
|
+
"value": "A stateful custom iterator using a closure.\n\n```lua\nlocal function range(n)\n local i = 0\n return function()\n i = i + 1\n if i <= n then return i end\n end\nend\n\nfor v in range(5) do print(v) end\n```"
|
|
791
|
+
},
|
|
792
|
+
"insertText": "local function ${1:range}(${2:n})\n\tlocal ${3:i} = 0\n\treturn function()\n\t\t$3 = $3 + 1\n\t\tif $3 <= $2 then return $3 end\n\tend\nend\n$0",
|
|
793
|
+
"insertTextRules": 4,
|
|
794
|
+
"sortText": "00_iterator_stateful"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"label": "generic for custom",
|
|
798
|
+
"kind": 15,
|
|
799
|
+
"detail": "Generic for with custom iterator",
|
|
800
|
+
"documentation": {
|
|
801
|
+
"value": "Using a custom iterator in a generic for loop.\n\n```lua\nfor value in myiter(args) do\n print(value)\nend\n```"
|
|
802
|
+
},
|
|
803
|
+
"insertText": "for ${1:value} in ${2:iterator}(${3:args}) do\n\t$0\nend",
|
|
804
|
+
"insertTextRules": 4,
|
|
805
|
+
"sortText": "00_generic_for_custom"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
"label": "integer division //",
|
|
809
|
+
"kind": 15,
|
|
810
|
+
"detail": "Integer division (5.3+)",
|
|
811
|
+
"documentation": {
|
|
812
|
+
"value": "Floor division operator available since Lua 5.3.\n\n```lua\nlocal q = 7 // 2 -- 3\n```"
|
|
813
|
+
},
|
|
814
|
+
"insertText": "${1:a} // ${2:b}",
|
|
815
|
+
"insertTextRules": 4,
|
|
816
|
+
"sortText": "00_integer_division_//"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"label": "bitwise and &",
|
|
820
|
+
"kind": 15,
|
|
821
|
+
"detail": "Bitwise AND (5.3+)",
|
|
822
|
+
"documentation": {
|
|
823
|
+
"value": "Bitwise AND operator.\n\n```lua\nlocal result = a & b\n```"
|
|
824
|
+
},
|
|
825
|
+
"insertText": "${1:a} & ${2:b}",
|
|
826
|
+
"insertTextRules": 4,
|
|
827
|
+
"sortText": "00_bitwise_and_&"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"label": "bitwise or |",
|
|
831
|
+
"kind": 15,
|
|
832
|
+
"detail": "Bitwise OR (5.3+)",
|
|
833
|
+
"documentation": {
|
|
834
|
+
"value": "Bitwise OR operator.\n\n```lua\nlocal result = a | b\n```"
|
|
835
|
+
},
|
|
836
|
+
"insertText": "${1:a} | ${2:b}",
|
|
837
|
+
"insertTextRules": 4,
|
|
838
|
+
"sortText": "00_bitwise_or_|"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"label": "bitwise xor ~",
|
|
842
|
+
"kind": 15,
|
|
843
|
+
"detail": "Bitwise XOR (5.3+)",
|
|
844
|
+
"documentation": {
|
|
845
|
+
"value": "Bitwise XOR operator (tilde).\n\n```lua\nlocal result = a ~ b\n```"
|
|
846
|
+
},
|
|
847
|
+
"insertText": "${1:a} ~ ${2:b}",
|
|
848
|
+
"insertTextRules": 4,
|
|
849
|
+
"sortText": "00_bitwise_xor_~"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
"label": "bitwise not ~",
|
|
853
|
+
"kind": 15,
|
|
854
|
+
"detail": "Bitwise NOT (5.3+)",
|
|
855
|
+
"documentation": {
|
|
856
|
+
"value": "Bitwise NOT (unary tilde).\n\n```lua\nlocal result = ~a\n```"
|
|
857
|
+
},
|
|
858
|
+
"insertText": "~${1:a}",
|
|
859
|
+
"insertTextRules": 4,
|
|
860
|
+
"sortText": "00_bitwise_not_~"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
"label": "bitwise shift",
|
|
864
|
+
"kind": 15,
|
|
865
|
+
"detail": "Bitwise shift (5.3+)",
|
|
866
|
+
"documentation": {
|
|
867
|
+
"value": "Left/right bit shift operators.\n\n```lua\nlocal l = a << n\nlocal r = a >> n\n```"
|
|
868
|
+
},
|
|
869
|
+
"insertText": "${1:a} ${2:<<} ${3:n}",
|
|
870
|
+
"insertTextRules": 4,
|
|
871
|
+
"sortText": "00_bitwise_shift"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
"label": "goto label",
|
|
875
|
+
"kind": 15,
|
|
876
|
+
"detail": "Goto and label (5.2+)",
|
|
877
|
+
"documentation": {
|
|
878
|
+
"value": "Jump to a label.\n\n```lua\ngoto done\n-- skipped code\n::done::\n```"
|
|
879
|
+
},
|
|
880
|
+
"insertText": "goto ${1:label}\n$0\n::$1::",
|
|
881
|
+
"insertTextRules": 4,
|
|
882
|
+
"sortText": "00_goto_label"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
"label": "string.pack",
|
|
886
|
+
"kind": 15,
|
|
887
|
+
"detail": "string.pack (5.3+)",
|
|
888
|
+
"documentation": {
|
|
889
|
+
"value": "Pack values into a binary string.\n\n```lua\nlocal data = string.pack(\"i4i4\", 42, 99)\n```"
|
|
890
|
+
},
|
|
891
|
+
"insertText": "local ${1:data} = string.pack(\"${2:fmt}\", ${3:values})",
|
|
892
|
+
"insertTextRules": 4,
|
|
893
|
+
"sortText": "00_string.pack"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"label": "string.unpack",
|
|
897
|
+
"kind": 15,
|
|
898
|
+
"detail": "string.unpack (5.3+)",
|
|
899
|
+
"documentation": {
|
|
900
|
+
"value": "Unpack values from a binary string.\n\n```lua\nlocal a, b = string.unpack(\"i4i4\", data)\n```"
|
|
901
|
+
},
|
|
902
|
+
"insertText": "local ${1:a}, ${2:b} = string.unpack(\"${3:fmt}\", ${4:data})",
|
|
903
|
+
"insertTextRules": 4,
|
|
904
|
+
"sortText": "00_string.unpack"
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
"label": "utf8.codes",
|
|
908
|
+
"kind": 15,
|
|
909
|
+
"detail": "utf8.codes iteration (5.3+)",
|
|
910
|
+
"documentation": {
|
|
911
|
+
"value": "Iterate over UTF-8 codepoints.\n\n```lua\nfor pos, code in utf8.codes(s) do\n print(pos, code)\nend\n```"
|
|
912
|
+
},
|
|
913
|
+
"insertText": "for ${1:pos}, ${2:code} in utf8.codes(${3:s}) do\n\t$0\nend",
|
|
914
|
+
"insertTextRules": 4,
|
|
915
|
+
"sortText": "00_utf8.codes"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"label": "utf8.len",
|
|
919
|
+
"kind": 15,
|
|
920
|
+
"detail": "utf8.len (5.3+)",
|
|
921
|
+
"documentation": {
|
|
922
|
+
"value": "Get the number of UTF-8 characters.\n\n```lua\nlocal n = utf8.len(s)\n```"
|
|
923
|
+
},
|
|
924
|
+
"insertText": "local ${1:n} = utf8.len(${2:s})",
|
|
925
|
+
"insertTextRules": 4,
|
|
926
|
+
"sortText": "00_utf8.len"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"label": "ffi.cdef",
|
|
930
|
+
"kind": 15,
|
|
931
|
+
"detail": "FFI C definition (LuaJIT)",
|
|
932
|
+
"documentation": {
|
|
933
|
+
"value": "Declare C types and functions for FFI.\n\n```lua\nlocal ffi = require(\"ffi\")\nffi.cdef[[\n int printf(const char *fmt, ...);\n]]\n```"
|
|
934
|
+
},
|
|
935
|
+
"insertText": "local ffi = require(\"ffi\")\nffi.cdef[[\n\t${1:int printf(const char *fmt, ...);}\n]]",
|
|
936
|
+
"insertTextRules": 4,
|
|
937
|
+
"sortText": "00_ffi.cdef"
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
"label": "ffi.new",
|
|
941
|
+
"kind": 15,
|
|
942
|
+
"detail": "FFI allocate C data (LuaJIT)",
|
|
943
|
+
"documentation": {
|
|
944
|
+
"value": "Allocate a new C data object.\n\n```lua\nlocal buf = ffi.new(\"char[?]\", 256)\n```"
|
|
945
|
+
},
|
|
946
|
+
"insertText": "local ${1:ptr} = ffi.new(\"${2:type}\"${3:, ${4:size}})",
|
|
947
|
+
"insertTextRules": 4,
|
|
948
|
+
"sortText": "00_ffi.new"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
"label": "ffi.cast",
|
|
952
|
+
"kind": 15,
|
|
953
|
+
"detail": "FFI cast pointer (LuaJIT)",
|
|
954
|
+
"documentation": {
|
|
955
|
+
"value": "Cast a pointer to another type.\n\n```lua\nlocal p = ffi.cast(\"int*\", buf)\n```"
|
|
956
|
+
},
|
|
957
|
+
"insertText": "local ${1:p} = ffi.cast(\"${2:type}\", ${3:ptr})",
|
|
958
|
+
"insertTextRules": 4,
|
|
959
|
+
"sortText": "00_ffi.cast"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"label": "ffi.load",
|
|
963
|
+
"kind": 15,
|
|
964
|
+
"detail": "FFI load shared library (LuaJIT)",
|
|
965
|
+
"documentation": {
|
|
966
|
+
"value": "Load a shared library.\n\n```lua\nlocal lib = ffi.load(\"mylib\")\n```"
|
|
967
|
+
},
|
|
968
|
+
"insertText": "local ${1:lib} = ffi.load(\"${2:libname}\")",
|
|
969
|
+
"insertTextRules": 4,
|
|
970
|
+
"sortText": "00_ffi.load"
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
"label": "enum pattern",
|
|
974
|
+
"kind": 15,
|
|
975
|
+
"detail": "Enum / constants pattern",
|
|
976
|
+
"documentation": {
|
|
977
|
+
"value": "Use a table of constants as an enum.\n\n```lua\nlocal Color = {\n RED = 1,\n GREEN = 2,\n BLUE = 3,\n}\n```"
|
|
978
|
+
},
|
|
979
|
+
"insertText": "local ${1:Enum} = {\n\t${2:VALUE1} = ${3:1},\n\t${4:VALUE2} = ${5:2},\n\t$0\n}",
|
|
980
|
+
"insertTextRules": 4,
|
|
981
|
+
"sortText": "00_enum_pattern"
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
"label": "singleton pattern",
|
|
985
|
+
"kind": 15,
|
|
986
|
+
"detail": "Singleton pattern",
|
|
987
|
+
"documentation": {
|
|
988
|
+
"value": "Ensure a single instance via module caching.\n\n```lua\nlocal instance\nlocal M = {}\nfunction M.getInstance()\n if not instance then instance = M.new() end\n return instance\nend\nreturn M\n```"
|
|
989
|
+
},
|
|
990
|
+
"insertText": "local instance\nlocal ${1:M} = {}\n\nfunction $1.getInstance()\n\tif not instance then\n\t\tinstance = $1.new()\n\tend\n\treturn instance\nend\n\n$0\n\nreturn $1",
|
|
991
|
+
"insertTextRules": 4,
|
|
992
|
+
"sortText": "00_singleton_pattern"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"label": "callback event",
|
|
996
|
+
"kind": 15,
|
|
997
|
+
"detail": "Callback / event emitter pattern",
|
|
998
|
+
"documentation": {
|
|
999
|
+
"value": "Simple event/callback registration.\n\n```lua\nlocal listeners = {}\nfunction on(event, fn)\n listeners[event] = listeners[event] or {}\n table.insert(listeners[event], fn)\nend\nfunction emit(event, ...)\n for _, fn in ipairs(listeners[event] or {}) do\n fn(...)\n end\nend\n```"
|
|
1000
|
+
},
|
|
1001
|
+
"insertText": "local ${1:listeners} = {}\n\nfunction ${2:on}(${3:event}, ${4:fn})\n\t$1[$3] = $1[$3] or {}\n\ttable.insert($1[$3], $4)\nend\n\nfunction ${5:emit}($3, ...)\n\tfor _, fn in ipairs($1[$3] or {}) do\n\t\tfn(...)\n\tend\nend\n$0",
|
|
1002
|
+
"insertTextRules": 4,
|
|
1003
|
+
"sortText": "00_callback_event"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
"label": "type check guard",
|
|
1007
|
+
"kind": 15,
|
|
1008
|
+
"detail": "Type checking guard",
|
|
1009
|
+
"documentation": {
|
|
1010
|
+
"value": "Guard clause checking argument type.\n\n```lua\nif type(x) ~= \"string\" then\n error(\"expected string, got \" .. type(x), 2)\nend\n```"
|
|
1011
|
+
},
|
|
1012
|
+
"insertText": "if type(${1:x}) ~= \"${2:string}\" then\n\terror(\"expected $2, got \" .. type($1), 2)\nend",
|
|
1013
|
+
"insertTextRules": 4,
|
|
1014
|
+
"sortText": "00_type_check_guard"
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
"label": "deep copy",
|
|
1018
|
+
"kind": 15,
|
|
1019
|
+
"detail": "Deep copy table",
|
|
1020
|
+
"documentation": {
|
|
1021
|
+
"value": "Recursively copy a table and its metatables.\n\n```lua\nlocal function deepcopy(orig)\n if type(orig) ~= \"table\" then return orig end\n local copy = {}\n for k, v in next, orig, nil do\n copy[deepcopy(k)] = deepcopy(v)\n end\n return setmetatable(copy, getmetatable(orig))\nend\n```"
|
|
1022
|
+
},
|
|
1023
|
+
"insertText": "local function deepcopy(orig)\n\tif type(orig) ~= \"table\" then return orig end\n\tlocal copy = {}\n\tfor k, v in next, orig, nil do\n\t\tcopy[deepcopy(k)] = deepcopy(v)\n\tend\n\treturn setmetatable(copy, getmetatable(orig))\nend\n$0",
|
|
1024
|
+
"insertTextRules": 4,
|
|
1025
|
+
"sortText": "00_deep_copy"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
"label": "shallow copy",
|
|
1029
|
+
"kind": 15,
|
|
1030
|
+
"detail": "Shallow copy table",
|
|
1031
|
+
"documentation": {
|
|
1032
|
+
"value": "Copy top-level keys from a table.\n\n```lua\nlocal function shallowcopy(t)\n local copy = {}\n for k, v in pairs(t) do copy[k] = v end\n return setmetatable(copy, getmetatable(t))\nend\n```"
|
|
1033
|
+
},
|
|
1034
|
+
"insertText": "local function shallowcopy(${1:t})\n\tlocal copy = {}\n\tfor k, v in pairs($1) do copy[k] = v end\n\treturn setmetatable(copy, getmetatable($1))\nend\n$0",
|
|
1035
|
+
"insertTextRules": 4,
|
|
1036
|
+
"sortText": "00_shallow_copy"
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
"label": "switch pattern",
|
|
1040
|
+
"kind": 15,
|
|
1041
|
+
"detail": "Switch/case pattern",
|
|
1042
|
+
"documentation": {
|
|
1043
|
+
"value": "Simulate switch/case with a table of handlers.\n\n```lua\nlocal actions = {\n add = function(a, b) return a + b end,\n sub = function(a, b) return a - b end,\n}\nlocal fn = actions[op]\nif fn then fn(a, b) end\n```"
|
|
1044
|
+
},
|
|
1045
|
+
"insertText": "local ${1:actions} = {\n\t${2:case1} = function(${3:})\n\t\t${4:-- handler}\n\tend,\n\t$0\n}\nlocal fn = $1[${5:key}]\nif fn then fn(${6:}) end",
|
|
1046
|
+
"insertTextRules": 4,
|
|
1047
|
+
"sortText": "00_switch_pattern"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"label": "try-catch pattern",
|
|
1051
|
+
"kind": 15,
|
|
1052
|
+
"detail": "Try-catch pattern (pcall wrapper)",
|
|
1053
|
+
"documentation": {
|
|
1054
|
+
"value": "Wrap pcall into a try-catch-like construct.\n\n```lua\nlocal ok, err = pcall(function()\n -- try\nend)\nif not ok then\n -- catch\n print(\"Error: \" .. tostring(err))\nend\n```"
|
|
1055
|
+
},
|
|
1056
|
+
"insertText": "local ok, err = pcall(function()\n\t${1:-- try}\nend)\nif not ok then\n\t${0:-- catch}\nend",
|
|
1057
|
+
"insertTextRules": 4,
|
|
1058
|
+
"sortText": "00_try-catch_pattern"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
"label": "protected require",
|
|
1062
|
+
"kind": 15,
|
|
1063
|
+
"detail": "Protected require",
|
|
1064
|
+
"documentation": {
|
|
1065
|
+
"value": "Safely require a module.\n\n```lua\nlocal ok, mod = pcall(require, \"modname\")\nif not ok then\n print(\"Module not found\")\nend\n```"
|
|
1066
|
+
},
|
|
1067
|
+
"insertText": "local ok, ${1:mod} = pcall(require, \"${2:modname}\")\nif not ok then\n\t${0:-- fallback}\nend",
|
|
1068
|
+
"insertTextRules": 4,
|
|
1069
|
+
"sortText": "00_protected_require"
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
"label": "table merge",
|
|
1073
|
+
"kind": 15,
|
|
1074
|
+
"detail": "Merge tables",
|
|
1075
|
+
"documentation": {
|
|
1076
|
+
"value": "Merge keys from source tables into a target.\n\n```lua\nlocal function merge(target, ...)\n for _, src in ipairs({...}) do\n for k, v in pairs(src) do\n target[k] = v\n end\n end\n return target\nend\n```"
|
|
1077
|
+
},
|
|
1078
|
+
"insertText": "local function merge(${1:target}, ...)\n\tfor _, src in ipairs({...}) do\n\t\tfor k, v in pairs(src) do\n\t\t\t$1[k] = v\n\t\tend\n\tend\n\treturn $1\nend\n$0",
|
|
1079
|
+
"insertTextRules": 4,
|
|
1080
|
+
"sortText": "00_table_merge"
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
"label": "table filter",
|
|
1084
|
+
"kind": 15,
|
|
1085
|
+
"detail": "Filter table elements",
|
|
1086
|
+
"documentation": {
|
|
1087
|
+
"value": "Filter array elements by a predicate.\n\n```lua\nlocal function filter(t, predicate)\n local result = {}\n for _, v in ipairs(t) do\n if predicate(v) then result[#result + 1] = v end\n end\n return result\nend\n```"
|
|
1088
|
+
},
|
|
1089
|
+
"insertText": "local function filter(${1:t}, ${2:predicate})\n\tlocal result = {}\n\tfor _, v in ipairs($1) do\n\t\tif $2(v) then result[#result + 1] = v end\n\tend\n\treturn result\nend\n$0",
|
|
1090
|
+
"insertTextRules": 4,
|
|
1091
|
+
"sortText": "00_table_filter"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
"label": "table map",
|
|
1095
|
+
"kind": 15,
|
|
1096
|
+
"detail": "Map over table elements",
|
|
1097
|
+
"documentation": {
|
|
1098
|
+
"value": "Apply a function to each element of an array.\n\n```lua\nlocal function map(t, fn)\n local result = {}\n for i, v in ipairs(t) do result[i] = fn(v, i) end\n return result\nend\n```"
|
|
1099
|
+
},
|
|
1100
|
+
"insertText": "local function map(${1:t}, ${2:fn})\n\tlocal result = {}\n\tfor i, v in ipairs($1) do result[i] = $2(v, i) end\n\treturn result\nend\n$0",
|
|
1101
|
+
"insertTextRules": 4,
|
|
1102
|
+
"sortText": "00_table_map"
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
"label": "table reduce",
|
|
1106
|
+
"kind": 15,
|
|
1107
|
+
"detail": "Reduce / fold table",
|
|
1108
|
+
"documentation": {
|
|
1109
|
+
"value": "Reduce an array to a single value.\n\n```lua\nlocal function reduce(t, fn, init)\n local acc = init\n for _, v in ipairs(t) do acc = fn(acc, v) end\n return acc\nend\n```"
|
|
1110
|
+
},
|
|
1111
|
+
"insertText": "local function reduce(${1:t}, ${2:fn}, ${3:init})\n\tlocal acc = $3\n\tfor _, v in ipairs($1) do acc = $2(acc, v) end\n\treturn acc\nend\n$0",
|
|
1112
|
+
"insertTextRules": 4,
|
|
1113
|
+
"sortText": "00_table_reduce"
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
"label": "string split",
|
|
1117
|
+
"kind": 15,
|
|
1118
|
+
"detail": "Split string into parts",
|
|
1119
|
+
"documentation": {
|
|
1120
|
+
"value": "Split a string by a delimiter.\n\n```lua\nlocal function split(str, sep)\n local parts = {}\n for part in str:gmatch(\"[^\" .. sep .. \"]+\") do\n parts[#parts + 1] = part\n end\n return parts\nend\n```"
|
|
1121
|
+
},
|
|
1122
|
+
"insertText": "local function split(${1:str}, ${2:sep})\n\tlocal parts = {}\n\tfor part in $1:gmatch(\"[^\" .. $2 .. \"]+\") do\n\t\tparts[#parts + 1] = part\n\tend\n\treturn parts\nend\n$0",
|
|
1123
|
+
"insertTextRules": 4,
|
|
1124
|
+
"sortText": "00_string_split"
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
"label": "string trim",
|
|
1128
|
+
"kind": 15,
|
|
1129
|
+
"detail": "Trim whitespace from string",
|
|
1130
|
+
"documentation": {
|
|
1131
|
+
"value": "Remove leading and trailing whitespace.\n\n```lua\nlocal function trim(s)\n return s:match(\"^%s*(.-)%s*$\")\nend\n```"
|
|
1132
|
+
},
|
|
1133
|
+
"insertText": "local function trim(${1:s})\n\treturn $1:match(\"^%%s*(.-)%%s*$\")\nend\n$0",
|
|
1134
|
+
"insertTextRules": 4,
|
|
1135
|
+
"sortText": "00_string_trim"
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
"label": "table keys",
|
|
1139
|
+
"kind": 15,
|
|
1140
|
+
"detail": "Get table keys",
|
|
1141
|
+
"documentation": {
|
|
1142
|
+
"value": "Collect all keys of a table into an array.\n\n```lua\nlocal function keys(t)\n local ks = {}\n for k in pairs(t) do ks[#ks + 1] = k end\n return ks\nend\n```"
|
|
1143
|
+
},
|
|
1144
|
+
"insertText": "local function keys(${1:t})\n\tlocal ks = {}\n\tfor k in pairs($1) do ks[#ks + 1] = k end\n\treturn ks\nend\n$0",
|
|
1145
|
+
"insertTextRules": 4,
|
|
1146
|
+
"sortText": "00_table_keys"
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
"label": "table values",
|
|
1150
|
+
"kind": 15,
|
|
1151
|
+
"detail": "Get table values",
|
|
1152
|
+
"documentation": {
|
|
1153
|
+
"value": "Collect all values of a table into an array.\n\n```lua\nlocal function values(t)\n local vs = {}\n for _, v in pairs(t) do vs[#vs + 1] = v end\n return vs\nend\n```"
|
|
1154
|
+
},
|
|
1155
|
+
"insertText": "local function values(${1:t})\n\tlocal vs = {}\n\tfor _, v in pairs($1) do vs[#vs + 1] = v end\n\treturn vs\nend\n$0",
|
|
1156
|
+
"insertTextRules": 4,
|
|
1157
|
+
"sortText": "00_table_values"
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
"label": "table contains",
|
|
1161
|
+
"kind": 15,
|
|
1162
|
+
"detail": "Check if table contains value",
|
|
1163
|
+
"documentation": {
|
|
1164
|
+
"value": "Check if an array-like table contains a value.\n\n```lua\nlocal function contains(t, value)\n for _, v in ipairs(t) do\n if v == value then return true end\n end\n return false\nend\n```"
|
|
1165
|
+
},
|
|
1166
|
+
"insertText": "local function contains(${1:t}, ${2:value})\n\tfor _, v in ipairs($1) do\n\t\tif v == $2 then return true end\n\tend\n\treturn false\nend\n$0",
|
|
1167
|
+
"insertTextRules": 4,
|
|
1168
|
+
"sortText": "00_table_contains"
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
"label": "readonly table",
|
|
1172
|
+
"kind": 15,
|
|
1173
|
+
"detail": "Read-only table proxy",
|
|
1174
|
+
"documentation": {
|
|
1175
|
+
"value": "Create a proxy table that prevents modification.\n\n```lua\nlocal function readonly(t)\n return setmetatable({}, {\n __index = t,\n __newindex = function() error(\"attempt to modify read-only table\", 2) end,\n })\nend\n```"
|
|
1176
|
+
},
|
|
1177
|
+
"insertText": "local function readonly(${1:t})\n\treturn setmetatable({}, {\n\t\t__index = $1,\n\t\t__newindex = function() error(\"attempt to modify read-only table\", 2) end,\n\t})\nend\n$0",
|
|
1178
|
+
"insertTextRules": 4,
|
|
1179
|
+
"sortText": "00_readonly_table"
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
"label": "weak table",
|
|
1183
|
+
"kind": 15,
|
|
1184
|
+
"detail": "Weak reference table",
|
|
1185
|
+
"documentation": {
|
|
1186
|
+
"value": "Create a table with weak references.\n\n```lua\nlocal cache = setmetatable({}, { __mode = \"v\" }) -- weak values\n```"
|
|
1187
|
+
},
|
|
1188
|
+
"insertText": "local ${1:cache} = setmetatable({}, { __mode = \"${2:v}\" })",
|
|
1189
|
+
"insertTextRules": 4,
|
|
1190
|
+
"sortText": "00_weak_table"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
"label": "class with constructor",
|
|
1194
|
+
"kind": 15,
|
|
1195
|
+
"detail": "Class with constructor and methods",
|
|
1196
|
+
"documentation": {
|
|
1197
|
+
"value": "Full OOP class pattern with new, init, and methods.\n\n```lua\nlocal MyClass = {}\nMyClass.__index = MyClass\n\nfunction MyClass.new(name, value)\n local self = setmetatable({}, MyClass)\n self.name = name\n self.value = value\n return self\nend\n\nfunction MyClass:getName()\n return self.name\nend\n```"
|
|
1198
|
+
},
|
|
1199
|
+
"insertText": "local ${1:MyClass} = {}\n$1.__index = $1\n\nfunction $1.new(${2:args})\n\tlocal self = setmetatable({}, $1)\n\t${3:self.field = args}\n\treturn self\nend\n\nfunction $1:${4:method}()\n\t$0\nend",
|
|
1200
|
+
"insertTextRules": 4,
|
|
1201
|
+
"sortText": "00_class_with_constructor"
|
|
1202
|
+
},
|
|
4
1203
|
{
|
|
5
1204
|
"label": "print",
|
|
6
1205
|
"kind": 1,
|
|
7
1206
|
"detail": "Print values to stdout",
|
|
8
|
-
"documentation": {
|
|
1207
|
+
"documentation": {
|
|
1208
|
+
"value": "Receives any number of arguments and prints their values to stdout, converting each with `tostring`.\n\n```lua\nprint(\"Hello, world!\")\nprint(\"x =\", x, \"y =\", y)\n```"
|
|
1209
|
+
},
|
|
9
1210
|
"insertText": "print(${1:value})",
|
|
10
1211
|
"insertTextRules": 4,
|
|
11
1212
|
"sortText": "00_print"
|
|
@@ -14,79 +1215,196 @@
|
|
|
14
1215
|
"label": "type",
|
|
15
1216
|
"kind": 1,
|
|
16
1217
|
"detail": "Return type of a value as a string",
|
|
17
|
-
"documentation": {
|
|
1218
|
+
"documentation": {
|
|
1219
|
+
"value": "Returns the type of its argument as a string. Possible results are `\"nil\"`, `\"number\"`, `\"string\"`, `\"boolean\"`, `\"table\"`, `\"function\"`, `\"thread\"`, and `\"userdata\"`.\n\n```lua\nprint(type(42)) -- \"number\"\nprint(type(\"hello\")) -- \"string\"\n```"
|
|
1220
|
+
},
|
|
18
1221
|
"insertText": "type(${1:v})",
|
|
19
1222
|
"insertTextRules": 4,
|
|
20
1223
|
"sortText": "00_type"
|
|
21
1224
|
},
|
|
22
1225
|
{
|
|
23
|
-
"label": "tostring",
|
|
1226
|
+
"label": "tostring",
|
|
1227
|
+
"kind": 1,
|
|
1228
|
+
"detail": "Convert a value to a string",
|
|
1229
|
+
"documentation": {
|
|
1230
|
+
"value": "Receives a value of any type and converts it to a string in a human-readable format. If the metatable has a `__tostring` metamethod, it is called.\n\n```lua\ntostring(123) -- \"123\"\ntostring(true) -- \"true\"\n```"
|
|
1231
|
+
},
|
|
1232
|
+
"insertText": "tostring(${1:v})",
|
|
1233
|
+
"insertTextRules": 4,
|
|
1234
|
+
"sortText": "00_tostring"
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"label": "tonumber",
|
|
1238
|
+
"kind": 1,
|
|
1239
|
+
"detail": "Convert a value to a number",
|
|
1240
|
+
"documentation": {
|
|
1241
|
+
"value": "Tries to convert its argument to a number. An optional base (2–36) for string interpretation.\n\n```lua\ntonumber(\"42\") -- 42\ntonumber(\"1010\", 2) -- 10\n```"
|
|
1242
|
+
},
|
|
1243
|
+
"insertText": "tonumber(${1:e}${2:, ${3:base}})",
|
|
1244
|
+
"insertTextRules": 4,
|
|
1245
|
+
"sortText": "00_tonumber"
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
"label": "pairs",
|
|
1249
|
+
"kind": 1,
|
|
1250
|
+
"detail": "Iterate over all key-value pairs",
|
|
1251
|
+
"documentation": {
|
|
1252
|
+
"value": "Returns an iterator function, the table, and `nil` for `for k, v in pairs(t) do ... end`.\n\n```lua\nfor k, v in pairs(myTable) do\n print(k, v)\nend\n```"
|
|
1253
|
+
},
|
|
1254
|
+
"insertText": "pairs(${1:t})",
|
|
1255
|
+
"insertTextRules": 4,
|
|
1256
|
+
"sortText": "00_pairs"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
"label": "ipairs",
|
|
1260
|
+
"kind": 1,
|
|
1261
|
+
"detail": "Iterate over integer-keyed elements",
|
|
1262
|
+
"documentation": {
|
|
1263
|
+
"value": "Returns an iterator for integer keys 1, 2, ... until a nil value.\n\n```lua\nfor i, v in ipairs(list) do\n print(i, v)\nend\n```"
|
|
1264
|
+
},
|
|
1265
|
+
"insertText": "ipairs(${1:t})",
|
|
1266
|
+
"insertTextRules": 4,
|
|
1267
|
+
"sortText": "00_ipairs"
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
"label": "next",
|
|
1271
|
+
"kind": 1,
|
|
1272
|
+
"detail": "Traverse table fields",
|
|
1273
|
+
"documentation": {
|
|
1274
|
+
"value": "Returns the next index and value. When called with nil, returns an initial index.\n\n```lua\nlocal k, v = next(t)\n```"
|
|
1275
|
+
},
|
|
1276
|
+
"insertText": "next(${1:table}${2:, ${3:index}})",
|
|
1277
|
+
"insertTextRules": 4,
|
|
1278
|
+
"sortText": "00_next"
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
"label": "select",
|
|
1282
|
+
"kind": 1,
|
|
1283
|
+
"detail": "Select arguments by position",
|
|
1284
|
+
"documentation": {
|
|
1285
|
+
"value": "If index is a number, returns all arguments after that index. If `\"#\"`, returns the count.\n\n```lua\nselect(2, \"a\", \"b\", \"c\") -- \"b\", \"c\"\nselect(\"#\", \"a\", \"b\") -- 2\n```"
|
|
1286
|
+
},
|
|
1287
|
+
"insertText": "select(${1:index}, ${2:...})",
|
|
1288
|
+
"insertTextRules": 4,
|
|
1289
|
+
"sortText": "00_select"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
"label": "rawget",
|
|
1293
|
+
"kind": 1,
|
|
1294
|
+
"detail": "Get table value without __index",
|
|
1295
|
+
"documentation": {
|
|
1296
|
+
"value": "Gets `table[index]` without invoking the `__index` metamethod.\n\n```lua\nrawget(t, \"key\")\n```"
|
|
1297
|
+
},
|
|
1298
|
+
"insertText": "rawget(${1:table}, ${2:index})",
|
|
1299
|
+
"insertTextRules": 4,
|
|
1300
|
+
"sortText": "00_rawget"
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
"label": "rawset",
|
|
1304
|
+
"kind": 1,
|
|
1305
|
+
"detail": "Set table value without __newindex",
|
|
1306
|
+
"documentation": {
|
|
1307
|
+
"value": "Sets `table[index] = value` without invoking the `__newindex` metamethod.\n\n```lua\nrawset(t, \"key\", value)\n```"
|
|
1308
|
+
},
|
|
1309
|
+
"insertText": "rawset(${1:table}, ${2:index}, ${3:value})",
|
|
1310
|
+
"insertTextRules": 4,
|
|
1311
|
+
"sortText": "00_rawset"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
"label": "rawequal",
|
|
1315
|
+
"kind": 1,
|
|
1316
|
+
"detail": "Equality without __eq",
|
|
1317
|
+
"documentation": {
|
|
1318
|
+
"value": "Checks whether v1 is equal to v2 without invoking the `__eq` metamethod.\n\n```lua\nrawequal(a, b)\n```"
|
|
1319
|
+
},
|
|
1320
|
+
"insertText": "rawequal(${1:v1}, ${2:v2})",
|
|
1321
|
+
"insertTextRules": 4,
|
|
1322
|
+
"sortText": "00_rawequal"
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
"label": "rawlen",
|
|
24
1326
|
"kind": 1,
|
|
25
|
-
"detail": "
|
|
26
|
-
"documentation": {
|
|
27
|
-
|
|
1327
|
+
"detail": "Length without __len (5.2+)",
|
|
1328
|
+
"documentation": {
|
|
1329
|
+
"value": "Returns the length of table or string without invoking the `__len` metamethod.\n\n```lua\nrawlen(t)\n```"
|
|
1330
|
+
},
|
|
1331
|
+
"insertText": "rawlen(${1:v})",
|
|
28
1332
|
"insertTextRules": 4,
|
|
29
|
-
"sortText": "
|
|
1333
|
+
"sortText": "00_rawlen"
|
|
30
1334
|
},
|
|
31
1335
|
{
|
|
32
|
-
"label": "
|
|
1336
|
+
"label": "setmetatable",
|
|
33
1337
|
"kind": 1,
|
|
34
|
-
"detail": "
|
|
35
|
-
"documentation": {
|
|
36
|
-
|
|
1338
|
+
"detail": "Set metatable for a table",
|
|
1339
|
+
"documentation": {
|
|
1340
|
+
"value": "Sets the metatable for the given table. If metatable is nil, removes it.\n\n```lua\nsetmetatable(obj, { __index = proto })\n```"
|
|
1341
|
+
},
|
|
1342
|
+
"insertText": "setmetatable(${1:table}, ${2:metatable})",
|
|
37
1343
|
"insertTextRules": 4,
|
|
38
|
-
"sortText": "
|
|
1344
|
+
"sortText": "00_setmetatable"
|
|
39
1345
|
},
|
|
40
1346
|
{
|
|
41
|
-
"label": "
|
|
1347
|
+
"label": "getmetatable",
|
|
42
1348
|
"kind": 1,
|
|
43
|
-
"detail": "
|
|
44
|
-
"documentation": {
|
|
45
|
-
|
|
1349
|
+
"detail": "Get metatable of an object",
|
|
1350
|
+
"documentation": {
|
|
1351
|
+
"value": "Returns the metatable of the object, or nil if none. If __metatable is set, returns that value.\n\n```lua\nlocal mt = getmetatable(obj)\n```"
|
|
1352
|
+
},
|
|
1353
|
+
"insertText": "getmetatable(${1:object})",
|
|
46
1354
|
"insertTextRules": 4,
|
|
47
|
-
"sortText": "
|
|
1355
|
+
"sortText": "00_getmetatable"
|
|
48
1356
|
},
|
|
49
1357
|
{
|
|
50
|
-
"label": "
|
|
1358
|
+
"label": "require",
|
|
51
1359
|
"kind": 1,
|
|
52
|
-
"detail": "
|
|
53
|
-
"documentation": {
|
|
54
|
-
|
|
1360
|
+
"detail": "Load and cache a module",
|
|
1361
|
+
"documentation": {
|
|
1362
|
+
"value": "Loads the given module. Checks `package.loaded` first, then uses `package.searchers`.\n\n```lua\nlocal json = require(\"dkjson\")\n```"
|
|
1363
|
+
},
|
|
1364
|
+
"insertText": "require(\"${1:modname}\")",
|
|
55
1365
|
"insertTextRules": 4,
|
|
56
|
-
"sortText": "
|
|
1366
|
+
"sortText": "00_require"
|
|
57
1367
|
},
|
|
58
1368
|
{
|
|
59
|
-
"label": "
|
|
1369
|
+
"label": "dofile",
|
|
60
1370
|
"kind": 1,
|
|
61
|
-
"detail": "
|
|
62
|
-
"documentation": {
|
|
63
|
-
|
|
1371
|
+
"detail": "Execute a Lua file",
|
|
1372
|
+
"documentation": {
|
|
1373
|
+
"value": "Opens the named file and executes its contents as a Lua chunk. Returns any values returned by the chunk.\n\n```lua\ndofile(\"config.lua\")\n```"
|
|
1374
|
+
},
|
|
1375
|
+
"insertText": "dofile(\"${1:filename}\")",
|
|
64
1376
|
"insertTextRules": 4,
|
|
65
|
-
"sortText": "
|
|
1377
|
+
"sortText": "00_dofile"
|
|
66
1378
|
},
|
|
67
1379
|
{
|
|
68
|
-
"label": "
|
|
1380
|
+
"label": "loadfile",
|
|
69
1381
|
"kind": 1,
|
|
70
|
-
"detail": "
|
|
71
|
-
"documentation": {
|
|
72
|
-
|
|
1382
|
+
"detail": "Load a Lua file without executing",
|
|
1383
|
+
"documentation": {
|
|
1384
|
+
"value": "Loads a file as a Lua chunk without executing it. Returns the chunk as a function.\n\n```lua\nlocal fn = loadfile(\"script.lua\")\n```"
|
|
1385
|
+
},
|
|
1386
|
+
"insertText": "loadfile(\"${1:filename}\"${2:, ${3:mode}${4:, ${5:env}}})",
|
|
73
1387
|
"insertTextRules": 4,
|
|
74
|
-
"sortText": "
|
|
1388
|
+
"sortText": "00_loadfile"
|
|
75
1389
|
},
|
|
76
1390
|
{
|
|
77
|
-
"label": "
|
|
1391
|
+
"label": "load",
|
|
78
1392
|
"kind": 1,
|
|
79
|
-
"detail": "
|
|
80
|
-
"documentation": {
|
|
81
|
-
|
|
1393
|
+
"detail": "Load a chunk from string or function",
|
|
1394
|
+
"documentation": {
|
|
1395
|
+
"value": "Loads a chunk. If chunk is a string, loads it. If a function, calls it to get pieces.\n\n```lua\nlocal fn = load(\"return 42\")\nprint(fn()) -- 42\n```"
|
|
1396
|
+
},
|
|
1397
|
+
"insertText": "load(${1:chunk}${2:, ${3:chunkname}${4:, ${5:mode}${6:, ${7:env}}}})",
|
|
82
1398
|
"insertTextRules": 4,
|
|
83
|
-
"sortText": "
|
|
1399
|
+
"sortText": "00_load"
|
|
84
1400
|
},
|
|
85
1401
|
{
|
|
86
1402
|
"label": "pcall",
|
|
87
1403
|
"kind": 1,
|
|
88
|
-
"detail": "Protected call
|
|
89
|
-
"documentation": {
|
|
1404
|
+
"detail": "Protected call",
|
|
1405
|
+
"documentation": {
|
|
1406
|
+
"value": "Calls function f in protected mode. Returns true + results on success, false + error on failure.\n\n```lua\nlocal ok, result = pcall(myFunc, arg1)\n```"
|
|
1407
|
+
},
|
|
90
1408
|
"insertText": "pcall(${1:f}${2:, ${3:args}})",
|
|
91
1409
|
"insertTextRules": 4,
|
|
92
1410
|
"sortText": "00_pcall"
|
|
@@ -94,8 +1412,10 @@
|
|
|
94
1412
|
{
|
|
95
1413
|
"label": "xpcall",
|
|
96
1414
|
"kind": 1,
|
|
97
|
-
"detail": "
|
|
98
|
-
"documentation": {
|
|
1415
|
+
"detail": "Extended protected call",
|
|
1416
|
+
"documentation": {
|
|
1417
|
+
"value": "Like pcall but sets an error handler function.\n\n```lua\nlocal ok, result = xpcall(myFunc, debug.traceback, arg1)\n```"
|
|
1418
|
+
},
|
|
99
1419
|
"insertText": "xpcall(${1:f}, ${2:msgh}${3:, ${4:args}})",
|
|
100
1420
|
"insertTextRules": 4,
|
|
101
1421
|
"sortText": "00_xpcall"
|
|
@@ -104,7 +1424,9 @@
|
|
|
104
1424
|
"label": "error",
|
|
105
1425
|
"kind": 1,
|
|
106
1426
|
"detail": "Raise an error",
|
|
107
|
-
"documentation": {
|
|
1427
|
+
"documentation": {
|
|
1428
|
+
"value": "Terminates the last protected call with the given message. Level controls error position.\n\n```lua\nerror(\"invalid input\", 2)\n```"
|
|
1429
|
+
},
|
|
108
1430
|
"insertText": "error(${1:message}${2:, ${3:level}})",
|
|
109
1431
|
"insertTextRules": 4,
|
|
110
1432
|
"sortText": "00_error"
|
|
@@ -112,857 +1434,1201 @@
|
|
|
112
1434
|
{
|
|
113
1435
|
"label": "assert",
|
|
114
1436
|
"kind": 1,
|
|
115
|
-
"detail": "Assert a condition
|
|
116
|
-
"documentation": {
|
|
1437
|
+
"detail": "Assert a condition",
|
|
1438
|
+
"documentation": {
|
|
1439
|
+
"value": "Raises error if value is false/nil, otherwise returns all arguments.\n\n```lua\nassert(x > 0, \"x must be positive\")\n```"
|
|
1440
|
+
},
|
|
117
1441
|
"insertText": "assert(${1:v}${2:, ${3:message}})",
|
|
118
1442
|
"insertTextRules": 4,
|
|
119
1443
|
"sortText": "00_assert"
|
|
120
1444
|
},
|
|
121
1445
|
{
|
|
122
|
-
"label": "
|
|
1446
|
+
"label": "collectgarbage",
|
|
123
1447
|
"kind": 1,
|
|
124
|
-
"detail": "
|
|
125
|
-
"documentation": {
|
|
126
|
-
|
|
1448
|
+
"detail": "Control garbage collector",
|
|
1449
|
+
"documentation": {
|
|
1450
|
+
"value": "Generic interface to the GC. Options: \"collect\", \"stop\", \"restart\", \"count\", \"step\", etc.\n\n```lua\ncollectgarbage(\"collect\")\n```"
|
|
1451
|
+
},
|
|
1452
|
+
"insertText": "collectgarbage(\"${1:opt}\"${2:, ${3:arg}})",
|
|
127
1453
|
"insertTextRules": 4,
|
|
128
|
-
"sortText": "
|
|
1454
|
+
"sortText": "00_collectgarbage"
|
|
129
1455
|
},
|
|
130
1456
|
{
|
|
131
|
-
"label": "
|
|
1457
|
+
"label": "unpack",
|
|
132
1458
|
"kind": 1,
|
|
133
|
-
"detail": "
|
|
134
|
-
"documentation": {
|
|
135
|
-
|
|
1459
|
+
"detail": "Unpack table elements (5.1)",
|
|
1460
|
+
"documentation": {
|
|
1461
|
+
"value": "Returns elements from the given table. In Lua 5.2+ use `table.unpack`.\n\n```lua\nlocal a, b, c = unpack({1, 2, 3})\n```"
|
|
1462
|
+
},
|
|
1463
|
+
"insertText": "unpack(${1:list}${2:, ${3:i}${4:, ${5:j}}})",
|
|
136
1464
|
"insertTextRules": 4,
|
|
137
|
-
"sortText": "
|
|
1465
|
+
"sortText": "00_unpack"
|
|
138
1466
|
},
|
|
139
1467
|
{
|
|
140
|
-
"label": "
|
|
141
|
-
"kind":
|
|
142
|
-
"detail": "
|
|
143
|
-
"documentation": {
|
|
144
|
-
|
|
1468
|
+
"label": "and",
|
|
1469
|
+
"kind": 14,
|
|
1470
|
+
"detail": "keyword and",
|
|
1471
|
+
"documentation": {
|
|
1472
|
+
"value": "Lua keyword `and`."
|
|
1473
|
+
},
|
|
1474
|
+
"insertText": "and",
|
|
145
1475
|
"insertTextRules": 4,
|
|
146
|
-
"sortText": "
|
|
1476
|
+
"sortText": "00_kw_and"
|
|
147
1477
|
},
|
|
148
1478
|
{
|
|
149
|
-
"label": "
|
|
150
|
-
"kind":
|
|
151
|
-
"detail": "
|
|
152
|
-
"documentation": {
|
|
153
|
-
|
|
1479
|
+
"label": "break",
|
|
1480
|
+
"kind": 14,
|
|
1481
|
+
"detail": "keyword break",
|
|
1482
|
+
"documentation": {
|
|
1483
|
+
"value": "Lua keyword `break`."
|
|
1484
|
+
},
|
|
1485
|
+
"insertText": "break",
|
|
154
1486
|
"insertTextRules": 4,
|
|
155
|
-
"sortText": "
|
|
1487
|
+
"sortText": "00_kw_break"
|
|
156
1488
|
},
|
|
157
1489
|
{
|
|
158
|
-
"label": "
|
|
159
|
-
"kind":
|
|
160
|
-
"detail": "
|
|
161
|
-
"documentation": {
|
|
162
|
-
|
|
1490
|
+
"label": "do",
|
|
1491
|
+
"kind": 14,
|
|
1492
|
+
"detail": "keyword do",
|
|
1493
|
+
"documentation": {
|
|
1494
|
+
"value": "Lua keyword `do`."
|
|
1495
|
+
},
|
|
1496
|
+
"insertText": "do",
|
|
163
1497
|
"insertTextRules": 4,
|
|
164
|
-
"sortText": "
|
|
1498
|
+
"sortText": "00_kw_do"
|
|
165
1499
|
},
|
|
166
1500
|
{
|
|
167
|
-
"label": "
|
|
168
|
-
"kind":
|
|
169
|
-
"detail": "
|
|
170
|
-
"documentation": {
|
|
171
|
-
|
|
1501
|
+
"label": "else",
|
|
1502
|
+
"kind": 14,
|
|
1503
|
+
"detail": "keyword else",
|
|
1504
|
+
"documentation": {
|
|
1505
|
+
"value": "Lua keyword `else`."
|
|
1506
|
+
},
|
|
1507
|
+
"insertText": "else",
|
|
172
1508
|
"insertTextRules": 4,
|
|
173
|
-
"sortText": "
|
|
1509
|
+
"sortText": "00_kw_else"
|
|
174
1510
|
},
|
|
175
1511
|
{
|
|
176
|
-
"label": "
|
|
177
|
-
"kind":
|
|
178
|
-
"detail": "
|
|
179
|
-
"documentation": {
|
|
180
|
-
|
|
1512
|
+
"label": "elseif",
|
|
1513
|
+
"kind": 14,
|
|
1514
|
+
"detail": "keyword elseif",
|
|
1515
|
+
"documentation": {
|
|
1516
|
+
"value": "Lua keyword `elseif`."
|
|
1517
|
+
},
|
|
1518
|
+
"insertText": "elseif",
|
|
181
1519
|
"insertTextRules": 4,
|
|
182
|
-
"sortText": "
|
|
1520
|
+
"sortText": "00_kw_elseif"
|
|
183
1521
|
},
|
|
184
1522
|
{
|
|
185
|
-
"label": "
|
|
186
|
-
"kind":
|
|
187
|
-
"detail": "
|
|
188
|
-
"documentation": {
|
|
189
|
-
|
|
1523
|
+
"label": "end",
|
|
1524
|
+
"kind": 14,
|
|
1525
|
+
"detail": "keyword end",
|
|
1526
|
+
"documentation": {
|
|
1527
|
+
"value": "Lua keyword `end`."
|
|
1528
|
+
},
|
|
1529
|
+
"insertText": "end",
|
|
190
1530
|
"insertTextRules": 4,
|
|
191
|
-
"sortText": "
|
|
1531
|
+
"sortText": "00_kw_end"
|
|
192
1532
|
},
|
|
193
1533
|
{
|
|
194
|
-
"label": "
|
|
195
|
-
"kind":
|
|
196
|
-
"detail": "
|
|
197
|
-
"documentation": {
|
|
198
|
-
|
|
1534
|
+
"label": "false",
|
|
1535
|
+
"kind": 14,
|
|
1536
|
+
"detail": "keyword false",
|
|
1537
|
+
"documentation": {
|
|
1538
|
+
"value": "Lua keyword `false`."
|
|
1539
|
+
},
|
|
1540
|
+
"insertText": "false",
|
|
199
1541
|
"insertTextRules": 4,
|
|
200
|
-
"sortText": "
|
|
1542
|
+
"sortText": "00_kw_false"
|
|
201
1543
|
},
|
|
202
1544
|
{
|
|
203
|
-
"label": "
|
|
204
|
-
"kind":
|
|
205
|
-
"detail": "
|
|
206
|
-
"documentation": {
|
|
207
|
-
|
|
1545
|
+
"label": "for",
|
|
1546
|
+
"kind": 14,
|
|
1547
|
+
"detail": "keyword for",
|
|
1548
|
+
"documentation": {
|
|
1549
|
+
"value": "Lua keyword `for`."
|
|
1550
|
+
},
|
|
1551
|
+
"insertText": "for",
|
|
208
1552
|
"insertTextRules": 4,
|
|
209
|
-
"sortText": "
|
|
1553
|
+
"sortText": "00_kw_for"
|
|
210
1554
|
},
|
|
211
1555
|
{
|
|
212
|
-
"label": "
|
|
213
|
-
"kind":
|
|
214
|
-
"detail": "
|
|
215
|
-
"documentation": {
|
|
216
|
-
|
|
1556
|
+
"label": "function",
|
|
1557
|
+
"kind": 14,
|
|
1558
|
+
"detail": "keyword function",
|
|
1559
|
+
"documentation": {
|
|
1560
|
+
"value": "Lua keyword `function`."
|
|
1561
|
+
},
|
|
1562
|
+
"insertText": "function",
|
|
217
1563
|
"insertTextRules": 4,
|
|
218
|
-
"sortText": "
|
|
1564
|
+
"sortText": "00_kw_function"
|
|
219
1565
|
},
|
|
220
1566
|
{
|
|
221
|
-
"label": "
|
|
222
|
-
"kind":
|
|
223
|
-
"detail": "
|
|
224
|
-
"documentation": {
|
|
225
|
-
|
|
1567
|
+
"label": "goto",
|
|
1568
|
+
"kind": 14,
|
|
1569
|
+
"detail": "keyword goto",
|
|
1570
|
+
"documentation": {
|
|
1571
|
+
"value": "Lua keyword `goto`."
|
|
1572
|
+
},
|
|
1573
|
+
"insertText": "goto",
|
|
226
1574
|
"insertTextRules": 4,
|
|
227
|
-
"sortText": "
|
|
1575
|
+
"sortText": "00_kw_goto"
|
|
228
1576
|
},
|
|
229
1577
|
{
|
|
230
|
-
"label": "
|
|
231
|
-
"kind":
|
|
232
|
-
"detail": "
|
|
233
|
-
"documentation": {
|
|
234
|
-
|
|
1578
|
+
"label": "if",
|
|
1579
|
+
"kind": 14,
|
|
1580
|
+
"detail": "keyword if",
|
|
1581
|
+
"documentation": {
|
|
1582
|
+
"value": "Lua keyword `if`."
|
|
1583
|
+
},
|
|
1584
|
+
"insertText": "if",
|
|
235
1585
|
"insertTextRules": 4,
|
|
236
|
-
"sortText": "
|
|
1586
|
+
"sortText": "00_kw_if"
|
|
237
1587
|
},
|
|
238
1588
|
{
|
|
239
|
-
"label": "
|
|
240
|
-
"kind":
|
|
241
|
-
"detail": "
|
|
242
|
-
"documentation": {
|
|
243
|
-
|
|
1589
|
+
"label": "in",
|
|
1590
|
+
"kind": 14,
|
|
1591
|
+
"detail": "keyword in",
|
|
1592
|
+
"documentation": {
|
|
1593
|
+
"value": "Lua keyword `in`."
|
|
1594
|
+
},
|
|
1595
|
+
"insertText": "in",
|
|
244
1596
|
"insertTextRules": 4,
|
|
245
|
-
"sortText": "
|
|
1597
|
+
"sortText": "00_kw_in"
|
|
246
1598
|
},
|
|
247
1599
|
{
|
|
248
|
-
"label": "
|
|
249
|
-
"kind":
|
|
250
|
-
"detail": "
|
|
251
|
-
"documentation": {
|
|
252
|
-
|
|
1600
|
+
"label": "local",
|
|
1601
|
+
"kind": 14,
|
|
1602
|
+
"detail": "keyword local",
|
|
1603
|
+
"documentation": {
|
|
1604
|
+
"value": "Lua keyword `local`."
|
|
1605
|
+
},
|
|
1606
|
+
"insertText": "local",
|
|
253
1607
|
"insertTextRules": 4,
|
|
254
|
-
"sortText": "
|
|
1608
|
+
"sortText": "00_kw_local"
|
|
255
1609
|
},
|
|
256
1610
|
{
|
|
257
|
-
"label": "
|
|
258
|
-
"kind":
|
|
259
|
-
"detail": "
|
|
260
|
-
"documentation": {
|
|
261
|
-
|
|
1611
|
+
"label": "nil",
|
|
1612
|
+
"kind": 14,
|
|
1613
|
+
"detail": "keyword nil",
|
|
1614
|
+
"documentation": {
|
|
1615
|
+
"value": "Lua keyword `nil`."
|
|
1616
|
+
},
|
|
1617
|
+
"insertText": "nil",
|
|
262
1618
|
"insertTextRules": 4,
|
|
263
|
-
"sortText": "
|
|
1619
|
+
"sortText": "00_kw_nil"
|
|
264
1620
|
},
|
|
265
1621
|
{
|
|
266
|
-
"label": "
|
|
267
|
-
"kind":
|
|
268
|
-
"detail": "
|
|
269
|
-
"documentation": {
|
|
270
|
-
|
|
1622
|
+
"label": "not",
|
|
1623
|
+
"kind": 14,
|
|
1624
|
+
"detail": "keyword not",
|
|
1625
|
+
"documentation": {
|
|
1626
|
+
"value": "Lua keyword `not`."
|
|
1627
|
+
},
|
|
1628
|
+
"insertText": "not",
|
|
271
1629
|
"insertTextRules": 4,
|
|
272
|
-
"sortText": "
|
|
1630
|
+
"sortText": "00_kw_not"
|
|
273
1631
|
},
|
|
274
1632
|
{
|
|
275
|
-
"label": "
|
|
276
|
-
"kind":
|
|
277
|
-
"detail": "
|
|
278
|
-
"documentation": {
|
|
279
|
-
|
|
1633
|
+
"label": "or",
|
|
1634
|
+
"kind": 14,
|
|
1635
|
+
"detail": "keyword or",
|
|
1636
|
+
"documentation": {
|
|
1637
|
+
"value": "Lua keyword `or`."
|
|
1638
|
+
},
|
|
1639
|
+
"insertText": "or",
|
|
280
1640
|
"insertTextRules": 4,
|
|
281
|
-
"sortText": "
|
|
1641
|
+
"sortText": "00_kw_or"
|
|
282
1642
|
},
|
|
283
1643
|
{
|
|
284
|
-
"label": "
|
|
285
|
-
"kind":
|
|
286
|
-
"detail": "
|
|
287
|
-
"documentation": {
|
|
288
|
-
|
|
1644
|
+
"label": "repeat",
|
|
1645
|
+
"kind": 14,
|
|
1646
|
+
"detail": "keyword repeat",
|
|
1647
|
+
"documentation": {
|
|
1648
|
+
"value": "Lua keyword `repeat`."
|
|
1649
|
+
},
|
|
1650
|
+
"insertText": "repeat",
|
|
289
1651
|
"insertTextRules": 4,
|
|
290
|
-
"sortText": "
|
|
1652
|
+
"sortText": "00_kw_repeat"
|
|
291
1653
|
},
|
|
292
1654
|
{
|
|
293
|
-
"label": "
|
|
294
|
-
"kind":
|
|
295
|
-
"detail": "
|
|
296
|
-
"documentation": {
|
|
297
|
-
|
|
1655
|
+
"label": "return",
|
|
1656
|
+
"kind": 14,
|
|
1657
|
+
"detail": "keyword return",
|
|
1658
|
+
"documentation": {
|
|
1659
|
+
"value": "Lua keyword `return`."
|
|
1660
|
+
},
|
|
1661
|
+
"insertText": "return",
|
|
298
1662
|
"insertTextRules": 4,
|
|
299
|
-
"sortText": "
|
|
1663
|
+
"sortText": "00_kw_return"
|
|
300
1664
|
},
|
|
301
1665
|
{
|
|
302
|
-
"label": "
|
|
303
|
-
"kind":
|
|
304
|
-
"detail": "
|
|
305
|
-
"documentation": {
|
|
306
|
-
|
|
1666
|
+
"label": "then",
|
|
1667
|
+
"kind": 14,
|
|
1668
|
+
"detail": "keyword then",
|
|
1669
|
+
"documentation": {
|
|
1670
|
+
"value": "Lua keyword `then`."
|
|
1671
|
+
},
|
|
1672
|
+
"insertText": "then",
|
|
307
1673
|
"insertTextRules": 4,
|
|
308
|
-
"sortText": "
|
|
1674
|
+
"sortText": "00_kw_then"
|
|
309
1675
|
},
|
|
310
1676
|
{
|
|
311
|
-
"label": "
|
|
312
|
-
"kind":
|
|
313
|
-
"detail": "
|
|
314
|
-
"documentation": {
|
|
315
|
-
|
|
1677
|
+
"label": "true",
|
|
1678
|
+
"kind": 14,
|
|
1679
|
+
"detail": "keyword true",
|
|
1680
|
+
"documentation": {
|
|
1681
|
+
"value": "Lua keyword `true`."
|
|
1682
|
+
},
|
|
1683
|
+
"insertText": "true",
|
|
316
1684
|
"insertTextRules": 4,
|
|
317
|
-
"sortText": "
|
|
1685
|
+
"sortText": "00_kw_true"
|
|
318
1686
|
},
|
|
319
1687
|
{
|
|
320
|
-
"label": "
|
|
321
|
-
"kind":
|
|
322
|
-
"detail": "
|
|
323
|
-
"documentation": {
|
|
324
|
-
|
|
1688
|
+
"label": "until",
|
|
1689
|
+
"kind": 14,
|
|
1690
|
+
"detail": "keyword until",
|
|
1691
|
+
"documentation": {
|
|
1692
|
+
"value": "Lua keyword `until`."
|
|
1693
|
+
},
|
|
1694
|
+
"insertText": "until",
|
|
325
1695
|
"insertTextRules": 4,
|
|
326
|
-
"sortText": "
|
|
1696
|
+
"sortText": "00_kw_until"
|
|
327
1697
|
},
|
|
328
1698
|
{
|
|
329
|
-
"label": "
|
|
330
|
-
"kind":
|
|
331
|
-
"detail": "
|
|
332
|
-
"documentation": {
|
|
333
|
-
|
|
1699
|
+
"label": "while",
|
|
1700
|
+
"kind": 14,
|
|
1701
|
+
"detail": "keyword while",
|
|
1702
|
+
"documentation": {
|
|
1703
|
+
"value": "Lua keyword `while`."
|
|
1704
|
+
},
|
|
1705
|
+
"insertText": "while",
|
|
334
1706
|
"insertTextRules": 4,
|
|
335
|
-
"sortText": "
|
|
1707
|
+
"sortText": "00_kw_while"
|
|
336
1708
|
},
|
|
337
1709
|
{
|
|
338
|
-
"label": "string
|
|
1710
|
+
"label": "string",
|
|
1711
|
+
"kind": 9,
|
|
1712
|
+
"detail": "string library",
|
|
1713
|
+
"documentation": {
|
|
1714
|
+
"value": "The Lua `string` standard library module."
|
|
1715
|
+
},
|
|
1716
|
+
"insertText": "string",
|
|
1717
|
+
"insertTextRules": 4,
|
|
1718
|
+
"sortText": "01_string"
|
|
1719
|
+
},
|
|
1720
|
+
{
|
|
1721
|
+
"label": "table",
|
|
1722
|
+
"kind": 9,
|
|
1723
|
+
"detail": "table library",
|
|
1724
|
+
"documentation": {
|
|
1725
|
+
"value": "The Lua `table` standard library module."
|
|
1726
|
+
},
|
|
1727
|
+
"insertText": "table",
|
|
1728
|
+
"insertTextRules": 4,
|
|
1729
|
+
"sortText": "01_table"
|
|
1730
|
+
},
|
|
1731
|
+
{
|
|
1732
|
+
"label": "math",
|
|
1733
|
+
"kind": 9,
|
|
1734
|
+
"detail": "math library",
|
|
1735
|
+
"documentation": {
|
|
1736
|
+
"value": "The Lua `math` standard library module."
|
|
1737
|
+
},
|
|
1738
|
+
"insertText": "math",
|
|
1739
|
+
"insertTextRules": 4,
|
|
1740
|
+
"sortText": "01_math"
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
"label": "io",
|
|
1744
|
+
"kind": 9,
|
|
1745
|
+
"detail": "io library",
|
|
1746
|
+
"documentation": {
|
|
1747
|
+
"value": "The Lua `io` standard library module."
|
|
1748
|
+
},
|
|
1749
|
+
"insertText": "io",
|
|
1750
|
+
"insertTextRules": 4,
|
|
1751
|
+
"sortText": "01_io"
|
|
1752
|
+
},
|
|
1753
|
+
{
|
|
1754
|
+
"label": "os",
|
|
1755
|
+
"kind": 9,
|
|
1756
|
+
"detail": "os library",
|
|
1757
|
+
"documentation": {
|
|
1758
|
+
"value": "The Lua `os` standard library module."
|
|
1759
|
+
},
|
|
1760
|
+
"insertText": "os",
|
|
1761
|
+
"insertTextRules": 4,
|
|
1762
|
+
"sortText": "01_os"
|
|
1763
|
+
},
|
|
1764
|
+
{
|
|
1765
|
+
"label": "coroutine",
|
|
1766
|
+
"kind": 9,
|
|
1767
|
+
"detail": "coroutine library",
|
|
1768
|
+
"documentation": {
|
|
1769
|
+
"value": "The Lua `coroutine` standard library module."
|
|
1770
|
+
},
|
|
1771
|
+
"insertText": "coroutine",
|
|
1772
|
+
"insertTextRules": 4,
|
|
1773
|
+
"sortText": "01_coroutine"
|
|
1774
|
+
},
|
|
1775
|
+
{
|
|
1776
|
+
"label": "debug",
|
|
1777
|
+
"kind": 9,
|
|
1778
|
+
"detail": "debug library",
|
|
1779
|
+
"documentation": {
|
|
1780
|
+
"value": "The Lua `debug` standard library module."
|
|
1781
|
+
},
|
|
1782
|
+
"insertText": "debug",
|
|
1783
|
+
"insertTextRules": 4,
|
|
1784
|
+
"sortText": "01_debug"
|
|
1785
|
+
},
|
|
1786
|
+
{
|
|
1787
|
+
"label": "package",
|
|
1788
|
+
"kind": 9,
|
|
1789
|
+
"detail": "package library",
|
|
1790
|
+
"documentation": {
|
|
1791
|
+
"value": "The Lua `package` standard library module."
|
|
1792
|
+
},
|
|
1793
|
+
"insertText": "package",
|
|
1794
|
+
"insertTextRules": 4,
|
|
1795
|
+
"sortText": "01_package"
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
"label": "utf8",
|
|
1799
|
+
"kind": 9,
|
|
1800
|
+
"detail": "utf8 library",
|
|
1801
|
+
"documentation": {
|
|
1802
|
+
"value": "The Lua `utf8` standard library module."
|
|
1803
|
+
},
|
|
1804
|
+
"insertText": "utf8",
|
|
1805
|
+
"insertTextRules": 4,
|
|
1806
|
+
"sortText": "01_utf8"
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
"label": "warn",
|
|
339
1810
|
"kind": 1,
|
|
340
|
-
"detail": "
|
|
341
|
-
"documentation": {
|
|
342
|
-
|
|
1811
|
+
"detail": "Issue a warning message (Lua 5.4+)",
|
|
1812
|
+
"documentation": {
|
|
1813
|
+
"value": "Issue a warning message.\n\n```lua\nwarn(\"something suspicious\")\nwarn(\"@on\") -- enable warnings\nwarn(\"@off\") -- disable warnings\n```"
|
|
1814
|
+
},
|
|
1815
|
+
"insertText": "warn(${1:msg})",
|
|
1816
|
+
"insertTextRules": 4,
|
|
1817
|
+
"sortText": "01_warn"
|
|
1818
|
+
},
|
|
1819
|
+
{
|
|
1820
|
+
"label": "metatable __sub",
|
|
1821
|
+
"kind": 15,
|
|
1822
|
+
"detail": "Subtraction metamethod",
|
|
1823
|
+
"documentation": {
|
|
1824
|
+
"value": "Subtraction metamethod.\n\n```lua\nmetatable.__sub = function(a, b)\n\treturn a - b\nend\n```"
|
|
1825
|
+
},
|
|
1826
|
+
"insertText": "metatable.__sub = function(a, b)\n\t${0:return a - b}\nend",
|
|
1827
|
+
"insertTextRules": 4,
|
|
1828
|
+
"sortText": "04_metatable___sub"
|
|
1829
|
+
},
|
|
1830
|
+
{
|
|
1831
|
+
"label": "metatable __mul",
|
|
1832
|
+
"kind": 15,
|
|
1833
|
+
"detail": "Multiplication metamethod",
|
|
1834
|
+
"documentation": {
|
|
1835
|
+
"value": "Multiplication metamethod.\n\n```lua\nmetatable.__mul = function(a, b)\n\treturn a * b\nend\n```"
|
|
1836
|
+
},
|
|
1837
|
+
"insertText": "metatable.__mul = function(a, b)\n\t${0:return a * b}\nend",
|
|
1838
|
+
"insertTextRules": 4,
|
|
1839
|
+
"sortText": "04_metatable___mul"
|
|
1840
|
+
},
|
|
1841
|
+
{
|
|
1842
|
+
"label": "metatable __div",
|
|
1843
|
+
"kind": 15,
|
|
1844
|
+
"detail": "Division metamethod",
|
|
1845
|
+
"documentation": {
|
|
1846
|
+
"value": "Division metamethod.\n\n```lua\nmetatable.__div = function(a, b)\n\treturn a / b\nend\n```"
|
|
1847
|
+
},
|
|
1848
|
+
"insertText": "metatable.__div = function(a, b)\n\t${0:return a / b}\nend",
|
|
1849
|
+
"insertTextRules": 4,
|
|
1850
|
+
"sortText": "04_metatable___div"
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
"label": "metatable __mod",
|
|
1854
|
+
"kind": 15,
|
|
1855
|
+
"detail": "Modulo metamethod",
|
|
1856
|
+
"documentation": {
|
|
1857
|
+
"value": "Modulo metamethod.\n\n```lua\nmetatable.__mod = function(a, b)\n\treturn a % b\nend\n```"
|
|
1858
|
+
},
|
|
1859
|
+
"insertText": "metatable.__mod = function(a, b)\n\t${0:return a % b}\nend",
|
|
1860
|
+
"insertTextRules": 4,
|
|
1861
|
+
"sortText": "04_metatable___mod"
|
|
1862
|
+
},
|
|
1863
|
+
{
|
|
1864
|
+
"label": "metatable __pow",
|
|
1865
|
+
"kind": 15,
|
|
1866
|
+
"detail": "Exponentiation metamethod",
|
|
1867
|
+
"documentation": {
|
|
1868
|
+
"value": "Exponentiation metamethod.\n\n```lua\nmetatable.__pow = function(a, b)\n\treturn a ^ b\nend\n```"
|
|
1869
|
+
},
|
|
1870
|
+
"insertText": "metatable.__pow = function(a, b)\n\t${0:return a ^ b}\nend",
|
|
1871
|
+
"insertTextRules": 4,
|
|
1872
|
+
"sortText": "04_metatable___pow"
|
|
1873
|
+
},
|
|
1874
|
+
{
|
|
1875
|
+
"label": "metatable __unm",
|
|
1876
|
+
"kind": 15,
|
|
1877
|
+
"detail": "Unary minus metamethod",
|
|
1878
|
+
"documentation": {
|
|
1879
|
+
"value": "Unary minus metamethod.\n\n```lua\nmetatable.__unm = function(a)\n\treturn -a\nend\n```"
|
|
1880
|
+
},
|
|
1881
|
+
"insertText": "metatable.__unm = function(a)\n\t${0:return -a}\nend",
|
|
1882
|
+
"insertTextRules": 4,
|
|
1883
|
+
"sortText": "04_metatable___unm"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
"label": "metatable __le",
|
|
1887
|
+
"kind": 15,
|
|
1888
|
+
"detail": "Less-than-or-equal metamethod",
|
|
1889
|
+
"documentation": {
|
|
1890
|
+
"value": "Less-than-or-equal metamethod.\n\n```lua\nmetatable.__le = function(a, b)\n\treturn a <= b\nend\n```"
|
|
1891
|
+
},
|
|
1892
|
+
"insertText": "metatable.__le = function(a, b)\n\t${0:return a <= b}\nend",
|
|
1893
|
+
"insertTextRules": 4,
|
|
1894
|
+
"sortText": "04_metatable___le"
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
"label": "metatable __close",
|
|
1898
|
+
"kind": 15,
|
|
1899
|
+
"detail": "To-be-closed metamethod (5.4)",
|
|
1900
|
+
"documentation": {
|
|
1901
|
+
"value": "To-be-closed metamethod (5.4).\n\n```lua\nmetatable.__close = function(obj, err)\n\t-- cleanup\nend\n```"
|
|
1902
|
+
},
|
|
1903
|
+
"insertText": "metatable.__close = function(obj, err)\n\t${0:-- cleanup}\nend",
|
|
1904
|
+
"insertTextRules": 4,
|
|
1905
|
+
"sortText": "04_metatable___close"
|
|
1906
|
+
},
|
|
1907
|
+
{
|
|
1908
|
+
"label": "metatable __metatable",
|
|
1909
|
+
"kind": 15,
|
|
1910
|
+
"detail": "Metatable protection",
|
|
1911
|
+
"documentation": {
|
|
1912
|
+
"value": "Metatable protection.\n\n```lua\nmetatable.__metatable = \"protected\"\n```"
|
|
1913
|
+
},
|
|
1914
|
+
"insertText": "metatable.__metatable = ${0:\"protected\"}",
|
|
343
1915
|
"insertTextRules": 4,
|
|
344
|
-
"sortText": "
|
|
1916
|
+
"sortText": "04_metatable___metatable"
|
|
345
1917
|
},
|
|
346
1918
|
{
|
|
347
1919
|
"label": "table.insert",
|
|
348
|
-
"kind":
|
|
349
|
-
"detail": "Insert
|
|
350
|
-
"documentation": {
|
|
351
|
-
|
|
1920
|
+
"kind": 15,
|
|
1921
|
+
"detail": "Insert element into table",
|
|
1922
|
+
"documentation": {
|
|
1923
|
+
"value": "Insert element into table.\n\n```lua\nlocal t = {1,2,3}\ntable.insert(t, 4) -- {1,2,3,4}\ntable.insert(t, 1, 0) -- {0,1,2,3,4}\n```"
|
|
1924
|
+
},
|
|
1925
|
+
"insertText": "table.insert(${1:t}, ${2:value})",
|
|
352
1926
|
"insertTextRules": 4,
|
|
353
|
-
"sortText": "
|
|
1927
|
+
"sortText": "05_table_table.insert"
|
|
354
1928
|
},
|
|
355
1929
|
{
|
|
356
1930
|
"label": "table.remove",
|
|
357
|
-
"kind":
|
|
358
|
-
"detail": "Remove
|
|
359
|
-
"documentation": {
|
|
360
|
-
|
|
1931
|
+
"kind": 15,
|
|
1932
|
+
"detail": "Remove element from table",
|
|
1933
|
+
"documentation": {
|
|
1934
|
+
"value": "Remove element from table.\n\n```lua\nlocal t = {1,2,3}\nlocal v = table.remove(t, 2) -- v=2, t={1,3}\ntable.remove(t) -- removes last\n```"
|
|
1935
|
+
},
|
|
1936
|
+
"insertText": "table.remove(${1:t}, ${2:pos})",
|
|
361
1937
|
"insertTextRules": 4,
|
|
362
|
-
"sortText": "
|
|
1938
|
+
"sortText": "05_table_table.remove"
|
|
363
1939
|
},
|
|
364
1940
|
{
|
|
365
1941
|
"label": "table.sort",
|
|
366
|
-
"kind":
|
|
367
|
-
"detail": "Sort
|
|
368
|
-
"documentation": {
|
|
369
|
-
|
|
1942
|
+
"kind": 15,
|
|
1943
|
+
"detail": "Sort table in-place",
|
|
1944
|
+
"documentation": {
|
|
1945
|
+
"value": "Sort table in-place.\n\n```lua\nlocal t = {3,1,2}\ntable.sort(t) -- {1,2,3}\ntable.sort(t, function(a,b) return a > b end) -- {3,2,1}\n```"
|
|
1946
|
+
},
|
|
1947
|
+
"insertText": "table.sort(${1:t}, ${2:function(a, b) return a < b end})",
|
|
370
1948
|
"insertTextRules": 4,
|
|
371
|
-
"sortText": "
|
|
1949
|
+
"sortText": "05_table_table.sort"
|
|
372
1950
|
},
|
|
373
1951
|
{
|
|
374
1952
|
"label": "table.concat",
|
|
375
|
-
"kind":
|
|
376
|
-
"detail": "Concatenate table elements into
|
|
377
|
-
"documentation": {
|
|
378
|
-
|
|
1953
|
+
"kind": 15,
|
|
1954
|
+
"detail": "Concatenate table elements into string",
|
|
1955
|
+
"documentation": {
|
|
1956
|
+
"value": "Concatenate table elements into string.\n\n```lua\nlocal t = {'a','b','c'}\nprint(table.concat(t, ',')) -- a,b,c\nprint(table.concat(t, ', ', 2, 3)) -- b, c\n```"
|
|
1957
|
+
},
|
|
1958
|
+
"insertText": "table.concat(${1:t}, ${2:sep})",
|
|
379
1959
|
"insertTextRules": 4,
|
|
380
|
-
"sortText": "
|
|
1960
|
+
"sortText": "05_table_table.concat"
|
|
381
1961
|
},
|
|
382
1962
|
{
|
|
383
1963
|
"label": "table.move",
|
|
384
|
-
"kind":
|
|
385
|
-
"detail": "Move elements
|
|
386
|
-
"documentation": {
|
|
387
|
-
|
|
1964
|
+
"kind": 15,
|
|
1965
|
+
"detail": "Move elements between tables (5.3+)",
|
|
1966
|
+
"documentation": {
|
|
1967
|
+
"value": "Move elements between tables (5.3+).\n\n```lua\nlocal src = {1,2,3,4,5}\nlocal dst = {}\ntable.move(src, 2, 4, 1, dst) -- dst = {2,3,4}\n```"
|
|
1968
|
+
},
|
|
1969
|
+
"insertText": "table.move(${1:a1}, ${2:f}, ${3:e}, ${4:t}, ${5:a2})",
|
|
388
1970
|
"insertTextRules": 4,
|
|
389
|
-
"sortText": "
|
|
1971
|
+
"sortText": "05_table_table.move"
|
|
390
1972
|
},
|
|
391
1973
|
{
|
|
392
1974
|
"label": "table.pack",
|
|
393
|
-
"kind":
|
|
394
|
-
"detail": "Pack arguments into a table
|
|
395
|
-
"documentation": {
|
|
1975
|
+
"kind": 15,
|
|
1976
|
+
"detail": "Pack arguments into a table with .n field",
|
|
1977
|
+
"documentation": {
|
|
1978
|
+
"value": "Pack arguments into a table with .n field.\n\n```lua\nlocal t = table.pack(1,2,3) -- {1,2,3, n=3}\nprint(t.n) -- 3\n```"
|
|
1979
|
+
},
|
|
396
1980
|
"insertText": "table.pack(${1:...})",
|
|
397
1981
|
"insertTextRules": 4,
|
|
398
|
-
"sortText": "
|
|
1982
|
+
"sortText": "05_table_table.pack"
|
|
399
1983
|
},
|
|
400
1984
|
{
|
|
401
1985
|
"label": "table.unpack",
|
|
402
|
-
"kind":
|
|
403
|
-
"detail": "Unpack
|
|
404
|
-
"documentation": {
|
|
405
|
-
|
|
1986
|
+
"kind": 15,
|
|
1987
|
+
"detail": "Unpack table to multiple values",
|
|
1988
|
+
"documentation": {
|
|
1989
|
+
"value": "Unpack table to multiple values.\n\n```lua\nlocal t = {10,20,30}\nprint(table.unpack(t)) -- 10 20 30\nprint(table.unpack(t, 2, 3)) -- 20 30\n```"
|
|
1990
|
+
},
|
|
1991
|
+
"insertText": "table.unpack(${1:t}, ${2:i}, ${3:j})",
|
|
406
1992
|
"insertTextRules": 4,
|
|
407
|
-
"sortText": "
|
|
1993
|
+
"sortText": "05_table_table.unpack"
|
|
408
1994
|
},
|
|
409
1995
|
{
|
|
410
|
-
"label": "
|
|
411
|
-
"kind":
|
|
412
|
-
"detail": "
|
|
413
|
-
"documentation": {
|
|
414
|
-
|
|
1996
|
+
"label": "string.sub",
|
|
1997
|
+
"kind": 15,
|
|
1998
|
+
"detail": "Extract substring",
|
|
1999
|
+
"documentation": {
|
|
2000
|
+
"value": "Extract substring.\n\n```lua\nlocal s = 'hello world'\nprint(string.sub(s, 1, 5)) -- hello\nprint(string.sub(s, -5)) -- world\n```"
|
|
2001
|
+
},
|
|
2002
|
+
"insertText": "string.sub(${1:s}, ${2:i}, ${3:j})",
|
|
415
2003
|
"insertTextRules": 4,
|
|
416
|
-
"sortText": "
|
|
2004
|
+
"sortText": "05_string_string.sub"
|
|
417
2005
|
},
|
|
418
2006
|
{
|
|
419
|
-
"label": "
|
|
420
|
-
"kind":
|
|
421
|
-
"detail": "
|
|
422
|
-
"documentation": {
|
|
423
|
-
|
|
2007
|
+
"label": "string.rep",
|
|
2008
|
+
"kind": 15,
|
|
2009
|
+
"detail": "Repeat string n times",
|
|
2010
|
+
"documentation": {
|
|
2011
|
+
"value": "Repeat string n times.\n\n```lua\nprint(string.rep('ab', 3)) -- ababab\nprint(string.rep('ab', 3, ',')) -- ab,ab,ab\n```"
|
|
2012
|
+
},
|
|
2013
|
+
"insertText": "string.rep(${1:s}, ${2:n}, ${3:sep})",
|
|
424
2014
|
"insertTextRules": 4,
|
|
425
|
-
"sortText": "
|
|
2015
|
+
"sortText": "05_string_string.rep"
|
|
426
2016
|
},
|
|
427
2017
|
{
|
|
428
|
-
"label": "
|
|
429
|
-
"kind":
|
|
430
|
-
"detail": "
|
|
431
|
-
"documentation": {
|
|
432
|
-
|
|
2018
|
+
"label": "string.reverse",
|
|
2019
|
+
"kind": 15,
|
|
2020
|
+
"detail": "Reverse a string",
|
|
2021
|
+
"documentation": {
|
|
2022
|
+
"value": "Reverse a string.\n\n```lua\nprint(string.reverse('hello')) -- olleh\n```"
|
|
2023
|
+
},
|
|
2024
|
+
"insertText": "string.reverse(${1:s})",
|
|
433
2025
|
"insertTextRules": 4,
|
|
434
|
-
"sortText": "
|
|
2026
|
+
"sortText": "05_string_string.reverse"
|
|
435
2027
|
},
|
|
436
2028
|
{
|
|
437
|
-
"label": "
|
|
438
|
-
"kind":
|
|
439
|
-
"detail": "
|
|
440
|
-
"documentation": {
|
|
441
|
-
|
|
2029
|
+
"label": "string.upper",
|
|
2030
|
+
"kind": 15,
|
|
2031
|
+
"detail": "Convert to uppercase",
|
|
2032
|
+
"documentation": {
|
|
2033
|
+
"value": "Convert to uppercase.\n\n```lua\nprint(string.upper('hello')) -- HELLO\n```"
|
|
2034
|
+
},
|
|
2035
|
+
"insertText": "string.upper(${1:s})",
|
|
442
2036
|
"insertTextRules": 4,
|
|
443
|
-
"sortText": "
|
|
2037
|
+
"sortText": "05_string_string.upper"
|
|
444
2038
|
},
|
|
445
2039
|
{
|
|
446
|
-
"label": "
|
|
447
|
-
"kind":
|
|
448
|
-
"detail": "
|
|
449
|
-
"documentation": {
|
|
450
|
-
|
|
2040
|
+
"label": "string.lower",
|
|
2041
|
+
"kind": 15,
|
|
2042
|
+
"detail": "Convert to lowercase",
|
|
2043
|
+
"documentation": {
|
|
2044
|
+
"value": "Convert to lowercase.\n\n```lua\nprint(string.lower('HELLO')) -- hello\n```"
|
|
2045
|
+
},
|
|
2046
|
+
"insertText": "string.lower(${1:s})",
|
|
451
2047
|
"insertTextRules": 4,
|
|
452
|
-
"sortText": "
|
|
2048
|
+
"sortText": "05_string_string.lower"
|
|
453
2049
|
},
|
|
454
2050
|
{
|
|
455
|
-
"label": "
|
|
456
|
-
"kind":
|
|
457
|
-
"detail": "
|
|
458
|
-
"documentation": {
|
|
459
|
-
|
|
2051
|
+
"label": "string.len",
|
|
2052
|
+
"kind": 15,
|
|
2053
|
+
"detail": "Get string length in bytes",
|
|
2054
|
+
"documentation": {
|
|
2055
|
+
"value": "Get string length in bytes.\n\n```lua\nprint(string.len('hello')) -- 5\nprint(#'hello') -- 5 (operator shorthand)\n```"
|
|
2056
|
+
},
|
|
2057
|
+
"insertText": "string.len(${1:s})",
|
|
460
2058
|
"insertTextRules": 4,
|
|
461
|
-
"sortText": "
|
|
2059
|
+
"sortText": "05_string_string.len"
|
|
462
2060
|
},
|
|
463
2061
|
{
|
|
464
|
-
"label": "
|
|
465
|
-
"kind":
|
|
466
|
-
"detail": "
|
|
467
|
-
"documentation": {
|
|
468
|
-
|
|
2062
|
+
"label": "string.byte",
|
|
2063
|
+
"kind": 15,
|
|
2064
|
+
"detail": "Get byte values of characters",
|
|
2065
|
+
"documentation": {
|
|
2066
|
+
"value": "Get byte values of characters.\n\n```lua\nprint(string.byte('A')) -- 65\nprint(string.byte('abc', 1, 3)) -- 97 98 99\n```"
|
|
2067
|
+
},
|
|
2068
|
+
"insertText": "string.byte(${1:s}, ${2:i}, ${3:j})",
|
|
469
2069
|
"insertTextRules": 4,
|
|
470
|
-
"sortText": "
|
|
2070
|
+
"sortText": "05_string_string.byte"
|
|
471
2071
|
},
|
|
472
2072
|
{
|
|
473
|
-
"label": "
|
|
474
|
-
"kind":
|
|
475
|
-
"detail": "
|
|
476
|
-
"documentation": {
|
|
477
|
-
|
|
2073
|
+
"label": "string.char",
|
|
2074
|
+
"kind": 15,
|
|
2075
|
+
"detail": "Convert byte values to characters",
|
|
2076
|
+
"documentation": {
|
|
2077
|
+
"value": "Convert byte values to characters.\n\n```lua\nprint(string.char(72,101,108,108,111)) -- Hello\n```"
|
|
2078
|
+
},
|
|
2079
|
+
"insertText": "string.char(${1:...})",
|
|
2080
|
+
"insertTextRules": 4,
|
|
2081
|
+
"sortText": "05_string_string.char"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
"label": "string.dump",
|
|
2085
|
+
"kind": 15,
|
|
2086
|
+
"detail": "Dump function as binary string",
|
|
2087
|
+
"documentation": {
|
|
2088
|
+
"value": "Dump function as binary string.\n\n```lua\nlocal f = function() return 42 end\nlocal s = string.dump(f)\nlocal f2 = load(s)\nprint(f2()) -- 42\n```"
|
|
2089
|
+
},
|
|
2090
|
+
"insertText": "string.dump(${1:func}, ${2:strip})",
|
|
2091
|
+
"insertTextRules": 4,
|
|
2092
|
+
"sortText": "05_string_string.dump"
|
|
2093
|
+
},
|
|
2094
|
+
{
|
|
2095
|
+
"label": "string.packsize",
|
|
2096
|
+
"kind": 15,
|
|
2097
|
+
"detail": "Get packed size for format string (5.3+)",
|
|
2098
|
+
"documentation": {
|
|
2099
|
+
"value": "Get packed size for format string (5.3+).\n\n```lua\nprint(string.packsize('ii')) -- 8 (two ints)\nprint(string.packsize('Bs4')) -- varies\n```"
|
|
2100
|
+
},
|
|
2101
|
+
"insertText": "string.packsize(${1:fmt})",
|
|
2102
|
+
"insertTextRules": 4,
|
|
2103
|
+
"sortText": "05_string_string.packsize"
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
"label": "math.abs",
|
|
2107
|
+
"kind": 15,
|
|
2108
|
+
"detail": "Absolute value",
|
|
2109
|
+
"documentation": {
|
|
2110
|
+
"value": "Absolute value.\n\n```lua\nprint(math.abs(-5)) -- 5\n```"
|
|
2111
|
+
},
|
|
2112
|
+
"insertText": "math.abs(${1:x})",
|
|
478
2113
|
"insertTextRules": 4,
|
|
479
|
-
"sortText": "
|
|
2114
|
+
"sortText": "05_math_math.abs"
|
|
480
2115
|
},
|
|
481
2116
|
{
|
|
482
|
-
"label": "math.
|
|
483
|
-
"kind":
|
|
484
|
-
"detail": "
|
|
485
|
-
"documentation": {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
"
|
|
2117
|
+
"label": "math.ceil",
|
|
2118
|
+
"kind": 15,
|
|
2119
|
+
"detail": "Round up to integer",
|
|
2120
|
+
"documentation": {
|
|
2121
|
+
"value": "Round up to integer.\n\n```lua\nprint(math.ceil(3.2)) -- 4\n```"
|
|
2122
|
+
},
|
|
2123
|
+
"insertText": "math.ceil(${1:x})",
|
|
2124
|
+
"insertTextRules": 4,
|
|
2125
|
+
"sortText": "05_math_math.ceil"
|
|
489
2126
|
},
|
|
490
2127
|
{
|
|
491
|
-
"label": "math.
|
|
492
|
-
"kind":
|
|
493
|
-
"detail": "
|
|
494
|
-
"documentation": {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
"
|
|
2128
|
+
"label": "math.sqrt",
|
|
2129
|
+
"kind": 15,
|
|
2130
|
+
"detail": "Square root",
|
|
2131
|
+
"documentation": {
|
|
2132
|
+
"value": "Square root.\n\n```lua\nprint(math.sqrt(16)) -- 4.0\n```"
|
|
2133
|
+
},
|
|
2134
|
+
"insertText": "math.sqrt(${1:x})",
|
|
2135
|
+
"insertTextRules": 4,
|
|
2136
|
+
"sortText": "05_math_math.sqrt"
|
|
498
2137
|
},
|
|
499
2138
|
{
|
|
500
2139
|
"label": "math.sin",
|
|
501
|
-
"kind":
|
|
2140
|
+
"kind": 15,
|
|
502
2141
|
"detail": "Sine (radians)",
|
|
503
|
-
"documentation": {
|
|
2142
|
+
"documentation": {
|
|
2143
|
+
"value": "Sine (radians).\n\n```lua\nprint(math.sin(math.pi/2)) -- 1.0\n```"
|
|
2144
|
+
},
|
|
504
2145
|
"insertText": "math.sin(${1:x})",
|
|
505
2146
|
"insertTextRules": 4,
|
|
506
|
-
"sortText": "
|
|
2147
|
+
"sortText": "05_math_math.sin"
|
|
507
2148
|
},
|
|
508
2149
|
{
|
|
509
2150
|
"label": "math.cos",
|
|
510
|
-
"kind":
|
|
2151
|
+
"kind": 15,
|
|
511
2152
|
"detail": "Cosine (radians)",
|
|
512
|
-
"documentation": {
|
|
2153
|
+
"documentation": {
|
|
2154
|
+
"value": "Cosine (radians).\n\n```lua\nprint(math.cos(0)) -- 1.0\n```"
|
|
2155
|
+
},
|
|
513
2156
|
"insertText": "math.cos(${1:x})",
|
|
514
2157
|
"insertTextRules": 4,
|
|
515
|
-
"sortText": "
|
|
2158
|
+
"sortText": "05_math_math.cos"
|
|
516
2159
|
},
|
|
517
2160
|
{
|
|
518
|
-
"label": "math.
|
|
519
|
-
"kind":
|
|
520
|
-
"detail": "
|
|
521
|
-
"documentation": {
|
|
522
|
-
|
|
2161
|
+
"label": "math.tan",
|
|
2162
|
+
"kind": 15,
|
|
2163
|
+
"detail": "Tangent (radians)",
|
|
2164
|
+
"documentation": {
|
|
2165
|
+
"value": "Tangent (radians).\n\n```lua\nprint(math.tan(math.pi/4)) -- ~1.0\n```"
|
|
2166
|
+
},
|
|
2167
|
+
"insertText": "math.tan(${1:x})",
|
|
523
2168
|
"insertTextRules": 4,
|
|
524
|
-
"sortText": "
|
|
2169
|
+
"sortText": "05_math_math.tan"
|
|
525
2170
|
},
|
|
526
2171
|
{
|
|
527
2172
|
"label": "math.exp",
|
|
528
|
-
"kind":
|
|
529
|
-
"detail": "
|
|
530
|
-
"documentation": {
|
|
2173
|
+
"kind": 15,
|
|
2174
|
+
"detail": "e^x",
|
|
2175
|
+
"documentation": {
|
|
2176
|
+
"value": "e^x.\n\n```lua\nprint(math.exp(1)) -- 2.718...\n```"
|
|
2177
|
+
},
|
|
531
2178
|
"insertText": "math.exp(${1:x})",
|
|
532
2179
|
"insertTextRules": 4,
|
|
533
|
-
"sortText": "
|
|
2180
|
+
"sortText": "05_math_math.exp"
|
|
534
2181
|
},
|
|
535
2182
|
{
|
|
536
|
-
"label": "
|
|
537
|
-
"kind":
|
|
538
|
-
"detail": "
|
|
539
|
-
"documentation": {
|
|
540
|
-
|
|
2183
|
+
"label": "math.log",
|
|
2184
|
+
"kind": 15,
|
|
2185
|
+
"detail": "Logarithm (natural or custom base)",
|
|
2186
|
+
"documentation": {
|
|
2187
|
+
"value": "Logarithm (natural or custom base).\n\n```lua\nprint(math.log(math.exp(1))) -- 1.0\nprint(math.log(100, 10)) -- 2.0\n```"
|
|
2188
|
+
},
|
|
2189
|
+
"insertText": "math.log(${1:x}, ${2:base})",
|
|
541
2190
|
"insertTextRules": 4,
|
|
542
|
-
"sortText": "
|
|
2191
|
+
"sortText": "05_math_math.log"
|
|
543
2192
|
},
|
|
544
2193
|
{
|
|
545
|
-
"label": "
|
|
546
|
-
"kind":
|
|
547
|
-
"detail": "
|
|
548
|
-
"documentation": {
|
|
549
|
-
|
|
2194
|
+
"label": "math.fmod",
|
|
2195
|
+
"kind": 15,
|
|
2196
|
+
"detail": "Float modulo",
|
|
2197
|
+
"documentation": {
|
|
2198
|
+
"value": "Float modulo.\n\n```lua\nprint(math.fmod(7, 3)) -- 1.0\n```"
|
|
2199
|
+
},
|
|
2200
|
+
"insertText": "math.fmod(${1:x}, ${2:y})",
|
|
550
2201
|
"insertTextRules": 4,
|
|
551
|
-
"sortText": "
|
|
2202
|
+
"sortText": "05_math_math.fmod"
|
|
552
2203
|
},
|
|
553
2204
|
{
|
|
554
|
-
"label": "
|
|
555
|
-
"kind":
|
|
556
|
-
"detail": "
|
|
557
|
-
"documentation": {
|
|
558
|
-
|
|
2205
|
+
"label": "math.tointeger",
|
|
2206
|
+
"kind": 15,
|
|
2207
|
+
"detail": "Convert to integer or nil (5.3+)",
|
|
2208
|
+
"documentation": {
|
|
2209
|
+
"value": "Convert to integer or nil (5.3+).\n\n```lua\nprint(math.tointeger(5.0)) -- 5\nprint(math.tointeger(5.5)) -- nil\n```"
|
|
2210
|
+
},
|
|
2211
|
+
"insertText": "math.tointeger(${1:x})",
|
|
559
2212
|
"insertTextRules": 4,
|
|
560
|
-
"sortText": "
|
|
2213
|
+
"sortText": "05_math_math.tointeger"
|
|
561
2214
|
},
|
|
562
2215
|
{
|
|
563
|
-
"label": "
|
|
564
|
-
"kind":
|
|
565
|
-
"detail": "
|
|
566
|
-
"documentation": {
|
|
567
|
-
|
|
2216
|
+
"label": "math.randomseed",
|
|
2217
|
+
"kind": 15,
|
|
2218
|
+
"detail": "Set random seed",
|
|
2219
|
+
"documentation": {
|
|
2220
|
+
"value": "Set random seed.\n\n```lua\nmath.randomseed(os.time())\nprint(math.random(1, 100))\n```"
|
|
2221
|
+
},
|
|
2222
|
+
"insertText": "math.randomseed(${1:seed})",
|
|
568
2223
|
"insertTextRules": 4,
|
|
569
|
-
"sortText": "
|
|
2224
|
+
"sortText": "05_math_math.randomseed"
|
|
570
2225
|
},
|
|
571
2226
|
{
|
|
572
|
-
"label": "io.
|
|
573
|
-
"kind":
|
|
574
|
-
"detail": "
|
|
575
|
-
"documentation": {
|
|
576
|
-
|
|
2227
|
+
"label": "io.flush",
|
|
2228
|
+
"kind": 15,
|
|
2229
|
+
"detail": "Flush default output",
|
|
2230
|
+
"documentation": {
|
|
2231
|
+
"value": "Flush default output.\n\n```lua\nio.write('buffered')\nio.flush() -- force write\n```"
|
|
2232
|
+
},
|
|
2233
|
+
"insertText": "io.flush()",
|
|
577
2234
|
"insertTextRules": 4,
|
|
578
|
-
"sortText": "
|
|
2235
|
+
"sortText": "05_io_io.flush"
|
|
579
2236
|
},
|
|
580
2237
|
{
|
|
581
|
-
"label": "
|
|
582
|
-
"kind":
|
|
583
|
-
"detail": "
|
|
584
|
-
"documentation": {
|
|
585
|
-
|
|
2238
|
+
"label": "io.input",
|
|
2239
|
+
"kind": 15,
|
|
2240
|
+
"detail": "Set/get default input file",
|
|
2241
|
+
"documentation": {
|
|
2242
|
+
"value": "Set/get default input file.\n\n```lua\nio.input('data.txt')\nlocal content = io.read('*a')\n```"
|
|
2243
|
+
},
|
|
2244
|
+
"insertText": "io.input(${1:file})",
|
|
586
2245
|
"insertTextRules": 4,
|
|
587
|
-
"sortText": "
|
|
2246
|
+
"sortText": "05_io_io.input"
|
|
588
2247
|
},
|
|
589
2248
|
{
|
|
590
|
-
"label": "
|
|
591
|
-
"kind":
|
|
592
|
-
"detail": "
|
|
593
|
-
"documentation": {
|
|
594
|
-
|
|
2249
|
+
"label": "io.output",
|
|
2250
|
+
"kind": 15,
|
|
2251
|
+
"detail": "Set/get default output file",
|
|
2252
|
+
"documentation": {
|
|
2253
|
+
"value": "Set/get default output file.\n\n```lua\nio.output('out.txt')\nio.write('hello')\n```"
|
|
2254
|
+
},
|
|
2255
|
+
"insertText": "io.output(${1:file})",
|
|
595
2256
|
"insertTextRules": 4,
|
|
596
|
-
"sortText": "
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
"label": "os.clock",
|
|
600
|
-
"kind": 1,
|
|
601
|
-
"detail": "Get CPU time used by the program",
|
|
602
|
-
"documentation": { "value": "Returns an approximation of the amount of CPU time used by the program, in seconds.\n\n```lua\nlocal start = os.clock()\n-- ... do work ...\nprint(string.format(\"Elapsed: %.3f s\", os.clock() - start))\n```" },
|
|
603
|
-
"insertText": "os.clock()",
|
|
604
|
-
"insertTextRules": 0,
|
|
605
|
-
"sortText": "05_os.clock"
|
|
2257
|
+
"sortText": "05_io_io.output"
|
|
606
2258
|
},
|
|
607
2259
|
{
|
|
608
|
-
"label": "
|
|
609
|
-
"kind":
|
|
610
|
-
"detail": "
|
|
611
|
-
"documentation": {
|
|
612
|
-
|
|
2260
|
+
"label": "io.tmpfile",
|
|
2261
|
+
"kind": 15,
|
|
2262
|
+
"detail": "Create temporary file",
|
|
2263
|
+
"documentation": {
|
|
2264
|
+
"value": "Create temporary file.\n\n```lua\nlocal f = io.tmpfile()\nf:write('temp data')\nf:seek('set')\nprint(f:read('*a'))\n```"
|
|
2265
|
+
},
|
|
2266
|
+
"insertText": "io.tmpfile()",
|
|
613
2267
|
"insertTextRules": 4,
|
|
614
|
-
"sortText": "
|
|
2268
|
+
"sortText": "05_io_io.tmpfile"
|
|
615
2269
|
},
|
|
616
2270
|
{
|
|
617
|
-
"label": "
|
|
618
|
-
"kind":
|
|
619
|
-
"detail": "
|
|
620
|
-
"documentation": {
|
|
621
|
-
|
|
2271
|
+
"label": "io.type",
|
|
2272
|
+
"kind": 15,
|
|
2273
|
+
"detail": "Check file handle type",
|
|
2274
|
+
"documentation": {
|
|
2275
|
+
"value": "Check file handle type.\n\n```lua\nlocal f = io.open('test.txt')\nprint(io.type(f)) -- 'file'\nf:close()\nprint(io.type(f)) -- 'closed file'\n```"
|
|
2276
|
+
},
|
|
2277
|
+
"insertText": "io.type(${1:obj})",
|
|
622
2278
|
"insertTextRules": 4,
|
|
623
|
-
"sortText": "
|
|
2279
|
+
"sortText": "05_io_io.type"
|
|
624
2280
|
},
|
|
625
2281
|
{
|
|
626
|
-
"label": "
|
|
627
|
-
"kind":
|
|
628
|
-
"detail": "
|
|
629
|
-
"documentation": {
|
|
630
|
-
|
|
2282
|
+
"label": "io.popen",
|
|
2283
|
+
"kind": 15,
|
|
2284
|
+
"detail": "Execute command and get pipe",
|
|
2285
|
+
"documentation": {
|
|
2286
|
+
"value": "Execute command and get pipe.\n\n```lua\nlocal f = io.popen('ls', 'r')\nlocal output = f:read('*a')\nf:close()\n```"
|
|
2287
|
+
},
|
|
2288
|
+
"insertText": "io.popen(${1:cmd}, ${2:mode})",
|
|
631
2289
|
"insertTextRules": 4,
|
|
632
|
-
"sortText": "
|
|
2290
|
+
"sortText": "05_io_io.popen"
|
|
633
2291
|
},
|
|
634
2292
|
{
|
|
635
|
-
"label": "os.
|
|
636
|
-
"kind":
|
|
637
|
-
"detail": "
|
|
638
|
-
"documentation": {
|
|
639
|
-
|
|
2293
|
+
"label": "os.getenv",
|
|
2294
|
+
"kind": 15,
|
|
2295
|
+
"detail": "Get environment variable",
|
|
2296
|
+
"documentation": {
|
|
2297
|
+
"value": "Get environment variable.\n\n```lua\nlocal home = os.getenv('HOME')\nlocal path = os.getenv('PATH')\n```"
|
|
2298
|
+
},
|
|
2299
|
+
"insertText": "os.getenv(${1:varname})",
|
|
640
2300
|
"insertTextRules": 4,
|
|
641
|
-
"sortText": "
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
"label": "os.tmpname",
|
|
645
|
-
"kind": 1,
|
|
646
|
-
"detail": "Generate a temporary file name",
|
|
647
|
-
"documentation": { "value": "Returns a string with a file name that can be used for a temporary file.\n\n```lua\nlocal tmpfile = os.tmpname()\n```" },
|
|
648
|
-
"insertText": "os.tmpname()",
|
|
649
|
-
"insertTextRules": 0,
|
|
650
|
-
"sortText": "05_os.tmpname"
|
|
2301
|
+
"sortText": "05_os_os.getenv"
|
|
651
2302
|
},
|
|
652
2303
|
{
|
|
653
2304
|
"label": "os.exit",
|
|
654
|
-
"kind":
|
|
655
|
-
"detail": "
|
|
656
|
-
"documentation": {
|
|
657
|
-
|
|
2305
|
+
"kind": 15,
|
|
2306
|
+
"detail": "Exit the program",
|
|
2307
|
+
"documentation": {
|
|
2308
|
+
"value": "Exit the program.\n\n```lua\nos.exit(0) -- success\nos.exit(1) -- failure\nos.exit(true, true) -- close Lua state\n```"
|
|
2309
|
+
},
|
|
2310
|
+
"insertText": "os.exit(${1:code}, ${2:close})",
|
|
658
2311
|
"insertTextRules": 4,
|
|
659
|
-
"sortText": "
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
"label": "if",
|
|
663
|
-
"kind": 14,
|
|
664
|
-
"detail": "Conditional keyword",
|
|
665
|
-
"documentation": { "value": "Begins a conditional statement. Must be followed by `then` and closed with `end`.\n\n```lua\nif condition then\n -- code\nelseif other then\n -- code\nelse\n -- code\nend\n```" },
|
|
666
|
-
"insertText": "if",
|
|
667
|
-
"insertTextRules": 0,
|
|
668
|
-
"sortText": "06_if"
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
"label": "then",
|
|
672
|
-
"kind": 14,
|
|
673
|
-
"detail": "Conditional body keyword",
|
|
674
|
-
"documentation": { "value": "Follows an `if` or `elseif` condition to begin the conditional body." },
|
|
675
|
-
"insertText": "then",
|
|
676
|
-
"insertTextRules": 0,
|
|
677
|
-
"sortText": "06_then"
|
|
2312
|
+
"sortText": "05_os_os.exit"
|
|
678
2313
|
},
|
|
679
2314
|
{
|
|
680
|
-
"label": "
|
|
681
|
-
"kind":
|
|
682
|
-
"detail": "
|
|
683
|
-
"documentation": {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
"
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
"label": "elseif",
|
|
690
|
-
"kind": 14,
|
|
691
|
-
"detail": "Else-if branch keyword",
|
|
692
|
-
"documentation": { "value": "Combines an `else` and `if` into a single keyword for chaining conditions." },
|
|
693
|
-
"insertText": "elseif",
|
|
694
|
-
"insertTextRules": 0,
|
|
695
|
-
"sortText": "06_elseif"
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
"label": "end",
|
|
699
|
-
"kind": 14,
|
|
700
|
-
"detail": "Block terminator keyword",
|
|
701
|
-
"documentation": { "value": "Closes a block opened by `function`, `if`, `for`, `while`, or `do`." },
|
|
702
|
-
"insertText": "end",
|
|
703
|
-
"insertTextRules": 0,
|
|
704
|
-
"sortText": "06_end"
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
"label": "for",
|
|
708
|
-
"kind": 14,
|
|
709
|
-
"detail": "Loop keyword",
|
|
710
|
-
"documentation": { "value": "Begins a numeric or generic `for` loop.\n\n```lua\nfor i = 1, 10 do ... end\nfor k, v in pairs(t) do ... end\n```" },
|
|
711
|
-
"insertText": "for",
|
|
712
|
-
"insertTextRules": 0,
|
|
713
|
-
"sortText": "06_for"
|
|
2315
|
+
"label": "os.remove",
|
|
2316
|
+
"kind": 15,
|
|
2317
|
+
"detail": "Remove a file",
|
|
2318
|
+
"documentation": {
|
|
2319
|
+
"value": "Remove a file.\n\n```lua\nlocal ok, err = os.remove('temp.txt')\nif not ok then print(err) end\n```"
|
|
2320
|
+
},
|
|
2321
|
+
"insertText": "os.remove(${1:filename})",
|
|
2322
|
+
"insertTextRules": 4,
|
|
2323
|
+
"sortText": "05_os_os.remove"
|
|
714
2324
|
},
|
|
715
2325
|
{
|
|
716
|
-
"label": "
|
|
717
|
-
"kind":
|
|
718
|
-
"detail": "
|
|
719
|
-
"documentation": {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
"
|
|
2326
|
+
"label": "os.rename",
|
|
2327
|
+
"kind": 15,
|
|
2328
|
+
"detail": "Rename a file",
|
|
2329
|
+
"documentation": {
|
|
2330
|
+
"value": "Rename a file.\n\n```lua\nos.rename('old.txt', 'new.txt')\n```"
|
|
2331
|
+
},
|
|
2332
|
+
"insertText": "os.rename(${1:oldname}, ${2:newname})",
|
|
2333
|
+
"insertTextRules": 4,
|
|
2334
|
+
"sortText": "05_os_os.rename"
|
|
723
2335
|
},
|
|
724
2336
|
{
|
|
725
|
-
"label": "
|
|
726
|
-
"kind":
|
|
727
|
-
"detail": "
|
|
728
|
-
"documentation": {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
"
|
|
2337
|
+
"label": "os.difftime",
|
|
2338
|
+
"kind": 15,
|
|
2339
|
+
"detail": "Difference in seconds between two times",
|
|
2340
|
+
"documentation": {
|
|
2341
|
+
"value": "Difference in seconds between two times.\n\n```lua\nlocal t1 = os.time()\n-- ... work ...\nlocal t2 = os.time()\nprint(os.difftime(t2, t1) .. ' seconds')\n```"
|
|
2342
|
+
},
|
|
2343
|
+
"insertText": "os.difftime(${1:t2}, ${2:t1})",
|
|
2344
|
+
"insertTextRules": 4,
|
|
2345
|
+
"sortText": "05_os_os.difftime"
|
|
732
2346
|
},
|
|
733
2347
|
{
|
|
734
|
-
"label": "
|
|
735
|
-
"kind":
|
|
736
|
-
"detail": "
|
|
737
|
-
"documentation": {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
"
|
|
2348
|
+
"label": "os.tmpname",
|
|
2349
|
+
"kind": 15,
|
|
2350
|
+
"detail": "Generate temporary filename",
|
|
2351
|
+
"documentation": {
|
|
2352
|
+
"value": "Generate temporary filename.\n\n```lua\nlocal tmp = os.tmpname()\nprint(tmp) -- e.g. /tmp/lua_XXXXX\n```"
|
|
2353
|
+
},
|
|
2354
|
+
"insertText": "os.tmpname()",
|
|
2355
|
+
"insertTextRules": 4,
|
|
2356
|
+
"sortText": "05_os_os.tmpname"
|
|
741
2357
|
},
|
|
742
2358
|
{
|
|
743
|
-
"label": "
|
|
744
|
-
"kind":
|
|
745
|
-
"detail": "
|
|
746
|
-
"documentation": {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
"
|
|
2359
|
+
"label": "coroutine.status",
|
|
2360
|
+
"kind": 15,
|
|
2361
|
+
"detail": "Get coroutine status",
|
|
2362
|
+
"documentation": {
|
|
2363
|
+
"value": "Get coroutine status.\n\n```lua\nlocal co = coroutine.create(function() end)\nprint(coroutine.status(co)) -- 'suspended'\n```"
|
|
2364
|
+
},
|
|
2365
|
+
"insertText": "coroutine.status(${1:co})",
|
|
2366
|
+
"insertTextRules": 4,
|
|
2367
|
+
"sortText": "05_coroutine_coroutine.status"
|
|
750
2368
|
},
|
|
751
2369
|
{
|
|
752
|
-
"label": "
|
|
753
|
-
"kind":
|
|
754
|
-
"detail": "
|
|
755
|
-
"documentation": {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
"
|
|
2370
|
+
"label": "coroutine.isyieldable",
|
|
2371
|
+
"kind": 15,
|
|
2372
|
+
"detail": "Check if current coroutine can yield",
|
|
2373
|
+
"documentation": {
|
|
2374
|
+
"value": "Check if current coroutine can yield.\n\n```lua\nprint(coroutine.isyieldable()) -- false (main thread)\n```"
|
|
2375
|
+
},
|
|
2376
|
+
"insertText": "coroutine.isyieldable()",
|
|
2377
|
+
"insertTextRules": 4,
|
|
2378
|
+
"sortText": "05_coroutine_coroutine.isyieldable"
|
|
759
2379
|
},
|
|
760
2380
|
{
|
|
761
|
-
"label": "
|
|
762
|
-
"kind":
|
|
763
|
-
"detail": "
|
|
764
|
-
"documentation": {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
"
|
|
2381
|
+
"label": "coroutine.running",
|
|
2382
|
+
"kind": 15,
|
|
2383
|
+
"detail": "Get running coroutine and main thread flag",
|
|
2384
|
+
"documentation": {
|
|
2385
|
+
"value": "Get running coroutine and main thread flag.\n\n```lua\nlocal co, main = coroutine.running()\nprint(main) -- true if main thread\n```"
|
|
2386
|
+
},
|
|
2387
|
+
"insertText": "coroutine.running()",
|
|
2388
|
+
"insertTextRules": 4,
|
|
2389
|
+
"sortText": "05_coroutine_coroutine.running"
|
|
768
2390
|
},
|
|
769
2391
|
{
|
|
770
|
-
"label": "
|
|
771
|
-
"kind":
|
|
772
|
-
"detail": "
|
|
773
|
-
"documentation": {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
"
|
|
2392
|
+
"label": "coroutine.close",
|
|
2393
|
+
"kind": 15,
|
|
2394
|
+
"detail": "Close a coroutine (5.4+)",
|
|
2395
|
+
"documentation": {
|
|
2396
|
+
"value": "Close a coroutine (5.4+).\n\n```lua\nlocal co = coroutine.create(function() coroutine.yield() end)\ncoroutine.resume(co)\ncoroutine.close(co)\n```"
|
|
2397
|
+
},
|
|
2398
|
+
"insertText": "coroutine.close(${1:co})",
|
|
2399
|
+
"insertTextRules": 4,
|
|
2400
|
+
"sortText": "05_coroutine_coroutine.close"
|
|
777
2401
|
},
|
|
778
2402
|
{
|
|
779
|
-
"label": "
|
|
780
|
-
"kind":
|
|
781
|
-
"detail": "
|
|
782
|
-
"documentation": {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
"
|
|
2403
|
+
"label": "debug.sethook",
|
|
2404
|
+
"kind": 15,
|
|
2405
|
+
"detail": "Set debug hook",
|
|
2406
|
+
"documentation": {
|
|
2407
|
+
"value": "Set debug hook.\n\n```lua\ndebug.sethook(function(event, line)\n print(event, line)\nend, 'l') -- line hook\n```"
|
|
2408
|
+
},
|
|
2409
|
+
"insertText": "debug.sethook(${1:hook}, ${2:mask}, ${3:count})",
|
|
2410
|
+
"insertTextRules": 4,
|
|
2411
|
+
"sortText": "05_debug_debug.sethook"
|
|
786
2412
|
},
|
|
787
2413
|
{
|
|
788
|
-
"label": "
|
|
789
|
-
"kind":
|
|
790
|
-
"detail": "
|
|
791
|
-
"documentation": {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
"
|
|
2414
|
+
"label": "debug.getlocal",
|
|
2415
|
+
"kind": 15,
|
|
2416
|
+
"detail": "Get local variable name and value",
|
|
2417
|
+
"documentation": {
|
|
2418
|
+
"value": "Get local variable name and value.\n\n```lua\nlocal x = 42\nprint(debug.getlocal(1, 1)) -- 'x', 42\n```"
|
|
2419
|
+
},
|
|
2420
|
+
"insertText": "debug.getlocal(${1:level}, ${2:local_idx})",
|
|
2421
|
+
"insertTextRules": 4,
|
|
2422
|
+
"sortText": "05_debug_debug.getlocal"
|
|
795
2423
|
},
|
|
796
2424
|
{
|
|
797
|
-
"label": "
|
|
798
|
-
"kind":
|
|
799
|
-
"detail": "
|
|
800
|
-
"documentation": {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
"
|
|
2425
|
+
"label": "debug.setlocal",
|
|
2426
|
+
"kind": 15,
|
|
2427
|
+
"detail": "Set local variable value",
|
|
2428
|
+
"documentation": {
|
|
2429
|
+
"value": "Set local variable value.\n\n```lua\n-- Modify local in running function\ndebug.setlocal(1, 1, 'new_value')\n```"
|
|
2430
|
+
},
|
|
2431
|
+
"insertText": "debug.setlocal(${1:level}, ${2:local_idx}, ${3:value})",
|
|
2432
|
+
"insertTextRules": 4,
|
|
2433
|
+
"sortText": "05_debug_debug.setlocal"
|
|
804
2434
|
},
|
|
805
2435
|
{
|
|
806
|
-
"label": "
|
|
807
|
-
"kind":
|
|
808
|
-
"detail": "
|
|
809
|
-
"documentation": {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
"
|
|
2436
|
+
"label": "debug.getupvalue",
|
|
2437
|
+
"kind": 15,
|
|
2438
|
+
"detail": "Get upvalue name and value",
|
|
2439
|
+
"documentation": {
|
|
2440
|
+
"value": "Get upvalue name and value.\n\n```lua\nlocal x = 10\nlocal f = function() return x end\nprint(debug.getupvalue(f, 1)) -- 'x', 10\n```"
|
|
2441
|
+
},
|
|
2442
|
+
"insertText": "debug.getupvalue(${1:f}, ${2:up})",
|
|
2443
|
+
"insertTextRules": 4,
|
|
2444
|
+
"sortText": "05_debug_debug.getupvalue"
|
|
813
2445
|
},
|
|
814
2446
|
{
|
|
815
|
-
"label": "
|
|
816
|
-
"kind":
|
|
817
|
-
"detail": "
|
|
818
|
-
"documentation": {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
"
|
|
2447
|
+
"label": "debug.setupvalue",
|
|
2448
|
+
"kind": 15,
|
|
2449
|
+
"detail": "Set upvalue value",
|
|
2450
|
+
"documentation": {
|
|
2451
|
+
"value": "Set upvalue value.\n\n```lua\nlocal x = 10\nlocal f = function() return x end\ndebug.setupvalue(f, 1, 20)\n```"
|
|
2452
|
+
},
|
|
2453
|
+
"insertText": "debug.setupvalue(${1:f}, ${2:up}, ${3:value})",
|
|
2454
|
+
"insertTextRules": 4,
|
|
2455
|
+
"sortText": "05_debug_debug.setupvalue"
|
|
822
2456
|
},
|
|
823
2457
|
{
|
|
824
|
-
"label": "
|
|
825
|
-
"kind":
|
|
826
|
-
"detail": "
|
|
827
|
-
"documentation": {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
"
|
|
2458
|
+
"label": "debug.getmetatable",
|
|
2459
|
+
"kind": 15,
|
|
2460
|
+
"detail": "Get metatable (bypasses __metatable)",
|
|
2461
|
+
"documentation": {
|
|
2462
|
+
"value": "Get metatable (bypasses __metatable).\n\n```lua\nlocal mt = debug.getmetatable(obj) -- ignores __metatable\n```"
|
|
2463
|
+
},
|
|
2464
|
+
"insertText": "debug.getmetatable(${1:obj})",
|
|
2465
|
+
"insertTextRules": 4,
|
|
2466
|
+
"sortText": "05_debug_debug.getmetatable"
|
|
831
2467
|
},
|
|
832
2468
|
{
|
|
833
|
-
"label": "
|
|
834
|
-
"kind":
|
|
835
|
-
"detail": "
|
|
836
|
-
"documentation": {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
"
|
|
2469
|
+
"label": "debug.setmetatable",
|
|
2470
|
+
"kind": 15,
|
|
2471
|
+
"detail": "Set metatable on any value",
|
|
2472
|
+
"documentation": {
|
|
2473
|
+
"value": "Set metatable on any value.\n\n```lua\ndebug.setmetatable(obj, mt)\n```"
|
|
2474
|
+
},
|
|
2475
|
+
"insertText": "debug.setmetatable(${1:obj}, ${2:mt})",
|
|
2476
|
+
"insertTextRules": 4,
|
|
2477
|
+
"sortText": "05_debug_debug.setmetatable"
|
|
840
2478
|
},
|
|
841
2479
|
{
|
|
842
|
-
"label": "
|
|
843
|
-
"kind":
|
|
844
|
-
"detail": "
|
|
845
|
-
"documentation": {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
"
|
|
2480
|
+
"label": "debug.getuservalue",
|
|
2481
|
+
"kind": 15,
|
|
2482
|
+
"detail": "Get userdata value",
|
|
2483
|
+
"documentation": {
|
|
2484
|
+
"value": "Get userdata value.\n\n```lua\nlocal val = debug.getuservalue(ud, 1)\n```"
|
|
2485
|
+
},
|
|
2486
|
+
"insertText": "debug.getuservalue(${1:u}, ${2:n})",
|
|
2487
|
+
"insertTextRules": 4,
|
|
2488
|
+
"sortText": "05_debug_debug.getuservalue"
|
|
849
2489
|
},
|
|
850
2490
|
{
|
|
851
|
-
"label": "
|
|
852
|
-
"kind":
|
|
853
|
-
"detail": "
|
|
854
|
-
"documentation": {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
"
|
|
2491
|
+
"label": "debug.setuservalue",
|
|
2492
|
+
"kind": 15,
|
|
2493
|
+
"detail": "Set userdata value",
|
|
2494
|
+
"documentation": {
|
|
2495
|
+
"value": "Set userdata value.\n\n```lua\ndebug.setuservalue(ud, myvalue, 1)\n```"
|
|
2496
|
+
},
|
|
2497
|
+
"insertText": "debug.setuservalue(${1:u}, ${2:value}, ${3:n})",
|
|
2498
|
+
"insertTextRules": 4,
|
|
2499
|
+
"sortText": "05_debug_debug.setuservalue"
|
|
858
2500
|
},
|
|
859
2501
|
{
|
|
860
|
-
"label": "
|
|
2502
|
+
"label": "utf8.char",
|
|
861
2503
|
"kind": 15,
|
|
862
|
-
"detail": "
|
|
863
|
-
"documentation": {
|
|
864
|
-
|
|
2504
|
+
"detail": "Create UTF-8 string from codepoints",
|
|
2505
|
+
"documentation": {
|
|
2506
|
+
"value": "Create UTF-8 string from codepoints.\n\n```lua\nprint(utf8.char(72,233,108,108,244)) -- Héllô\n```"
|
|
2507
|
+
},
|
|
2508
|
+
"insertText": "utf8.char(${1:...})",
|
|
865
2509
|
"insertTextRules": 4,
|
|
866
|
-
"sortText": "
|
|
2510
|
+
"sortText": "05_utf8_utf8.char"
|
|
867
2511
|
},
|
|
868
2512
|
{
|
|
869
|
-
"label": "
|
|
2513
|
+
"label": "utf8.codepoint",
|
|
870
2514
|
"kind": 15,
|
|
871
|
-
"detail": "
|
|
872
|
-
"documentation": {
|
|
873
|
-
|
|
2515
|
+
"detail": "Get codepoints from UTF-8 string",
|
|
2516
|
+
"documentation": {
|
|
2517
|
+
"value": "Get codepoints from UTF-8 string.\n\n```lua\nprint(utf8.codepoint('é', 1, -1)) -- 233\n```"
|
|
2518
|
+
},
|
|
2519
|
+
"insertText": "utf8.codepoint(${1:s}, ${2:i}, ${3:j})",
|
|
874
2520
|
"insertTextRules": 4,
|
|
875
|
-
"sortText": "
|
|
2521
|
+
"sortText": "05_utf8_utf8.codepoint"
|
|
876
2522
|
},
|
|
877
2523
|
{
|
|
878
|
-
"label": "
|
|
2524
|
+
"label": "utf8.offset",
|
|
879
2525
|
"kind": 15,
|
|
880
|
-
"detail": "
|
|
881
|
-
"documentation": {
|
|
882
|
-
|
|
2526
|
+
"detail": "Get byte offset of nth character",
|
|
2527
|
+
"documentation": {
|
|
2528
|
+
"value": "Get byte offset of nth character.\n\n```lua\nlocal s = 'héllo'\nprint(utf8.offset(s, 3)) -- byte pos of 3rd char\n```"
|
|
2529
|
+
},
|
|
2530
|
+
"insertText": "utf8.offset(${1:s}, ${2:n}, ${3:i})",
|
|
883
2531
|
"insertTextRules": 4,
|
|
884
|
-
"sortText": "
|
|
2532
|
+
"sortText": "05_utf8_utf8.offset"
|
|
885
2533
|
},
|
|
886
2534
|
{
|
|
887
|
-
"label": "
|
|
2535
|
+
"label": "utf8.charpattern",
|
|
888
2536
|
"kind": 15,
|
|
889
|
-
"detail": "
|
|
890
|
-
"documentation": {
|
|
891
|
-
|
|
2537
|
+
"detail": "Pattern matching a single UTF-8 character",
|
|
2538
|
+
"documentation": {
|
|
2539
|
+
"value": "Pattern matching a single UTF-8 character.\n\n```lua\nfor c in string.gmatch(s, utf8.charpattern) do\n print(c)\nend\n```"
|
|
2540
|
+
},
|
|
2541
|
+
"insertText": "utf8.charpattern",
|
|
892
2542
|
"insertTextRules": 4,
|
|
893
|
-
"sortText": "
|
|
2543
|
+
"sortText": "05_utf8_utf8.charpattern"
|
|
894
2544
|
},
|
|
895
2545
|
{
|
|
896
|
-
"label": "
|
|
2546
|
+
"label": "package.path",
|
|
897
2547
|
"kind": 15,
|
|
898
|
-
"detail": "
|
|
899
|
-
"documentation": {
|
|
900
|
-
|
|
2548
|
+
"detail": "Lua module search path",
|
|
2549
|
+
"documentation": {
|
|
2550
|
+
"value": "Lua module search path.\n\n```lua\nprint(package.path)\npackage.path = package.path .. ';./libs/?.lua'\n```"
|
|
2551
|
+
},
|
|
2552
|
+
"insertText": "package.path",
|
|
901
2553
|
"insertTextRules": 4,
|
|
902
|
-
"sortText": "
|
|
2554
|
+
"sortText": "05_package_package.path"
|
|
903
2555
|
},
|
|
904
2556
|
{
|
|
905
|
-
"label": "
|
|
2557
|
+
"label": "package.cpath",
|
|
906
2558
|
"kind": 15,
|
|
907
|
-
"detail": "
|
|
908
|
-
"documentation": {
|
|
909
|
-
|
|
2559
|
+
"detail": "C module search path",
|
|
2560
|
+
"documentation": {
|
|
2561
|
+
"value": "C module search path.\n\n```lua\nprint(package.cpath)\npackage.cpath = package.cpath .. ';./libs/?.so'\n```"
|
|
2562
|
+
},
|
|
2563
|
+
"insertText": "package.cpath",
|
|
910
2564
|
"insertTextRules": 4,
|
|
911
|
-
"sortText": "
|
|
2565
|
+
"sortText": "05_package_package.cpath"
|
|
912
2566
|
},
|
|
913
2567
|
{
|
|
914
|
-
"label": "
|
|
2568
|
+
"label": "package.loaded",
|
|
915
2569
|
"kind": 15,
|
|
916
|
-
"detail": "
|
|
917
|
-
"documentation": {
|
|
918
|
-
|
|
2570
|
+
"detail": "Table of loaded modules",
|
|
2571
|
+
"documentation": {
|
|
2572
|
+
"value": "Table of loaded modules.\n\n```lua\n-- Check if a module is loaded\nif package.loaded['socket'] then\n print('socket loaded')\nend\n-- Force re-require\npackage.loaded['mymod'] = nil\nrequire('mymod')\n```"
|
|
2573
|
+
},
|
|
2574
|
+
"insertText": "package.loaded",
|
|
919
2575
|
"insertTextRules": 4,
|
|
920
|
-
"sortText": "
|
|
2576
|
+
"sortText": "05_package_package.loaded"
|
|
921
2577
|
},
|
|
922
2578
|
{
|
|
923
|
-
"label": "
|
|
2579
|
+
"label": "package.preload",
|
|
924
2580
|
"kind": 15,
|
|
925
|
-
"detail": "
|
|
926
|
-
"documentation": {
|
|
927
|
-
|
|
2581
|
+
"detail": "Table of module loaders",
|
|
2582
|
+
"documentation": {
|
|
2583
|
+
"value": "Table of module loaders.\n\n```lua\npackage.preload['mymod'] = function()\n return { hello = function() print('hi') end }\nend\n```"
|
|
2584
|
+
},
|
|
2585
|
+
"insertText": "package.preload",
|
|
928
2586
|
"insertTextRules": 4,
|
|
929
|
-
"sortText": "
|
|
2587
|
+
"sortText": "05_package_package.preload"
|
|
930
2588
|
},
|
|
931
2589
|
{
|
|
932
|
-
"label": "
|
|
2590
|
+
"label": "package.searchers",
|
|
933
2591
|
"kind": 15,
|
|
934
|
-
"detail": "
|
|
935
|
-
"documentation": {
|
|
936
|
-
|
|
2592
|
+
"detail": "Table of module searcher functions",
|
|
2593
|
+
"documentation": {
|
|
2594
|
+
"value": "Table of module searcher functions.\n\n```lua\n-- Add custom searcher\ntable.insert(package.searchers, 2, function(name)\n -- custom logic\nend)\n```"
|
|
2595
|
+
},
|
|
2596
|
+
"insertText": "package.searchers",
|
|
937
2597
|
"insertTextRules": 4,
|
|
938
|
-
"sortText": "
|
|
2598
|
+
"sortText": "05_package_package.searchers"
|
|
939
2599
|
},
|
|
940
2600
|
{
|
|
941
|
-
"label": "
|
|
2601
|
+
"label": "package.searchpath",
|
|
942
2602
|
"kind": 15,
|
|
943
|
-
"detail": "
|
|
944
|
-
"documentation": {
|
|
945
|
-
|
|
2603
|
+
"detail": "Search for file in path",
|
|
2604
|
+
"documentation": {
|
|
2605
|
+
"value": "Search for file in path.\n\n```lua\nlocal file = package.searchpath('socket', package.path)\nprint(file) -- /usr/local/share/lua/5.4/socket.lua\n```"
|
|
2606
|
+
},
|
|
2607
|
+
"insertText": "package.searchpath(${1:name}, ${2:path})",
|
|
946
2608
|
"insertTextRules": 4,
|
|
947
|
-
"sortText": "
|
|
2609
|
+
"sortText": "05_package_package.searchpath"
|
|
948
2610
|
},
|
|
949
2611
|
{
|
|
950
|
-
"label": "
|
|
2612
|
+
"label": "package.config",
|
|
951
2613
|
"kind": 15,
|
|
952
|
-
"detail": "
|
|
953
|
-
"documentation": {
|
|
954
|
-
|
|
2614
|
+
"detail": "Path configuration string",
|
|
2615
|
+
"documentation": {
|
|
2616
|
+
"value": "Path configuration string.\n\n```lua\n-- First char: dir separator\n-- Second char: path separator\nprint(package.config:sub(1,1)) -- '/' or '\\\\'\n```"
|
|
2617
|
+
},
|
|
2618
|
+
"insertText": "package.config",
|
|
955
2619
|
"insertTextRules": 4,
|
|
956
|
-
"sortText": "
|
|
2620
|
+
"sortText": "05_package_package.config"
|
|
957
2621
|
},
|
|
958
2622
|
{
|
|
959
|
-
"label": "
|
|
2623
|
+
"label": "local close",
|
|
960
2624
|
"kind": 15,
|
|
961
|
-
"detail": "
|
|
962
|
-
"documentation": {
|
|
963
|
-
|
|
2625
|
+
"detail": "To-be-closed variable (Lua 5.4)",
|
|
2626
|
+
"documentation": {
|
|
2627
|
+
"value": "To-be-closed variable with automatic cleanup.\n\n```lua\nlocal f <close> = io.open('file.txt')\n-- f:close() called automatically when f goes out of scope\n```"
|
|
2628
|
+
},
|
|
2629
|
+
"insertText": "local ${1:var} <close> = ${0}",
|
|
964
2630
|
"insertTextRules": 4,
|
|
965
|
-
"sortText": "
|
|
2631
|
+
"sortText": "02_local_close"
|
|
966
2632
|
}
|
|
967
2633
|
]
|
|
968
|
-
}
|
|
2634
|
+
}
|