summaryrefslogtreecommitdiff
path: root/snippets/lua.snippets
blob: ce87bb88bd085f0c35c5840bf6a708d2074f8bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
snippet #!
	#!/usr/bin/env lua
	$1
snippet local
	local ${1:x} = ${0:1}
snippet fun
	function ${1:fname}(${2:...})
		${0:-- body}
	end
snippet for
	for ${1:i}=${2:1},${3:10} do
		${0:print(i)}
	end
snippet forp
	for ${1:i},${2:v} in pairs(${3:table_name}) do
		${0:-- body}
	end
snippet fori
	for ${1:i},${2:v} in ipairs(${3:table_name}) do
		${0:-- body}
	end
snippet if
	if ${1:condition} then
		${2:-- body}
	end
snippet ife
	if ${1:condition} then
		${2:-- if condition}
	else
		${0:-- else}
	end
snippet elif
	elseif ${1:condition} then
		${0:--body}
snippet repeat
	repeat
		${1:--body}
	until ${0:condition}
snippet while
	while ${1:condition} do
		${0:--body}
	end
snippet print
	print("${1:string}")
snippet pr
	print($0)
snippet prs
	print("$0")
snippet prf
	print(string.format("${1:%s}"$0))
snippet wr
	io.write($0)
snippet wrs
	io.write("$0")
snippet wrf
	io.write(string.format("${1:%s}"$0))
snippet fwr
	io.${1:stderr}:write($0)
snippet fwrs
	io.${1:stderr}:write("$0")
snippet fwrf
	io.${1:stderr}:write(string.format("${2:%s}"$0))
snippet im
	import "${1:import file}"