diff --git a/package.json b/package.json index f33d7b10..3306cf28 100644 --- a/package.json +++ b/package.json @@ -164,6 +164,22 @@ "language": "rust", "path": "./snippets/frameworks/relm4/components.json" }, + { + "language": ["typst"], + "path": "./snippets/typst/layout.json" + }, + { + "language": ["typst"], + "path": "./snippets/typst/visualize.json" + }, + { + "language": ["typst"], + "path": "./snippets/typst/markup.json" + }, + { + "language": ["typst"], + "path": "./snippets/typst/maths.json" + }, { "language": "haskell", "path": "./snippets/haskell.json" diff --git a/snippets/typst/layout.json b/snippets/typst/layout.json new file mode 100644 index 00000000..fdfd1ae3 --- /dev/null +++ b/snippets/typst/layout.json @@ -0,0 +1,67 @@ +{ + "align center": { + "prefix": "align.c", + "body": [ + "#align(center)[", + "${0:para}", + "]" + ], + "description": "Align contents center." + }, + "align right bottom": { + "prefix": "align.r.b", + "body": [ + "#align(right + bottom)[", + "${0:para}", + "]" + ], + "description": "Align contents towards right bottom." + }, + "block": { + "prefix": "block", + "body": [ + "#block(", + "fill: luma(230),", + "inset: 8pt,", + "radius: 4pt,", + ")[${0:text}]" + ], + "description": "A block-level container." + }, + "box": { + "prefix": "box", + "body": [ + "#box(", + " inset: 4pt,", + ")[${0:text}]" + ], + "description": "An inline-level container that sizes content." + }, + "pagebreak": { + "prefix": "pagebreak", + "body": [ + "#pagebreak(", + " weak: false,", + " to: \"${0:odd}\",", + ")" + ], + "description": [ + "A manual page break.", + " ", + "Must not be used inside any containers.", + " ", + "PARAMETERS:", + " ", + "weak: bool", + " ", + "If true, the page break is skipped if the current page is already empty.", + " ", + "Default: false", + " ", + "to: none or str", + " ", + "If given, ensures that the next page will be an even/odd page, with an empty page in between if necessary.", + " " + ] + } +} diff --git a/snippets/typst/markup.json b/snippets/typst/markup.json new file mode 100644 index 00000000..bb1866df --- /dev/null +++ b/snippets/typst/markup.json @@ -0,0 +1,168 @@ +{ + "header 1": { + "prefix": "h1", + "body": ["= ${0}"], + "description": "Add header level 1" + }, + "header 2": { + "prefix": "h2", + "body": ["== ${0}"], + "description": "Add header level 2" + }, + "header 3": { + "prefix": "h3", + "body": ["=== ${0}"], + "description": "Add header level 3" + }, + "header 4": { + "prefix": "h4", + "body": ["==== ${0}"], + "description": "Add header level 4" + }, + "header 5": { + "prefix": "h5", + "body": ["===== ${0}"], + "description": "Add header level 5" + }, + "header 6": { + "prefix": "h6", + "body": ["====== ${0}"], + "description": "Add header level 6" + }, + "Strong emphasis": { + "prefix": "emp", + "body": ["*${0}*"], + "description": "Strong emphasis" + }, + "Emphasis": { + "prefix": "emp", + "body": ["_${0}_"], + "description": "emphasis" + }, + "Raw text": { + "prefix": "raw", + "body": ["`${0}`"], + "description": "Raw text" + }, + "Label": { + "prefix": "lable", + "body": ["<${0}>"], + "description": "Label" + }, + "Reference": { + "prefix": "reference", + "body": ["@${0}"], + "description": "Reference" + }, + "Links": { + "prefix": ["l", "link"], + "body": ["#link(${1:url})[${2:test}] ${0}"], + "description": "Add links\n\nexample:\n\n#link(\"https://example.com\")[repo link]\n\nsnippet:\n" + }, + "Internal Links": { + "prefix": ["l", "link_internal"], + "body": ["#link((${1:page: 1, x: 0pt, y: 0pt}))[${2:test}] ${0}"], + "description": "add internal links" + }, + "Lable Links": { + "prefix": ["l", "link_label"], + "body": ["#link(${1:})[${2:Go to intro}] ${0}"], + "description": "add lable links" + }, + "Bullet list": { + "prefix": ["list.b"], + "body": [ + "- ${0: item}" + ], + "description": "add Bullet list" + }, + "2 Bullet list": { + "prefix": ["list.b.2"], + "body": [ + "- ${0: item}", + "- ${1: item}" + ], + "description": "add 2 Bullet list" + }, + "3 Bullet list": { + "prefix": ["list.b.3"], + "body": [ + "- ${0: item}", + "- ${1: item}", + "- ${2: item}" + ], + "description": "add 3 Bullet list" + }, + "4 Bullet list": { + "prefix": ["list.b.4"], + "body": [ + "- ${0: item}", + "- ${1: item}", + "- ${2: item}", + "- ${3: item}" + ], + "description": "add 4 Bullet list" + }, + "Numbered list": { + "prefix": ["list.n"], + "body": [ + "+ ${0: item}" + ], + "description": "add Numbered list" + }, + "2 Numbered list": { + "prefix": ["list.n.2"], + "body": [ + "+ ${0: item}", + "+ ${1: item}" + ], + "description": "add 2 Numbered list" + }, + "3 Numbered list": { + "prefix": ["list.n.3"], + "body": [ + "+ ${0: item}", + "+ ${1: item}", + "+ ${2: item}" + ], + "description": "add 3 Numbered list" + }, + "4 Numbered list": { + "prefix": ["list.n.4"], + "body": [ + "+ ${0: item}", + "+ ${1: item}", + "+ ${2: item}", + "+ ${3: item}" + ], + "description": "add 4 Numbered list" + }, + "Term list": { + "prefix": ["term.list", "list.term"], + "body": [ + "/ Term: ${0: description}" + ], + "description": "add Term list" + }, + "Math": { + "prefix": ["maths"], + "body": [ + "$${0:x^2}$" + ], + "description": "maths block" + }, + "Comment block": { + "prefix": ["comment.b"], + "body": [ + "/* ${0:comment} */" + ], + "description": "Comment block" + }, + "Comment line": { + "prefix": ["comment.l"], + "body": [ + "// ${0:comment}" + ], + "description": "Comment line" + } +} diff --git a/snippets/typst/maths.json b/snippets/typst/maths.json new file mode 100644 index 00000000..f66f0d4c --- /dev/null +++ b/snippets/typst/maths.json @@ -0,0 +1,34 @@ +{ + "cases": { + "prefix": ["cases", "maths.cases"], + "body": [ + "$ f(x, y) := cases(", + " 1 \"if\" (x dot y)/2 <= 0,", + " 2 \"if\" x \"is even\",", + " 3 \"if\" x in NN,", + " 4 \"else\",", + ") $" + ], + "description": [ + "A case distinction.", + " ", + "Content across different branches can be aligned with the & symbol." + ] + }, + "equation": { + "prefix": ["equation", "maths.equation"], + "body": [ + "$ sum_(k=1)^n k = (n(n+1)) / 2 $" + ], + "description": [ + "A mathematical equation.", + " ", + "Can be displayed inline with text or as a separate block." + ] + }, + "frac": { + "prefix": ["frac", "maths.frac"], + "body": ["$ ((${0:x}+1)) / 2 = frac(a, b) $"], + "description": "A mathematical fraction." + } +} diff --git a/snippets/typst/visualize.json b/snippets/typst/visualize.json new file mode 100644 index 00000000..b34ecb0a --- /dev/null +++ b/snippets/typst/visualize.json @@ -0,0 +1,44 @@ +{ + "Images": { + "prefix": "img", + "body": [ + "#image(${0:\"img.png\"}, ${1:width: 80%})" + ], + "description": "Add images" + }, + "Figure Images": { + "prefix": ["img_figure", "figure_img"], + "body": [ + "#figure(", + "image(${1:\"img.png\"}, ${2:width: 80%}),", + "cation: [", + "${0: cation}", + "],", + ")" + ], + "description": "Add images with figure" + }, + "highlight": { + "prefix": "highlight", + "body": ["#highlight[${0: important}]"], + "description": "Add highlight" + }, + "highlight full": { + "prefix": "highlight_full", + "body": [ + "#highlight(", + "fill: blue,", + "stroke: fuchsia,", + "extent: 4pt,", + "radius: 5pt,", + "top-edge: \"ascender\",", + "bottom-edge: \"descender\",", + ")[${0: important}]"], + "description": "Add highlight with full options" + }, + "lorem": { + "prefix": "lorem", + "body": ["#lorem(${0: num})"], + "description": "This function yields a Latin-like Lorem Ipsum blind text with the given number of words." + } +}