@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.
@@ -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": { "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```" },
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": { "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\"\nprint(type(nil)) -- \"nil\"\n```" },
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": "Convert a value to a string",
26
- "documentation": { "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 with the value as argument.\n\n```lua\ntostring(123) -- \"123\"\ntostring(true) -- \"true\"\ntostring(nil) -- \"nil\"\n```" },
27
- "insertText": "tostring(${1:v})",
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": "00_tostring"
1333
+ "sortText": "00_rawlen"
30
1334
  },
31
1335
  {
32
- "label": "tonumber",
1336
+ "label": "setmetatable",
33
1337
  "kind": 1,
34
- "detail": "Convert a value to a number",
35
- "documentation": { "value": "Tries to convert its argument to a number. If the argument is already a number or a convertible string, returns the number; otherwise returns `nil`. An optional base (2–36) specifies the base for interpretation.\n\n```lua\ntonumber(\"42\") -- 42\ntonumber(\"0xff\") -- 255\ntonumber(\"1010\", 2) -- 10\n```" },
36
- "insertText": "tonumber(${1:e}${2:, ${3:base}})",
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": "00_tonumber"
1344
+ "sortText": "00_setmetatable"
39
1345
  },
40
1346
  {
41
- "label": "pairs",
1347
+ "label": "getmetatable",
42
1348
  "kind": 1,
43
- "detail": "Iterate over all key-value pairs in a table",
44
- "documentation": { "value": "Returns an iterator function, the table, and `nil`, so that the construction `for k, v in pairs(t) do ... end` iterates over all key–value pairs of table `t`.\n\n```lua\nfor k, v in pairs(myTable) do\n print(k, v)\nend\n```" },
45
- "insertText": "pairs(${1:t})",
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": "00_pairs"
1355
+ "sortText": "00_getmetatable"
48
1356
  },
49
1357
  {
50
- "label": "ipairs",
1358
+ "label": "require",
51
1359
  "kind": 1,
52
- "detail": "Iterate over integer-keyed elements of a table",
53
- "documentation": { "value": "Returns an iterator function, the table, and `0`, so that the construction `for i, v in ipairs(t) do ... end` iterates over the integer keys 1, 2, ... of table `t`.\n\n```lua\nlocal fruits = {\"apple\", \"banana\", \"cherry\"}\nfor i, v in ipairs(fruits) do\n print(i, v)\nend\n```" },
54
- "insertText": "ipairs(${1:t})",
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": "00_ipairs"
1366
+ "sortText": "00_require"
57
1367
  },
58
1368
  {
59
- "label": "next",
1369
+ "label": "dofile",
60
1370
  "kind": 1,
61
- "detail": "Get next key-value pair from a table",
62
- "documentation": { "value": "Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index. Returns the next index and its value. When called with `nil` as second argument, returns the first index.\n\n```lua\nlocal k, v = next(t) -- first pair\nlocal k2, v2 = next(t, k) -- next pair\n```" },
63
- "insertText": "next(${1:table}${2:, ${3:index}})",
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": "00_next"
1377
+ "sortText": "00_dofile"
66
1378
  },
67
1379
  {
68
- "label": "select",
1380
+ "label": "loadfile",
69
1381
  "kind": 1,
70
- "detail": "Select from argument list",
71
- "documentation": { "value": "If `index` is a number, returns all arguments after argument number `index`. If `index` is `\"#\"`, returns the total number of extra arguments received.\n\n```lua\nselect(2, \"a\", \"b\", \"c\") -- \"b\", \"c\"\nselect(\"#\", \"a\", \"b\", \"c\") -- 3\n```" },
72
- "insertText": "select(${1:index}, ${2:...})",
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": "00_select"
1388
+ "sortText": "00_loadfile"
75
1389
  },
76
1390
  {
77
- "label": "unpack",
1391
+ "label": "load",
78
1392
  "kind": 1,
79
- "detail": "Unpack elements from a table (Lua 5.1/LuaJIT)",
80
- "documentation": { "value": "Returns the elements from the given list. In Lua 5.1 and LuaJIT this is a global function. In Lua 5.2+ it has been moved to `table.unpack`.\n\n```lua\nlocal a, b, c = unpack({10, 20, 30})\n-- a=10, b=20, c=30\n```\n\n**Note:** Use `table.unpack` in Lua 5.2+." },
81
- "insertText": "unpack(${1:list}${2:, ${3:i}${4:, ${5:j}}})",
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": "00_unpack"
1399
+ "sortText": "00_load"
84
1400
  },
85
1401
  {
86
1402
  "label": "pcall",
87
1403
  "kind": 1,
88
- "detail": "Protected call — catch errors",
89
- "documentation": { "value": "Calls function `f` with the given arguments in protected mode. If there are no errors, returns `true` plus results. If there is an error, returns `false` plus the error object.\n\n```lua\nlocal ok, result = pcall(function()\n return riskyOperation()\nend)\nif not ok then\n print(\"Error:\", result)\nend\n```" },
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": "Protected call with error handler",
98
- "documentation": { "value": "Similar to `pcall`, but sets a message handler `msgh` for errors. Any error inside `f` is not propagated; instead, `xpcall` catches the error, calls `msgh` with the original error, and returns the status code plus the result from `msgh`.\n\n```lua\nlocal ok, result = xpcall(riskyFunc, function(err)\n return debug.traceback(err, 2)\nend)\n```\n\n**Note:** In Lua 5.1, `xpcall` does not accept arguments for the called function. Lua 5.2+ and LuaJIT 2.1 support extra arguments." },
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": { "value": "Raises an error with `message` as the error object. `level` specifies where the error points (1 = current function, 2 = caller, etc., 0 = no position info).\n\n```lua\nerror(\"something went wrong\")\nerror(\"invalid argument\", 2)\nerror({code = 404, msg = \"not found\"})\n```" },
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, raising error if false/nil",
116
- "documentation": { "value": "Calls `error` if the value of its argument `v` is false (i.e., `nil` or `false`); otherwise returns all its arguments.\n\n```lua\nassert(type(x) == \"number\", \"x must be a number\")\nlocal f = assert(io.open(filename, \"r\"))\n```" },
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": "require",
1446
+ "label": "collectgarbage",
123
1447
  "kind": 1,
124
- "detail": "Load a module",
125
- "documentation": { "value": "Loads the given module. Searches for a loader using `package.searchers` (Lua 5.2+) or `package.loaders` (Lua 5.1). Caches results in `package.loaded`.\n\n```lua\nlocal json = require(\"cjson\")\nlocal utils = require(\"mylib.utils\")\n```" },
126
- "insertText": "require(\"${1:modname}\")",
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": "00_require"
1454
+ "sortText": "00_collectgarbage"
129
1455
  },
