# turbo-js 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: javascript, json, toml, yaml, markdown, html, xml, dockerfile, # bash. Leave it out and the snippet is offered everywhere. # # Bodies indent with two spaces, which is what Prettier writes by default; a # tab here would be reformatted away the first time `npx prettier --write` # runs, which is a diff nobody asked for. # # Your own snippets, shared across every project, go in: # %s [[snippet]] name = "import" group = "JavaScript" languages = ["javascript"] body = 'import { name } from "node:module";' [[snippet]] name = "require" group = "JavaScript" languages = ["javascript"] body = 'const name = require("node:module");' [[snippet]] name = "async function" group = "JavaScript" languages = ["javascript"] body = """ async function name() { const result = await promise; return result; }""" [[snippet]] name = "try / catch" group = "JavaScript" languages = ["javascript"] body = """ try { } catch (error) { console.error(error); }""" [[snippet]] name = "class" group = "JavaScript" languages = ["javascript"] body = """ class Name { #field; constructor(field) { this.#field = field; } }""" [[snippet]] name = "for of" group = "JavaScript" languages = ["javascript"] body = """ for (const item of items) { }""" [[snippet]] name = "test" group = "JavaScript" languages = ["javascript"] body = """ import { test } from "node:test"; import assert from "node:assert/strict"; test("it works", () => { assert.equal(1 + 1, 2); });""" [[snippet]] name = "scripts" group = "JSON" languages = ["json"] body = """ "scripts": { "start": "node main.js", "test": "node --test" }""" [[snippet]] group = "General" name = "Hello" body = "Hello!!!" [[snippet]] group = "Markdown" name = "Image" languages = ["markdown"] body = "![img](./pictures)"