| 📦 Turbo JS 91999d1 k33g 12h ago | 1 | # turbo-js snippets. |
| 2 | # |
| 3 | # Each [[snippet]] becomes one line of the Snippets menu. Snippets sharing a |
| 4 | # group appear together in a submenu of that name; one with no group goes into |
| 5 | # %s. A snippet is inserted at the cursor, and every line after the |
| 6 | # first is indented to match the line you inserted it on. |
| 7 | # |
| 8 | # languages restricts a snippet to files of those kinds, by the names the |
| 9 | # editor uses: javascript, json, toml, yaml, markdown, html, xml, dockerfile, |
| 10 | # bash. Leave it out and the snippet is offered everywhere. |
| 11 | # |
| 12 | # Bodies indent with two spaces, which is what Prettier writes by default; a |
| 13 | # tab here would be reformatted away the first time `npx prettier --write` |
| 14 | # runs, which is a diff nobody asked for. |
| 15 | # |
| 16 | # Your own snippets, shared across every project, go in: |
| 17 | # %s |
| 18 | |
| 19 | [[snippet]] |
| 20 | name = "import" |
| 21 | group = "JavaScript" |
| 22 | languages = ["javascript"] |
| 23 | body = 'import { name } from "node:module";' |
| 24 | |
| 25 | [[snippet]] |
| 26 | name = "require" |
| 27 | group = "JavaScript" |
| 28 | languages = ["javascript"] |
| 29 | body = 'const name = require("node:module");' |
| 30 | |
| 31 | [[snippet]] |
| 32 | name = "async function" |
| 33 | group = "JavaScript" |
| 34 | languages = ["javascript"] |
| 35 | body = """ |
| 36 | async function name() { |
| 37 | const result = await promise; |
| 38 | return result; |
| 39 | }""" |
| 40 | |
| 41 | [[snippet]] |
| 42 | name = "try / catch" |
| 43 | group = "JavaScript" |
| 44 | languages = ["javascript"] |
| 45 | body = """ |
| 46 | try { |
| 47 | } catch (error) { |
| 48 | console.error(error); |
| 49 | }""" |
| 50 | |
| 51 | [[snippet]] |
| 52 | name = "class" |
| 53 | group = "JavaScript" |
| 54 | languages = ["javascript"] |
| 55 | body = """ |
| 56 | class Name { |
| 57 | #field; |
| 58 | |
| 59 | constructor(field) { |
| 60 | this.#field = field; |
| 61 | } |
| 62 | }""" |
| 63 | |
| 64 | [[snippet]] |
| 65 | name = "for of" |
| 66 | group = "JavaScript" |
| 67 | languages = ["javascript"] |
| 68 | body = """ |
| 69 | for (const item of items) { |
| 70 | }""" |
| 71 | |
| 72 | [[snippet]] |
| 73 | name = "test" |
| 74 | group = "JavaScript" |
| 75 | languages = ["javascript"] |
| 76 | body = """ |
| 77 | import { test } from "node:test"; |
| 78 | import assert from "node:assert/strict"; |
| 79 | |
| 80 | test("it works", () => { |
| 81 | assert.equal(1 + 1, 2); |
| 82 | });""" |
| 83 | |
| 84 | [[snippet]] |
| 85 | name = "scripts" |
| 86 | group = "JSON" |
| 87 | languages = ["json"] |
| 88 | body = """ |
| 89 | "scripts": { |
| 90 | "start": "node main.js", |
| 91 | "test": "node --test" |
| 92 | }""" |
| 93 | |
| 94 | [[snippet]] |
| 95 | group = "General" |
| 96 | name = "Hello" |
| 97 | body = "Hello!!!" |
| 98 | |
| 99 | [[snippet]] |
| 100 | group = "Markdown" |
| 101 | name = "Image" |
| 102 | languages = ["markdown"] |
| 103 | body = "" |