130
1456
  {
131
- "label": "dofile",
1457
+ "label": "unpack",
132
1458
  "kind": 1,
133
- "detail": "Execute a Lua file",
134
- "documentation": { "value": "Opens the named file and executes its contents as a Lua chunk. Returns any values returned by the chunk. In case of errors, propagates them to the caller.\n\n```lua\ndofile(\"config.lua\")\nlocal result = dofile(\"script.lua\")\n```" },
135
- "insertText": "dofile(\"${1:filename}\")",
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": "00_dofile"
1465
+ "sortText": "00_unpack"
138
1466
  },
139
1467
  {
140
- "label": "loadfile",
141
- "kind": 1,
142
- "detail": "Load a Lua file as a chunk without executing",
143
- "documentation": { "value": "Loads a chunk from file `filename` without running it. Returns the compiled chunk as a function, or `nil` plus error message on failure.\n\n```lua\nlocal chunk, err = loadfile(\"script.lua\")\nif chunk then chunk() end\n```\n\n**Lua 5.2+:** Accepts optional `mode` and `env` parameters." },
144
- "insertText": "loadfile(\"${1:filename}\")",
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": "00_loadfile"
1476
+ "sortText": "00_kw_and"
147
1477
  },
148
1478
  {
149
- "label": "load",
150
- "kind": 1,
151
- "detail": "Load a chunk from a string or function",
152
- "documentation": { "value": "Loads a chunk. If `chunk` is a string, loads that string. If it is a function, calls it repeatedly to get pieces. Returns the compiled chunk as a function.\n\n```lua\nlocal fn = load(\"return 2 + 2\")\nprint(fn()) -- 4\n```\n\n**Lua 5.1:** Use `loadstring` for strings. Lua 5.2+ unified into `load`." },
153
- "insertText": "load(${1:chunk}${2:, ${3:chunkname}${4:, ${5:mode}${6:, ${7:env}}}})",
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": "00_load"
1487
+ "sortText": "00_kw_break"
156
1488
  },
157
1489
  {
158
- "label": "rawget",
159
- "kind": 1,
160
- "detail": "Get a table value without invoking metamethods",
161
- "documentation": { "value": "Gets the real value of `table[index]` without invoking the `__index` metamethod.\n\n```lua\nlocal v = rawget(t, \"key\")\n```" },
162
- "insertText": "rawget(${1:table}, ${2:index})",
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": "00_rawget"
1498
+ "sortText": "00_kw_do"
165
1499
  },
166
1500
  {
167
- "label": "rawset",
168
- "kind": 1,
169
- "detail": "Set a table value without invoking metamethods",
170
- "documentation": { "value": "Sets the real value of `table[index]` to `value` without invoking the `__newindex` metamethod. Returns `table`.\n\n```lua\nrawset(t, \"key\", 42)\n```" },
171
- "insertText": "rawset(${1:table}, ${2:index}, ${3:value})",
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": "00_rawset"
1509
+ "sortText": "00_kw_else"
174
1510
  },
175
1511
  {
176
- "label": "rawequal",
177
- "kind": 1,
178
- "detail": "Check equality without invoking metamethods",
179
- "documentation": { "value": "Checks whether `v1` is equal to `v2`, without invoking the `__eq` metamethod.\n\n```lua\nrawequal(a, b)\n```" },
180
- "insertText": "rawequal(${1:v1}, ${2:v2})",
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": "00_rawequal"
1520
+ "sortText": "00_kw_elseif"
183
1521
  },
184
1522
  {
185
- "label": "rawlen",
186
- "kind": 1,
187
- "detail": "Get length without invoking metamethods (Lua 5.2+)",
188
- "documentation": { "value": "Returns the length of the object `v`, which must be a table or a string, without invoking the `__len` metamethod.\n\n```lua\nlocal n = rawlen(t)\n```\n\n**Note:** Available in Lua 5.2+ only. Not available in Lua 5.1 or LuaJIT (unless patched)." },
189
- "insertText": "rawlen(${1:v})",
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": "00_rawlen"
1531
+ "sortText": "00_kw_end"
192
1532
  },
193
1533
  {
194
- "label": "setmetatable",
195
- "kind": 1,
196
- "detail": "Set the metatable for a table",
197
- "documentation": { "value": "Sets the metatable for the given table. If `metatable` is `nil`, removes the metatable. If the original metatable has a `__metatable` field, raises an error. Returns `table`.\n\n```lua\nlocal mt = { __index = baseClass }\nsetmetatable(obj, mt)\n```" },
198
- "insertText": "setmetatable(${1:table}, ${2:metatable})",
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": "00_setmetatable"
1542
+ "sortText": "00_kw_false"
201
1543
  },
202
1544
  {
203
- "label": "getmetatable",
204
- "kind": 1,
205
- "detail": "Get the metatable of an object",
206
- "documentation": { "value": "Returns the metatable of the given object, or `nil` if it does not have one. If the metatable has a `__metatable` field, returns that value instead.\n\n```lua\nlocal mt = getmetatable(obj)\n```" },
207
- "insertText": "getmetatable(${1:object})",
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": "00_getmetatable"
1553
+ "sortText": "00_kw_for"
210
1554
  },
211
1555
  {
212
- "label": "collectgarbage",
213
- "kind": 1,
214
- "detail": "Control the garbage collector",
215
- "documentation": { "value": "Generic interface to the garbage collector. Performs different functions depending on `opt`: `\"collect\"`, `\"stop\"`, `\"restart\"`, `\"count\"`, `\"step\"`, `\"isrunning\"`, `\"incremental\"`, `\"generational\"`.\n\n```lua\ncollectgarbage(\"collect\")\nlocal kb = collectgarbage(\"count\")\n```\n\n**Lua 5.4:** Added `\"incremental\"` and `\"generational\"` options." },
216
- "insertText": "collectgarbage(\"${1:opt}\"${2:, ${3:arg}})",
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": "00_collectgarbage"
1564
+ "sortText": "00_kw_function"
219
1565
  },
220
1566
  {
221
- "label": "string.format",
222
- "kind": 1,
223
- "detail": "Format a string",
224
- "documentation": { "value": "Returns a formatted version of its variable number of arguments following the description given in `formatstring`. Similar to C `sprintf`.\n\n```lua\nstring.format(\"%s is %d years old\", name, age)\nstring.format(\"%02x\", 255) -- \"ff\"\nstring.format(\"%.2f\", 3.14159) -- \"3.14\"\n```" },
225
- "insertText": "string.format(\"${1:fmt}\", ${2:args})",
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": "01_string.format"
1575
+ "sortText": "00_kw_goto"
228
1576
  },
