# 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 # General. 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: # /Users/k33g/Library/Application Support/turbo-golo/snippets.toml [[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 = "![img](./pictures)"