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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# turbo-golo snippets.
#
# Each [[snippet]] becomes one line of the Snippets menu. Snippets sharing a
# group appear together in a submenu of that name; one with no group goes into
# %s. A snippet is inserted at the cursor, and every line after the
# first is indented to match the line you inserted it on.
#
# languages restricts a snippet to files of those kinds, by the names the
# editor uses: bash, dockerfile, golo, html, javascript, markdown, toml, xml,
# yaml. Leave it out and the snippet is offered everywhere.
#
# Bodies are indented with two spaces, which is what every example in the
# GoloScript documentation and its own templates use. Golo has no formatter to
# disagree with, so the convention is the only authority there is.
#
# Every Golo body below is written in single quotes — '''…''' rather than
# """…""" — because a Golo string carries \n and \" the way a Go string does,
# and TOML would interpret those escapes in a basic string before the editor
# ever saw them. In a literal string a backslash is just a backslash, which is
# what a Golo snippet needs.
#
# Your own snippets, shared across every project, go in:
# %s
[[snippet]]
name = "module"
group = "Golo"
languages = ["golo"]
body = '''
module hello.World
function main = |args| {
println("Hello, Golo!")
}'''
[[snippet]]
name = "main"
group = "Golo"
languages = ["golo"]
body = '''
function main = |args| {
println("Hello, Golo!")
}'''
[[snippet]]
name = "function"
group = "Golo"
languages = ["golo"]
body = '''
function name = |a, b| {
return a + b
}'''
[[snippet]]
name = "closure"
group = "Golo"
languages = ["golo"]
body = '''
let f = |x| -> x * 2'''
[[snippet]]
name = "struct"
group = "Golo"
languages = ["golo"]
body = '''
struct Point = { x, y }'''
[[snippet]]
name = "union"
group = "Golo"
languages = ["golo"]
body = '''
union Shape = {
Circle = { radius }
Rect = { width, height }
}'''
[[snippet]]
name = "augment"
group = "Golo"
languages = ["golo"]
body = '''
augment Point {
function describe = |this| -> "(" + this: x() + ", " + this: y() + ")"
}'''
[[snippet]]
name = "match"
group = "Golo"
languages = ["golo"]
body = '''
let label = match {
when n < 0 then "negative"
when n == 0 then "zero"
otherwise "positive"
}'''
[[snippet]]
name = "foreach"
group = "Golo"
languages = ["golo"]
body = '''
foreach item in list[1, 2, 3] {
println(item)
}'''
[[snippet]]
name = "for"
group = "Golo"
languages = ["golo"]
body = '''
for (var i = 0, i < 10, i = i + 1) {
println(i)
}'''
[[snippet]]
name = "try"
group = "Golo"
languages = ["golo"]
body = '''
try {
throw "boom"
} catch (e) {
println("caught: \"" + e + "\"")
} finally {
println("done")
}'''
[[snippet]]
name = "comprehension"
group = "Golo"
languages = ["golo"]
body = '''
let squares = list[x * x foreach x in range(1, 6) when x > 2]'''
[[snippet]]
group = "General"
name = "Hello"
body = "Hello!!!"
[[snippet]]
group = "Markdown"
name = "Image"
languages = ["markdown"]
body = ""
|