229
1577
  {
230
- "label": "string.find",
231
- "kind": 1,
232
- "detail": "Find a pattern in a string",
233
- "documentation": { "value": "Looks for the first match of `pattern` in `s`. Returns the start and end indices of the match, plus any captures. Returns `nil` if no match.\n\n```lua\nlocal i, j = string.find(\"hello world\", \"world\") -- 7, 11\nlocal s, e, cap = string.find(\"abc123\", \"(%d+)\") -- 4, 6, \"123\"\n```" },
234
- "insertText": "string.find(${1:s}, \"${2:pattern}\"${3:, ${4:init}${5:, ${6:plain}}})",
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": "01_string.find"
1586
+ "sortText": "00_kw_if"
237
1587
  },
238
1588
  {
239
- "label": "string.match",
240
- "kind": 1,
241
- "detail": "Extract pattern matches from a string",
242
- "documentation": { "value": "Looks for the first match of `pattern` in `s`. Returns the captures, or the whole match if no captures. Returns `nil` if no match.\n\n```lua\nlocal year, month, day = string.match(\"2026-03-03\", \"(%d+)-(%d+)-(%d+)\")\nlocal word = string.match(\"hello world\", \"%a+\") -- \"hello\"\n```" },
243
- "insertText": "string.match(${1:s}, \"${2:pattern}\"${3:, ${4:init}})",
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": "01_string.match"
1597
+ "sortText": "00_kw_in"
246
1598
  },
247
1599
  {
248
- "label": "string.gmatch",
249
- "kind": 1,
250
- "detail": "Iterate over all pattern matches",
251
- "documentation": { "value": "Returns an iterator function that each time returns the next captures from `pattern` over the string `s`.\n\n```lua\nfor word in string.gmatch(\"Hello Lua World\", \"%a+\") do\n print(word)\nend\nfor k, v in string.gmatch(s, \"(%w+)=(%w+)\") do\n t[k] = v\nend\n```" },
252
- "insertText": "string.gmatch(${1:s}, \"${2:pattern}\")",
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": "01_string.gmatch"
1608
+ "sortText": "00_kw_local"
255
1609
  },
256
1610
  {
257
- "label": "string.gsub",
258
- "kind": 1,
259
- "detail": "Global substitution — replace pattern matches",
260
- "documentation": { "value": "Returns a copy of `s` in which all (or the first `n`) occurrences of `pattern` have been replaced. `repl` can be a string, table, or function. Returns the result string and the number of substitutions.\n\n```lua\nstring.gsub(\"hello world\", \"(%w+)\", string.upper) -- \"HELLO WORLD\"\nstring.gsub(\"abc\", \"b\", \"B\") -- \"aBc\"\n```" },
261
- "insertText": "string.gsub(${1:s}, \"${2:pattern}\", ${3:repl}${4:, ${5:n}})",
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": "01_string.gsub"
1619
+ "sortText": "00_kw_nil"
264
1620
  },
265
1621
  {
266
- "label": "string.sub",
267
- "kind": 1,
268
- "detail": "Extract a substring",
269
- "documentation": { "value": "Returns the substring of `s` that starts at `i` and continues until `j` (inclusive). Negative indices count from the end.\n\n```lua\nstring.sub(\"Hello\", 2, 4) -- \"ell\"\nstring.sub(\"Hello\", -3) -- \"llo\"\n```" },
270
- "insertText": "string.sub(${1:s}, ${2:i}${3:, ${4:j}})",
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": "01_string.sub"
1630
+ "sortText": "00_kw_not"
273
1631
  },
274
1632
  {
275
- "label": "string.rep",
276
- "kind": 1,
277
- "detail": "Repeat a string",
278
- "documentation": { "value": "Returns a string that is the concatenation of `n` copies of `s`, separated by `sep` (Lua 5.2+).\n\n```lua\nstring.rep(\"ab\", 3) -- \"ababab\"\nstring.rep(\"ab\", 3, \",\") -- \"ab,ab,ab\" (Lua 5.2+)\n```" },
279
- "insertText": "string.rep(${1:s}, ${2:n}${3:, ${4:sep}})",
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": "01_string.rep"
1641
+ "sortText": "00_kw_or"
282
1642
  },
283
1643
  {
284
- "label": "string.reverse",
285
- "kind": 1,
286
- "detail": "Reverse a string",
287
- "documentation": { "value": "Returns a string that is the reverse of `s`.\n\n```lua\nstring.reverse(\"hello\") -- \"olleh\"\n```" },
288
- "insertText": "string.reverse(${1:s})",
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": "01_string.reverse"
1652
+ "sortText": "00_kw_repeat"
291
1653
  },
292
1654
  {
293
- "label": "string.upper",
294
- "kind": 1,
295
- "detail": "Convert string to uppercase",
296
- "documentation": { "value": "Returns a copy of `s` with all lowercase letters changed to uppercase. The definition of what a lowercase letter is depends on the current locale.\n\n```lua\nstring.upper(\"hello\") -- \"HELLO\"\n```" },
297
- "insertText": "string.upper(${1:s})",
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": "01_string.upper"
1663
+ "sortText": "00_kw_return"
300
1664
  },
301
1665
  {
302
- "label": "string.lower",
303
- "kind": 1,
304
- "detail": "Convert string to lowercase",
305
- "documentation": { "value": "Returns a copy of `s` with all uppercase letters changed to lowercase.\n\n```lua\nstring.lower(\"HELLO\") -- \"hello\"\n```" },
306
- "insertText": "string.lower(${1:s})",
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": "01_string.lower"
1674
+ "sortText": "00_kw_then"
309
1675
  },
310
1676
  {
311
- "label": "string.len",
312
- "kind": 1,
313
- "detail": "Get string length",
314
- "documentation": { "value": "Returns the length of the string `s`. The empty string has length 0. Embedded zeros are counted.\n\n```lua\nstring.len(\"hello\") -- 5\n(\"hello\"):len() -- 5\n#\"hello\" -- 5 (idiomatic)\n```" },
315
- "insertText": "string.len(${1:s})",
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": "01_string.len"
1685
+ "sortText": "00_kw_true"
318
1686
  },
319
1687
  {
320
- "label": "string.byte",
321
- "kind": 1,
322
- "detail": "Get numeric byte values of characters",
323
- "documentation": { "value": "Returns the internal numeric codes of the characters `s[i]` through `s[j]`.\n\n```lua\nstring.byte(\"A\") -- 65\nstring.byte(\"ABC\", 1, 3) -- 65, 66, 67\n```" },
324
- "insertText": "string.byte(${1:s}${2:, ${3:i}${4:, ${5:j}}})",
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": "01_string.byte"
1696
+ "sortText": "00_kw_until"
327
1697
  },
