-
Notifications
You must be signed in to change notification settings - Fork 28
/
typst.hsnips
98 lines (76 loc) · 2.78 KB
/
typst.hsnips
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
snippet lm "inline Math" iwA
$${1}$
endsnippet
snippet dm "display Math" iwA
$ ${1} $
endsnippet
snippet pp "parenthesis" iAm
(${1})
endsnippet
snippet lim "limit" iAm
lim_(${1:n} -> oo)
endsnippet
snippet derive "derive" iAm
derive(${1:f}, ${2:x})
endsnippet
snippet part "partial" iAm
(diff ${1:f})/(diff ${3:x})
endsnippet
snippet int "integral" iAm
integral
endsnippet
snippet sb "subscript" iAm
_(${1:2})
endsnippet
snippet sr "square" iAm
^2
endsnippet
snippet tp "to the ... power" iAm
^(${1:3})
endsnippet
snippet veps "epsilon.alt" iAm
epsilon.alt
endsnippet
snippet ;; "\;" iAm
\;
endsnippet
snippet ,, "\," iAm
\,
endsnippet
snippet `([A-Za-z\)])(\d)` "auto subscript" iAm
`` rv = m[1] + "_" + m[2]``
endsnippet
snippet `([A-Za-z\)])_(\d{2})` "auto subscript" iAm
`` rv = m[1] + "_(" + m[2] + ")" ``
endsnippet
snippet `(?<![A-Za-z])([A-Za-hk-z])([acdijkmnpqrstABCDIJKMNPQRST])\2` "auto subscript" iAm
`` rv = m[1] + "_" + m[2] ``
endsnippet
# Custom: Add more greek letters
snippet `(\)|mu|alpha|sigma|rho|beta|gamma|delta|zeta|eta|varepsilon|epsilon|theta|iota|kappa|vartheta|lambda|nu|pi|rho|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)([acdijkmnpqrstABCDIJKMNPQRST])\2` "auto subscript for greek letter" iAm
`` rv = m[1] + "_" + m[2].substring(0, 1) ``
endsnippet
snippet `(?<![A-Za-z])([A-Za-hk-z01])(grave|acute|hat|tilde|macron|breve|dot|ddot|dddot|ddddot|diaer|circle|caron|vec|upright|italic|b|sans|frak|mono|bb|cal|ov)` "hat" iAm
``
const map = { "ddot": "dot.double", "dddot": "dot.triple", "ddddot": "dot.quad", "vec": "arrow", "b": "bold", "ov": "overline" }
rv = (map[m[2]] || m[2]) + "(" + m[1] + ")"
``
endsnippet
snippet `(mu|alpha|sigma|rho|beta|gamma|delta|zeta|eta|varepsilon|epsilon|theta|iota|kappa|vartheta|lambda|nu|pi|rho|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(grave|acute|hat|tilde|macron|breve|dot|ddot|dddot|ddddot|diaer|circle|caron|vec|upright|italic|b|sans|frak|mono|bb|cal|ov)` "hat" iAm
``
const map = { "ddot": "dot.double", "dddot": "dot.triple", "ddddot": "dot.quad", "vec": "arrow", "b": "bold", "ov": "overline" }
rv = (map[m[2]] || m[2]) + "(" + m[1] + ")"
``
endsnippet
snippet `((grave|acute|hat|tilde|macron|breve|dot|dot\.double|dot\.triple|dot\.quad|diaer|circle|acute\.double|caron|arrow|arrow\.l|upright|italic|bold|sans|frak|mono|bb|cal)\([a-zA-Z\d]+\))(grave|acute|hat|tilde|macron|breve|dot|ddot|dddot|ddddot|diaer|circle|caron|vec|upright|italic|b|sans|frak|mono|bb|cal|ov)` "hat" iAm
``
const map = { "ddot": "dot.double", "dddot": "dot.triple", "ddddot": "dot.quad", "vec": "arrow", "b": "bold", "ov": "overline" }
rv = (map[m[3]] || m[3]) + "(" + m[1] + ")"
``
endsnippet
snippet `(?<!\.)alt` "alt" iAm
.alt
endsnippet
snippet invs "inverse" iAm
^(-1)
endsnippet