diff --git a/snippets/lua/lua.json b/snippets/lua/lua.json index fdafb237..39f70f04 100644 --- a/snippets/lua/lua.json +++ b/snippets/lua/lua.json @@ -7,17 +7,17 @@ "return": { "prefix": "rt", "body": ["return $0"], - "description": "return value" + "description": "Return value" }, "assigment": { "prefix": "ll", "body": ["local ${1:varName} = ${0:value}"], - "description": "define a variable" + "description": "Define a variable" }, "local": { "prefix": "l", "body": ["local ${0}"], - "description": "declare a variable" + "description": "Declare a variable" }, "locreq": { "prefix": "lreq", @@ -44,12 +44,23 @@ }, "for": { "prefix": "for", - "body": ["for ${1:i}=${2:1},${3:10} do", "\t$0", "end"], - "description": "for loop range" + "body": ["for $1 do", "\t$0", "end"], + "description": "for statement" }, - "foreach": { - "prefix": "foreach", - "body": ["for i, ${1:x} in pairs(${2:table}) do", "\t$0", "end"] + "for-numeric": { + "prefix": "forn", + "body": ["for ${1:i} = ${2:1}, ${3:10} do", "\t$0", "end"], + "description": "for numeric range statement" + }, + "for-ipairs": { + "prefix": "fori", + "body": ["for ${1:i}, ${2:x} in ipairs(${3:t}) do", "\t$0", "end"], + "description": "for i, x in ipairs(t)" + }, + "for-pairs": { + "prefix": "forp", + "body": ["for ${1:k}, ${2:v} in pairs(${3:t}) do", "\t$0", "end"], + "description": "for k, v in pairs(t)" }, "forline": { "prefix": "forline", @@ -61,15 +72,37 @@ "\t${0}", "end" ], - "description": "read file line by line" + "description": "Read file line by line" }, "function": { "prefix": "fu", - "body": ["function ${1:name}($2)", "\t${0}", "end"] + "body": ["function ${1:name}($2)", "\t${0}", "end"], + "description": "Define a function" }, - "inline-function": { + "assign-function": { "prefix": "f=", - "body": ["local ${1:name} = function($2)", "\t${0}", "end"] + "body": ["${1:name} = function($2)", "\t${0}", "end"], + "description": "Assign a function to a variable" + }, + "local-function": { + "prefix": "lfu", + "body": ["local function ${1:name}($2)", "\t${0}", "end"], + "description": "Define a local function" + }, + "local-assign-function": { + "prefix": "lf=", + "body": ["local ${1:name} = function($2)", "\t${0}", "end"], + "description": "Assign a function to a local variable" + }, + "anonymous-function": { + "prefix": "f)", + "body": ["function($1)", "\t${0}", "end"], + "description": "Create an anonymous function" + }, + "member-function": { + "prefix": "f,", + "body": ["${1:name} = function($2)", "\t${0}", "end,"], + "description": "Assign a function to a table key" }, "print": { "prefix": "p",