328
1698
  {
329
- "label": "string.char",
330
- "kind": 1,
331
- "detail": "Convert numeric codes to a string",
332
- "documentation": { "value": "Returns a string with characters having the internal numeric codes equal to the arguments.\n\n```lua\nstring.char(65, 66, 67) -- \"ABC\"\nstring.char(72, 101, 108, 108, 111) -- \"Hello\"\n```" },
333
- "insertText": "string.char(${1:...})",
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": "01_string.char"
1707
+ "sortText": "00_kw_while"
336
1708
  },
337
1709
  {
338
- "label": "string.dump",
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": "Dump a function as binary string",
341
- "documentation": { "value": "Returns a string containing a binary representation of the given function, so that a later `load` can return a copy of the function. The function must be a Lua function without upvalues.\n\n```lua\nlocal s = string.dump(function() return 42 end)\nlocal f = load(s)\nprint(f()) -- 42\n```\n\n**Lua 5.3+:** Optional `strip` parameter to strip debug info." },
342
- "insertText": "string.dump(${1:function}${2:, ${3:strip}})",
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": "01_string.dump"
1916
+ "sortText": "04_metatable___metatable"
345
1917
  },
346
1918
  {
347
1919
  "label": "table.insert",
348
- "kind": 1,
349
- "detail": "Insert an element into a table",
350
- "documentation": { "value": "Inserts element `value` at position `pos` in `list`, shifting up other elements. The default value for `pos` is `#list+1` (append).\n\n```lua\nlocal t = {1, 2, 3}\ntable.insert(t, 4) -- {1, 2, 3, 4}\ntable.insert(t, 2, 10) -- {1, 10, 2, 3, 4}\n```" },
351
- "insertText": "table.insert(${1:list}, ${2:value})",
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": "02_table.insert"
1927
+ "sortText": "05_table_table.insert"
354
1928
  },
355
1929
  {
356
1930
  "label": "table.remove",
357
- "kind": 1,
358
- "detail": "Remove an element from a table",
359
- "documentation": { "value": "Removes from `list` the element at position `pos`, returning the removed value. Default `pos` is `#list` (last element).\n\n```lua\nlocal t = {1, 2, 3, 4}\nlocal v = table.remove(t) -- v=4, t={1,2,3}\nlocal w = table.remove(t, 1) -- w=1, t={2,3}\n```" },
360
- "insertText": "table.remove(${1:list}${2:, ${3:pos}})",
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": "02_table.remove"
1938
+ "sortText": "05_table_table.remove"
363
1939
  },
364
1940
  {
365
1941
  "label": "table.sort",
366
- "kind": 1,
367
- "detail": "Sort a table in-place",
368
- "documentation": { "value": "Sorts the list elements in-place, from `list[1]` to `list[#list]`. An optional comparison function `comp` can be provided.\n\n```lua\nlocal t = {3, 1, 4, 1, 5}\ntable.sort(t) -- {1, 1, 3, 4, 5}\ntable.sort(t, function(a, b) return a > b end) -- descending\n```" },
369
- "insertText": "table.sort(${1:list}${2:, ${3:comp}})",
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": "02_table.sort"
1949
+ "sortText": "05_table_table.sort"
372
1950
  },
373
1951
  {
374
1952
  "label": "table.concat",
375
- "kind": 1,
376
- "detail": "Concatenate table elements into a string",
377
- "documentation": { "value": "Returns a string made by concatenating `list[i]..list[j]` with `sep` between each element.\n\n```lua\nlocal t = {\"Hello\", \"Lua\", \"World\"}\ntable.concat(t, \" \") -- \"Hello Lua World\"\ntable.concat(t, \", \", 2) -- \"Lua, World\"\n```" },
378
- "insertText": "table.concat(${1:list}${2:, ${3:sep}${4:, ${5:i}${6:, ${7:j}}}})",
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": "02_table.concat"
1960
+ "sortText": "05_table_table.concat"
381
1961
  },
382
1962
  {
383
1963
  "label": "table.move",
384
- "kind": 1,
385
- "detail": "Move elements within or between tables (Lua 5.3+)",
386
- "documentation": { "value": "Moves elements from table `a1` to table `a2`. Equivalent to `a2[t], ... = a1[f], ..., a1[e]` with appropriate destination indexing. Returns `a2`.\n\n```lua\nlocal t = {1, 2, 3, 4, 5}\ntable.move(t, 3, 5, 1) -- {3, 4, 5, 4, 5}\n```\n\n**Note:** Available in Lua 5.3+ only." },
387
- "insertText": "table.move(${1:a1}, ${2:f}, ${3:e}, ${4:t}${5:, ${6:a2}})",
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": "02_table.move"
1971
+ "sortText": "05_table_table.move"
390
1972
  },
391
1973
  {
392
1974
  "label": "table.pack",
393
- "kind": 1,
394
- "detail": "Pack arguments into a table (Lua 5.2+)",
395
- "documentation": { "value": "Returns a new table with all arguments stored at numeric keys and a field `n` with the total number of arguments.\n\n```lua\nlocal t = table.pack(1, 2, nil, 4)\nprint(t.n) -- 4\n```\n\n**Note:** Available in Lua 5.2+ and LuaJIT with compatibility flag." },
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": "02_table.pack"
1982
+ "sortText": "05_table_table.pack"
399
1983
  },
400
1984
  {
401
1985
  "label": "table.unpack",
402
- "kind": 1,
403
- "detail": "Unpack elements from a table (Lua 5.2+)",
404
- "documentation": { "value": "Returns the elements from the given table. Equivalent to `return list[i], list[i+1], ..., list[j]`.\n\n```lua\nlocal a, b, c = table.unpack({10, 20, 30})\n```\n\n**Note:** In Lua 5.1 this is the global `unpack` function." },
405
- "insertText": "table.unpack(${1:list}${2:, ${3:i}${4:, ${5:j}}})",
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": "02_table.unpack"
1993
+ "sortText": "05_table_table.unpack"
408
1994
  },
409
1995
  {
410
- "label": "math.abs",
411
- "kind": 1,
412
- "detail": "Absolute value",
413
- "documentation": { "value": "Returns the absolute value of `x`.\n\n```lua\nmath.abs(-42) -- 42\nmath.abs(3.14) -- 3.14\n```" },
414
- "insertText": "math.abs(${1:x})",
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": "03_math.abs"
2004
+ "sortText": "05_string_string.sub"
417
2005
  },
