209 lines
3.1 KiB
Text
209 lines
3.1 KiB
Text
global !p
|
|
def math():
|
|
return vim.eval('vimtex#syntax#in_mathzone()') == '1'
|
|
|
|
def comment():
|
|
return vim.eval('vimtex#syntax#in_comment()') == '1'
|
|
|
|
def env(name):
|
|
[x,y] = vim.eval("vimtex#env#is_inside('" + name + "')")
|
|
return x != '0' and y != '0'
|
|
|
|
endglobal
|
|
|
|
# General Formatting
|
|
snippet beg "begin{} / end{}" bA
|
|
\\begin{$1}
|
|
$0
|
|
\\end{$1}
|
|
endsnippet
|
|
|
|
snippet tit "Italics" w
|
|
\textit{$1}$0
|
|
endsnippet
|
|
|
|
snippet tob "Bold" w
|
|
\textbf{$1}$0
|
|
endsnippet
|
|
|
|
# Text Formatting
|
|
|
|
snippet ... "ldots" A
|
|
\ldots
|
|
endsnippet
|
|
|
|
# Math Environments
|
|
snippet im "Inline math" w
|
|
\(${1}\)`!p
|
|
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
|
|
snip.rv = ' '
|
|
else:
|
|
snip.rv = ''
|
|
`$2
|
|
endsnippet
|
|
|
|
snippet dm "Display math" w
|
|
\[
|
|
${1:${VISUAL}}
|
|
\] $0
|
|
endsnippet
|
|
|
|
# Math Snippets
|
|
context "math()"
|
|
snippet iff "iff" Ai
|
|
\iff
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet => "implies" iA
|
|
\Rightarrow
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet =< "implied by" iA
|
|
\Leftarrow
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet -> "maps to" iA
|
|
\rightarrow
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet -< "maps from" iA
|
|
\leftarrow
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet / "Fraction" i
|
|
\\frac{$1}{$2}$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet '([A-Za-z])(\d)' "auto subscript" wrA
|
|
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
|
|
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
|
|
endsnippet
|
|
|
|
snippet __ "subscript" iA
|
|
_{$1}$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet ceil "ceil" iA
|
|
\left\lceil $1 \right\rceil $0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet floor "floor" iA
|
|
\left\lfloor $1 \right\rfloor$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet ** "cdot" iA
|
|
\cdot
|
|
endsnippet
|
|
|
|
priority 100
|
|
context "math()"
|
|
snippet '(?<!\\)(sin|cos|arccot|cot|csc|ln|log|exp|star|perp)' "ln" rwA
|
|
\\`!p snip.rv = match.group(1)`
|
|
endsnippet
|
|
|
|
priority 300
|
|
context "math()"
|
|
snippet dint "integral" wA
|
|
\int_{${1}}^{${2}} ${3} $0
|
|
endsnippet
|
|
|
|
priority 200
|
|
context "math()"
|
|
snippet '(?<!\\)(arcsin|arccos|arctan|arccot|arccsc|arcsec|pi|zeta|int)' "ln" rwA
|
|
\\`!p snip.rv = match.group(1)`
|
|
endsnippet
|
|
|
|
priority 100
|
|
context "math()"
|
|
snippet -> "to" iA
|
|
\to
|
|
endsnippet
|
|
|
|
priority 200
|
|
context "math()"
|
|
snippet <-> "leftrightarrow" iA
|
|
\leftrightarrow
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet !> "mapsto" iA
|
|
\mapsto
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet invs "inverse" iA
|
|
^{-1}
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet compl "complement" iA
|
|
^{c}
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet set "set" wA
|
|
\\{$1\\} $0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet cc "subset" Ai
|
|
\subset
|
|
endsnippet
|
|
|
|
snippet notin "not in " iA
|
|
\not\in
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet inn "in " iA
|
|
\in
|
|
endsnippet
|
|
|
|
snippet NN "n" iA
|
|
\N
|
|
endsnippet
|
|
|
|
snippet Nn "cap" iA
|
|
\cap
|
|
endsnippet
|
|
|
|
snippet UU "cup" iA
|
|
\cup
|
|
endsnippet
|
|
|
|
priority 10
|
|
context "math()"
|
|
snippet "bar" "bar" riA
|
|
\overline{$1}$0
|
|
endsnippet
|
|
|
|
priority 100
|
|
context "math()"
|
|
snippet "([a-zA-Z])bar" "bar" riA
|
|
\overline{`!p snip.rv=match.group(1)`}
|
|
endsnippet
|
|
|
|
priority 10
|
|
context "math()"
|
|
snippet "hat" "hat" riA
|
|
\hat{$1}$0
|
|
endsnippet
|
|
|
|
priority 100
|
|
context "math()"
|
|
snippet "([a-zA-Z])hat" "hat" riA
|
|
\hat{`!p snip.rv=match.group(1)`}
|
|
endsnippet
|