mirror of https://github.com/zoomiti/dotfiles.git
254 lines
4.4 KiB
Plaintext
254 lines
4.4 KiB
Plaintext
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 x != '0'
|
|
|
|
endglobal
|
|
|
|
snippet fig "Figure environment" b
|
|
\begin{figure}[${1:htpb}]
|
|
\centering
|
|
${2:\includegraphics[width=0.8\textwidth]{$3}}
|
|
\caption{${4:$3}}
|
|
\label{fig:${5:${3/\W+/-/g}}}
|
|
\end{figure}
|
|
endsnippet
|
|
|
|
snippet table "Table environment" b
|
|
\begin{table}[${1:htpb}]
|
|
\centering
|
|
\caption{${2:caption}}
|
|
\label{tab:${3:label}}
|
|
\begin{tabular}{${5:c}}
|
|
$0${5/((?<=.)c|l|r)|./(?1: & )/g}
|
|
\end{tabular}
|
|
\end{table}
|
|
endsnippet
|
|
|
|
snippet beg "\begin{}...\end{}" bA
|
|
\\begin{$1}
|
|
$0
|
|
\\end{$1}
|
|
endsnippet
|
|
|
|
snippet enum "list"
|
|
\begin{enumerate}[label=$1]
|
|
\item $0
|
|
\end{enumerate}
|
|
endsnippet
|
|
|
|
snippet mk "Math" wA
|
|
$${1}$`!p
|
|
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
|
|
snip.rv = ' '
|
|
else:
|
|
snip.rv = ''
|
|
`$2
|
|
endsnippet
|
|
|
|
snippet dm "Math" wA
|
|
\[
|
|
$2
|
|
${1:.}\] $0
|
|
endsnippet
|
|
|
|
snippet ali "Align" bA
|
|
\begin{align*}
|
|
${2:${VISUAL}}
|
|
${1:.}\end{align*}
|
|
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 sr "^2" iA
|
|
^2
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet cb "^3" iA
|
|
^3
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet td "superscript" iA
|
|
^{$1}$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet // "Fraction" iA
|
|
\\frac{$1}{$2}$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet / "Fraction" i
|
|
\\frac{${VISUAL}}{$1}$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
|
|
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
|
|
endsnippet
|
|
|
|
priority 1000
|
|
context "math()"
|
|
snippet '^.*\)/' "() Fraction" wrA
|
|
`!p
|
|
stripped = match.string[:-1]
|
|
depth = 0
|
|
i = len(stripped) - 1
|
|
while True:
|
|
if stripped[i] == ')': depth += 1
|
|
if stripped[i] == '(': depth -= 1
|
|
if depth == 0: break;
|
|
i -= 1
|
|
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
|
|
`{$1}$0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet () "left( right)" iA
|
|
\left( ${1:${VISUAL}} \right) $0
|
|
endsnippet
|
|
|
|
snippet lr "left( right)" i
|
|
\left( ${1:${VISUAL}} \right) $0
|
|
endsnippet
|
|
|
|
snippet lr( "left( right)" i
|
|
\left( ${1:${VISUAL}} \right) $0
|
|
endsnippet
|
|
|
|
snippet lr| "left| right|" i
|
|
\left| ${1:${VISUAL}} \right| $0
|
|
endsnippet
|
|
|
|
snippet lr{ "left\{ right\}" i
|
|
\left\\{ ${1:${VISUAL}} \right\\} $0
|
|
endsnippet
|
|
|
|
snippet lrb "left\{ right\}" i
|
|
\left\\{ ${1:${VISUAL}} \right\\} $0
|
|
endsnippet
|
|
|
|
snippet lr[ "left[ right]" i
|
|
\left[ ${1:${VISUAL}} \right] $0
|
|
endsnippet
|
|
|
|
snippet lra "leftangle rightangle" iA
|
|
\left<${1:${VISUAL}} \right>$0
|
|
endsnippet
|
|
|
|
snippet sum "sum" w
|
|
\sum_{n=${1:1}}^{${2:\infty}} ${3:a_n z^n}
|
|
endsnippet
|
|
|
|
snippet taylor "taylor" w
|
|
\sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1 $0
|
|
endsnippet
|
|
|
|
snippet lim "limit" w
|
|
\lim_{${1:n} \to ${2:\infty}}
|
|
endsnippet
|
|
|
|
snippet limsup "limsup" w
|
|
\limsup_{${1:n} \to ${2:\infty}}
|
|
endsnippet
|
|
|
|
snippet prod "product" w
|
|
\prod_{${1:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}} $0
|
|
endsnippet
|
|
|
|
snippet part "d/dx" w
|
|
\frac{\partial ${1:V}}{\partial ${2:x}} $0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet sq "\sqrt{}" iA
|
|
\sqrt{${1:${VISUAL}}} $0
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet sr "^2" iA
|
|
^2
|
|
endsnippet
|
|
|
|
snippet plot "Plot" w
|
|
\begin{figure}[$1]
|
|
\centering
|
|
\begin{tikzpicture}
|
|
\begin{axis}[
|
|
xmin= ${2:-10}, xmax= ${3:10},
|
|
ymin= ${4:-10}, ymax = ${5:10},
|
|
axis lines = middle,
|
|
]
|
|
\addplot[domain=$2:$3, samples=${6:100}]{$7};
|
|
\end{axis}
|
|
\end{tikzpicture}
|
|
\caption{$8}
|
|
\label{${9:$8}}
|
|
\end{figure}
|
|
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:-\infty}}^{${2:\infty}} ${3:${VISUAL}} $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
|
|
|
|
context "math()"
|
|
snippet case "cases" wA
|
|
\begin{cases}
|
|
$1
|
|
\end{cases}
|
|
endsnippet
|
|
|
|
snippet ooo "\infty" iA
|
|
\infty
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet nn "hn" iA
|
|
[n]
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet tt "ht" iA
|
|
(t)
|
|
endsnippet
|
|
|
|
context "math()"
|
|
snippet ss "hs" iA
|
|
(s)
|
|
endsnippet
|