418
2006
  {
419
- "label": "math.ceil",
420
- "kind": 1,
421
- "detail": "Round up to nearest integer",
422
- "documentation": { "value": "Returns the smallest integral value greater than or equal to `x`.\n\n```lua\nmath.ceil(4.2) -- 5\nmath.ceil(-4.8) -- -4\n```" },
423
- "insertText": "math.ceil(${1:x})",
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": "03_math.ceil"
2015
+ "sortText": "05_string_string.rep"
426
2016
  },
427
2017
  {
428
- "label": "math.floor",
429
- "kind": 1,
430
- "detail": "Round down to nearest integer",
431
- "documentation": { "value": "Returns the largest integral value less than or equal to `x`.\n\n```lua\nmath.floor(4.8) -- 4\nmath.floor(-4.2) -- -5\n```" },
432
- "insertText": "math.floor(${1:x})",
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": "03_math.floor"
2026
+ "sortText": "05_string_string.reverse"
435
2027
  },
436
2028
  {
437
- "label": "math.max",
438
- "kind": 1,
439
- "detail": "Return the maximum value",
440
- "documentation": { "value": "Returns the argument with the maximum value, according to the Lua `<` operator.\n\n```lua\nmath.max(1, 5, 3) -- 5\n```" },
441
- "insertText": "math.max(${1:x}, ${2:...})",
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": "03_math.max"
2037
+ "sortText": "05_string_string.upper"
444
2038
  },
445
2039
  {
446
- "label": "math.min",
447
- "kind": 1,
448
- "detail": "Return the minimum value",
449
- "documentation": { "value": "Returns the argument with the minimum value, according to the Lua `<` operator.\n\n```lua\nmath.min(1, 5, 3) -- 1\n```" },
450
- "insertText": "math.min(${1:x}, ${2:...})",
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": "03_math.min"
2048
+ "sortText": "05_string_string.lower"
453
2049
  },
454
2050
  {
455
- "label": "math.sqrt",
456
- "kind": 1,
457
- "detail": "Square root",
458
- "documentation": { "value": "Returns the square root of `x`. Equivalent to `x^0.5`.\n\n```lua\nmath.sqrt(144) -- 12.0\nmath.sqrt(2) -- 1.4142135623731\n```" },
459
- "insertText": "math.sqrt(${1:x})",
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": "03_math.sqrt"
2059
+ "sortText": "05_string_string.len"
462
2060
  },
463
2061
  {
464
- "label": "math.random",
465
- "kind": 1,
466
- "detail": "Generate a pseudo-random number",
467
- "documentation": { "value": "When called without arguments, returns a uniform pseudo-random real in [0,1). With `m`, returns integer in [1,m]. With `m` and `n`, returns integer in [m,n].\n\n```lua\nmath.random() -- 0.0 to 1.0\nmath.random(6) -- 1 to 6\nmath.random(1, 100) -- 1 to 100\n```\n\n**Lua 5.4:** Uses xoshiro256** algorithm. Older versions use C `rand()`." },
468
- "insertText": "math.random(${1:m}${2:, ${3:n}})",
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": "03_math.random"
2070
+ "sortText": "05_string_string.byte"
471
2071
  },
472
2072
  {
473
- "label": "math.randomseed",
474
- "kind": 1,
475
- "detail": "Set random seed",
476
- "documentation": { "value": "Sets `x` as the seed for the pseudo-random generator.\n\n```lua\nmath.randomseed(os.time())\n```\n\n**Lua 5.4:** If called without arguments, seeds with a system-dependent somewhat-random value." },
477
- "insertText": "math.randomseed(${1:x})",
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": "03_math.randomseed"
2114
+ "sortText": "05_math_math.abs"
480
2115
  },
481
2116
  {
482
- "label": "math.huge",
483
- "kind": 5,
484
- "detail": "Positive infinity",
485
- "documentation": { "value": "The float value `HUGE_VAL`, a value greater than any other numeric value (positive infinity).\n\n```lua\nprint(math.huge) -- inf\nprint(-math.huge) -- -inf\nprint(1 / 0 == math.huge) -- true\n```" },
486
- "insertText": "math.huge",
487
- "insertTextRules": 0,
488
- "sortText": "03_math.huge"
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.pi",
492
- "kind": 5,
493
- "detail": "The value of π",
494
- "documentation": { "value": "The value of π (3.14159265358979...).\n\n```lua\nprint(math.pi) -- 3.1415926535898\nlocal circumference = 2 * math.pi * radius\n```" },
495
- "insertText": "math.pi",
496
- "insertTextRules": 0,
497
- "sortText": "03_math.pi"
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": 1,
2140
+ "kind": 15,
502
2141
  "detail": "Sine (radians)",
503
- "documentation": { "value": "Returns the sine of `x` (assumed to be in radians).\n\n```lua\nmath.sin(0) -- 0.0\nmath.sin(math.pi/2) -- 1.0\n```" },
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": "03_math.sin"
2147
+ "sortText": "05_math_math.sin"
507
2148
  },
508
2149
  {
509
2150
  "label": "math.cos",
510
- "kind": 1,
2151
+ "kind": 15,
511
2152
  "detail": "Cosine (radians)",
512
- "documentation": { "value": "Returns the cosine of `x` (assumed to be in radians).\n\n```lua\nmath.cos(0) -- 1.0\nmath.cos(math.pi) -- -1.0\n```" },
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": "03_math.cos"
2158
+ "sortText": "05_math_math.cos"
516
2159
  },
517
2160
  {
518
- "label": "math.log",
519
- "kind": 1,
520
- "detail": "Logarithm",
521
- "documentation": { "value": "Returns the logarithm of `x` in the given base. The default for `base` is `e` (natural logarithm).\n\n```lua\nmath.log(math.exp(1)) -- 1.0\nmath.log(1000, 10) -- 3.0 (Lua 5.2+ base parameter)\n```\n\n**Lua 5.1:** Use `math.log10` for base-10. Lua 5.2+ accepts optional base." },
522
- "insertText": "math.log(${1:x}${2:, ${3:base}})",
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": "03_math.log"
2169
+ "sortText": "05_math_math.tan"
525
2170
  },
526
2171
  {
527
2172
  "label": "math.exp",
528
- "kind": 1,
529
- "detail": "Exponential function (e^x)",
530
- "documentation": { "value": "Returns the value e^x (where `e` is the base of natural logarithms).\n\n```lua\nmath.exp(0) -- 1.0\nmath.exp(1) -- 2.718281828...\n```" },
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": "03_math.exp"
2180
+ "sortText": "05_math_math.exp"
534
2181
  },
