Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lua): for / function snippets overhaul #537

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions snippets/lua/lua.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down