535
2182
  {
536
- "label": "io.open",
537
- "kind": 1,
538
- "detail": "Open a file",
539
- "documentation": { "value": "Opens a file in the specified mode. Returns a file handle, or `nil` plus an error message. Mode can be `\"r\"` (read), `\"w\"` (write), `\"a\"` (append), with optional `\"b\"` for binary.\n\n```lua\nlocal f = io.open(\"data.txt\", \"r\")\nlocal content = f:read(\"*a\")\nf:close()\n```" },
540
- "insertText": "io.open(\"${1:filename}\", \"${2:r}\")",
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": "04_io.open"
2191
+ "sortText": "05_math_math.log"
543
2192
  },
544
2193
  {
545
- "label": "io.read",
546
- "kind": 1,
547
- "detail": "Read from default input",
548
- "documentation": { "value": "Reads from the default input file according to the given formats.\n\n```lua\nlocal line = io.read() -- read one line\nlocal all = io.read(\"*a\") -- read entire file\nlocal num = io.read(\"*n\") -- read a number\n```\n\n**Lua 5.3+:** Use `\"a\"`, `\"l\"`, `\"L\"`, `\"n\"` (without `*` prefix)." },
549
- "insertText": "io.read(\"${1:*l}\")",
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": "04_io.read"
2202
+ "sortText": "05_math_math.fmod"
552
2203
  },
553
2204
  {
554
- "label": "io.write",
555
- "kind": 1,
556
- "detail": "Write to default output",
557
- "documentation": { "value": "Writes the value of each argument to the default output file.\n\n```lua\nio.write(\"Hello, world!\\n\")\nio.write(string.format(\"Value: %d\\n\", x))\n```" },
558
- "insertText": "io.write(${1:value})",
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": "04_io.write"
2213
+ "sortText": "05_math_math.tointeger"
561
2214
  },
562
2215
  {
563
- "label": "io.close",
564
- "kind": 1,
565
- "detail": "Close a file",
566
- "documentation": { "value": "Closes `file` or the default output file.\n\n```lua\nio.close(file)\nio.close() -- close default output\n```" },
567
- "insertText": "io.close(${1:file})",
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": "04_io.close"
2224
+ "sortText": "05_math_math.randomseed"
570
2225
  },
571
2226
  {
572
- "label": "io.lines",
573
- "kind": 1,
574
- "detail": "Iterate over lines of a file",
575
- "documentation": { "value": "Opens the given file name and returns an iterator function that returns a new line from the file each time it is called. The file is automatically closed when the loop ends.\n\n```lua\nfor line in io.lines(\"data.txt\") do\n print(line)\nend\n```" },
576
- "insertText": "io.lines(\"${1:filename}\")",
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": "04_io.lines"
2235
+ "sortText": "05_io_io.flush"
579
2236
  },
580
2237
  {
581
- "label": "os.time",
582
- "kind": 1,
583
- "detail": "Get current time or convert a date table",
584
- "documentation": { "value": "Returns the current time when called without arguments, or a time representing the date and time specified by the given table.\n\n```lua\nlocal now = os.time()\nlocal t = os.time({year=2026, month=3, day=3})\n```" },
585
- "insertText": "os.time(${1:})",
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": "05_os.time"
2246
+ "sortText": "05_io_io.input"
588
2247
  },
589
2248
  {
590
- "label": "os.date",
591
- "kind": 1,
592
- "detail": "Format date/time as a string",
593
- "documentation": { "value": "Returns a string or table with date and time, formatted according to the given string `format`. If `format` starts with `!`, it is formatted in UTC.\n\n```lua\nos.date(\"%Y-%m-%d %H:%M:%S\") -- \"2026-03-03 12:00:00\"\nos.date(\"%A\") -- \"Tuesday\"\nos.date(\"*t\") -- returns a table\n```" },
594
- "insertText": "os.date(\"${1:%Y-%m-%d %H:%M:%S}\"${2:, ${3:time}})",
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": "05_os.date"
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": "os.execute",
609
- "kind": 1,
610
- "detail": "Execute a shell command",
611
- "documentation": { "value": "Passes `command` to be executed by the operating system shell. Returns `true` (or `nil`), a string describing the exit status, and the exit code.\n\n```lua\nos.execute(\"mkdir mydir\")\nlocal ok, exittype, code = os.execute(\"ls -la\")\n```\n\n**Lua 5.1:** Returns only the exit status number." },
612
- "insertText": "os.execute(\"${1:command}\")",
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": "05_os.execute"
2268
+ "sortText": "05_io_io.tmpfile"
615
2269
  },
616
2270
  {
617
- "label": "os.getenv",
618
- "kind": 1,
619
- "detail": "Get an environment variable",
620
- "documentation": { "value": "Returns the value of the environment variable `varname`, or `nil` if not defined.\n\n```lua\nlocal home = os.getenv(\"HOME\")\nlocal path = os.getenv(\"PATH\")\n```" },
621
- "insertText": "os.getenv(\"${1:varname}\")",
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": "05_os.getenv"
2279
+ "sortText": "05_io_io.type"
624
2280
  },
625
2281
  {
626
- "label": "os.rename",
627
- "kind": 1,
628
- "detail": "Rename a file or directory",
629
- "documentation": { "value": "Renames the file or directory named `oldname` to `newname`. Returns `true` on success, or `nil` plus error message.\n\n```lua\nos.rename(\"old.txt\", \"new.txt\")\n```" },
630
- "insertText": "os.rename(\"${1:oldname}\", \"${2:newname}\")",
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": "05_os.rename"
2290
+ "sortText": "05_io_io.popen"
633
2291
  },
634
2292
  {
635
- "label": "os.remove",
636
- "kind": 1,
637
- "detail": "Remove a file",
638
- "documentation": { "value": "Deletes the file with the given name. If it fails, returns `nil` plus an error message and error number.\n\n```lua\nos.remove(\"temp.txt\")\n```" },
639
- "insertText": "os.remove(\"${1:filename}\")",
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": "05_os.remove"
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": 1,
655
- "detail": "Terminate the program",
656
- "documentation": { "value": "Calls the ISO C function `exit` to terminate the host program. If `code` is `true`, the exit status is `EXIT_SUCCESS`; if `false`, it is `EXIT_FAILURE`; if a number, it is used as exit code.\n\n```lua\nos.exit() -- success\nos.exit(1) -- failure\nos.exit(true) -- Lua 5.2+ success\n```\n\n**Lua 5.2+:** Optional `close` parameter to close the Lua state." },
657
- "insertText": "os.exit(${1:code})",
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": "05_os.exit"
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": "else",
681
- "kind": 14,
682
- "detail": "Else branch keyword",
683
- "documentation": { "value": "Begins an alternative branch in an `if` statement." },
684
- "insertText": "else",
685
- "insertTextRules": 0,
686
- "sortText": "06_else"
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": "while",
717
- "kind": 14,
718
- "detail": "While-loop keyword",
719
- "documentation": { "value": "Begins a while loop.\n\n```lua\nwhile condition do\n -- code\nend\n```" },
720
- "insertText": "while",
721
- "insertTextRules": 0,
722
- "sortText": "06_while"
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": "do",
726
- "kind": 14,
727
- "detail": "Block start keyword",
728
- "documentation": { "value": "Begins a block. Used with `while`, `for`, or standalone for scoping.\n\n```lua\ndo\n local x = 10\nend -- x is out of scope\n```" },
729
- "insertText": "do",
730
- "insertTextRules": 0,
731
- "sortText": "06_do"
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": "repeat",
735
- "kind": 14,
736
- "detail": "Repeat-until loop keyword",
737
- "documentation": { "value": "Begins a repeat-until loop. The body executes at least once.\n\n```lua\nrepeat\n -- code\nuntil condition\n```" },
738
- "insertText": "repeat",
739
- "insertTextRules": 0,
740
- "sortText": "06_repeat"
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": "until",
744
- "kind": 14,
745
- "detail": "Repeat-until terminator keyword",
746
- "documentation": { "value": "Terminates a `repeat` block and specifies the loop condition." },
747
- "insertText": "until",
748
- "insertTextRules": 0,
749
- "sortText": "06_until"
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": "function",
753
- "kind": 14,
754
- "detail": "Function definition keyword",
755
- "documentation": { "value": "Defines a function.\n\n```lua\nfunction foo(a, b)\n return a + b\nend\n\nlocal bar = function(x) return x * 2 end\n```" },
756
- "insertText": "function",
757
- "insertTextRules": 0,
758
- "sortText": "06_function"
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": "local",
762
- "kind": 14,
763
- "detail": "Local variable declaration keyword",
764
- "documentation": { "value": "Declares a local variable or function, limiting its scope to the enclosing block.\n\n```lua\nlocal x = 10\nlocal function helper() end\n```" },
765
- "insertText": "local",
766
- "insertTextRules": 0,
767
- "sortText": "06_local"
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": "return",
771
- "kind": 14,
772
- "detail": "Return from function keyword",
773
- "documentation": { "value": "Returns values from a function. Must be the last statement in a block.\n\n```lua\nreturn x, y\n```" },
774
- "insertText": "return",
775
- "insertTextRules": 0,
776
- "sortText": "06_return"
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": "break",
780
- "kind": 14,
781
- "detail": "Break out of a loop keyword",
782
- "documentation": { "value": "Terminates the execution of a `while`, `repeat`, or `for` loop, skipping to the next statement after the loop." },
783
- "insertText": "break",
784
- "insertTextRules": 0,
785
- "sortText": "06_break"
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": "goto",
789
- "kind": 14,
790
- "detail": "Jump to a label (Lua 5.2+)",
791
- "documentation": { "value": "Transfers the program control to the statement after the given label. Uses `::label::` syntax for label definitions.\n\n```lua\ngoto continue\n::continue::\n```\n\n**Note:** Available in Lua 5.2+ and LuaJIT 2.x." },
792
- "insertText": "goto",
793
- "insertTextRules": 0,
794
- "sortText": "06_goto"
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": "in",
798
- "kind": 14,
799
- "detail": "Generic for-loop keyword",
800
- "documentation": { "value": "Used in generic `for` loops to specify the iterator.\n\n```lua\nfor k, v in pairs(t) do ... end\n```" },
801
- "insertText": "in",
802
- "insertTextRules": 0,
803
- "sortText": "06_in"
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": "and",
807
- "kind": 14,
808
- "detail": "Logical AND operator",
809
- "documentation": { "value": "Logical conjunction. Returns its first argument if it is false or nil; otherwise returns its second argument.\n\n```lua\nlocal x = a and b -- short-circuit evaluation\n```" },
810
- "insertText": "and",
811
- "insertTextRules": 0,
812
- "sortText": "06_and"
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": "or",
816
- "kind": 14,
817
- "detail": "Logical OR operator",
818
- "documentation": { "value": "Logical disjunction. Returns its first argument if it is not false/nil; otherwise returns its second argument.\n\n```lua\nlocal x = a or default_value\n```" },
819
- "insertText": "or",
820
- "insertTextRules": 0,
821
- "sortText": "06_or"
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": "not",
825
- "kind": 14,
826
- "detail": "Logical NOT operator",
827
- "documentation": { "value": "Logical negation. Returns `true` if the argument is false or nil, otherwise returns `false`.\n\n```lua\nif not done then ... end\n```" },
828
- "insertText": "not",
829
- "insertTextRules": 0,
830
- "sortText": "06_not"
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": "nil",
834
- "kind": 14,
835
- "detail": "Nil value keyword",
836
- "documentation": { "value": "The type `nil` has one single value, `nil`, whose main property is to be different from any other value. It represents the absence of a useful value." },
837
- "insertText": "nil",
838
- "insertTextRules": 0,
839
- "sortText": "06_nil"
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": "true",
843
- "kind": 14,
844
- "detail": "Boolean true keyword",
845
- "documentation": { "value": "The boolean value `true`." },
846
- "insertText": "true",
847
- "insertTextRules": 0,
848
- "sortText": "06_true"
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": "false",
852
- "kind": 14,
853
- "detail": "Boolean false keyword",
854
- "documentation": { "value": "The boolean value `false`. Together with `nil`, it is considered false in conditional tests; all other values are true." },
855
- "insertText": "false",
856
- "insertTextRules": 0,
857
- "sortText": "06_false"
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": "function definition",
2502
+ "label": "utf8.char",
861
2503
  "kind": 15,
862
- "detail": "Define a named function",
863
- "documentation": { "value": "Snippet for a named function definition.\n\n```lua\nfunction name(args)\n -- body\nend\n```" },
864
- "insertText": "function ${1:name}(${2:args})\n\t${3:-- body}\nend",
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": "07_function_definition"
2510
+ "sortText": "05_utf8_utf8.char"
867
2511
  },
868
2512
  {
869
- "label": "local function",
2513
+ "label": "utf8.codepoint",
870
2514
  "kind": 15,
871
- "detail": "Define a local function",
872
- "documentation": { "value": "Snippet for a local function definition.\n\n```lua\nlocal function name(args)\n -- body\nend\n```" },
873
- "insertText": "local function ${1:name}(${2:args})\n\t${3:-- body}\nend",
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": "07_local_function"
2521
+ "sortText": "05_utf8_utf8.codepoint"
876
2522
  },
877
2523
  {
878
- "label": "for i = ...",
2524
+ "label": "utf8.offset",
879
2525
  "kind": 15,
880
- "detail": "Numeric for loop",
881
- "documentation": { "value": "Snippet for a numeric `for` loop.\n\n```lua\nfor i = 1, 10 do\n -- body\nend\n```" },
882
- "insertText": "for ${1:i} = ${2:1}, ${3:10}${4:, ${5:1}} do\n\t${6:-- body}\nend",
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": "07_for_numeric"
2532
+ "sortText": "05_utf8_utf8.offset"
885
2533
  },
886
2534
  {
887
- "label": "for k, v in pairs",
2535
+ "label": "utf8.charpattern",
888
2536
  "kind": 15,
889
- "detail": "Generic for loop with pairs()",
890
- "documentation": { "value": "Snippet to iterate over all key-value pairs in a table.\n\n```lua\nfor k, v in pairs(t) do\n -- body\nend\n```" },
891
- "insertText": "for ${1:k}, ${2:v} in pairs(${3:t}) do\n\t${4:-- body}\nend",
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": "07_for_pairs"
2543
+ "sortText": "05_utf8_utf8.charpattern"
894
2544
  },
895
2545
  {
896
- "label": "for i, v in ipairs",
2546
+ "label": "package.path",
897
2547
  "kind": 15,
898
- "detail": "Generic for loop with ipairs()",
899
- "documentation": { "value": "Snippet to iterate over integer-keyed elements of a table.\n\n```lua\nfor i, v in ipairs(t) do\n -- body\nend\n```" },
900
- "insertText": "for ${1:i}, ${2:v} in ipairs(${3:t}) do\n\t${4:-- body}\nend",
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": "07_for_ipairs"
2554
+ "sortText": "05_package_package.path"
903
2555
  },
904
2556
  {
905
- "label": "while loop",
2557
+ "label": "package.cpath",
906
2558
  "kind": 15,
907
- "detail": "While loop",
908
- "documentation": { "value": "Snippet for a `while` loop.\n\n```lua\nwhile condition do\n -- body\nend\n```" },
909
- "insertText": "while ${1:condition} do\n\t${2:-- body}\nend",
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": "07_while_loop"
2565
+ "sortText": "05_package_package.cpath"
912
2566
  },
913
2567
  {
914
- "label": "repeat until",
2568
+ "label": "package.loaded",
915
2569
  "kind": 15,
916
- "detail": "Repeat-until loop",
917
- "documentation": { "value": "Snippet for a `repeat-until` loop. The body runs at least once.\n\n```lua\nrepeat\n -- body\nuntil condition\n```" },
918
- "insertText": "repeat\n\t${1:-- body}\nuntil ${2:condition}",
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": "07_repeat_until"
2576
+ "sortText": "05_package_package.loaded"
921
2577
  },
922
2578
  {
923
- "label": "if then end",
2579
+ "label": "package.preload",
924
2580
  "kind": 15,
925
- "detail": "If-then-end block",
926
- "documentation": { "value": "Snippet for a simple `if` block.\n\n```lua\nif condition then\n -- body\nend\n```" },
927
- "insertText": "if ${1:condition} then\n\t${2:-- body}\nend",
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": "07_if_then_end"
2587
+ "sortText": "05_package_package.preload"
930
2588
  },
931
2589
  {
932
- "label": "if else",
2590
+ "label": "package.searchers",
933
2591
  "kind": 15,
934
- "detail": "If-else block",
935
- "documentation": { "value": "Snippet for an `if-else` block.\n\n```lua\nif condition then\n -- then body\nelse\n -- else body\nend\n```" },
936
- "insertText": "if ${1:condition} then\n\t${2:-- then body}\nelse\n\t${3:-- else body}\nend",
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": "07_if_else"
2598
+ "sortText": "05_package_package.searchers"
939
2599
  },
940
2600
  {
941
- "label": "module pattern",
2601
+ "label": "package.searchpath",
942
2602
  "kind": 15,
943
- "detail": "Lua module pattern",
944
- "documentation": { "value": "Creates a module using the standard Lua module pattern (returning a table).\n\n```lua\nlocal M = {}\n\nfunction M.myFunc()\n -- ...\nend\n\nreturn M\n```" },
945
- "insertText": "local ${1:M} = {}\n\nfunction ${1:M}.${2:name}(${3:args})\n\t${4:-- body}\nend\n\nreturn ${1:M}",
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": "07_module_pattern"
2609
+ "sortText": "05_package_package.searchpath"
948
2610
  },
949
2611
  {
950
- "label": "class with metatables",
2612
+ "label": "package.config",
951
2613
  "kind": 15,
952
- "detail": "OOP class pattern using metatables",
953
- "documentation": { "value": "Creates a class-like structure using metatables and `__index`.\n\n```lua\nlocal MyClass = {}\nMyClass.__index = MyClass\n\nfunction MyClass.new(value)\n local self = setmetatable({}, MyClass)\n self.value = value\n return self\nend\n\nfunction MyClass:getValue()\n return self.value\nend\n```" },
954
- "insertText": "local ${1:MyClass} = {}\n${1:MyClass}.__index = ${1:MyClass}\n\nfunction ${1:MyClass}.new(${2:args})\n\tlocal self = setmetatable({}, ${1:MyClass})\n\t${3:-- initialize}\n\treturn self\nend\n\nfunction ${1:MyClass}:${4:method}(${5:})\n\t${6:-- body}\nend\n\nreturn ${1:MyClass}",
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": "07_class_metatables"
2620
+ "sortText": "05_package_package.config"
957
2621
  },
958
2622
  {
959
- "label": "coroutine pattern",
2623
+ "label": "local close",
960
2624
  "kind": 15,
961
- "detail": "Coroutine creation and resumption pattern",
962
- "documentation": { "value": "Creates and uses a coroutine.\n\n```lua\nlocal co = coroutine.create(function()\n for i = 1, 5 do\n coroutine.yield(i)\n end\nend)\n\nwhile coroutine.status(co) ~= \"dead\" do\n local ok, value = coroutine.resume(co)\n if ok then print(value) end\nend\n```" },
963
- "insertText": "local ${1:co} = coroutine.create(function(${2:})\n\t${3:coroutine.yield(${4:value})}\nend)\n\nlocal ${5:ok}, ${6:value} = coroutine.resume(${1:co})",
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": "07_coroutine_pattern"
2631
+ "sortText": "02_local_close"
966
2632
  }
967
2633
  ]
968
- }
2634
+ }