First commit
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
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
|
||||
|
||||
snippet beg "begin{} / end{}" bA
|
||||
\\begin{$1}
|
||||
$0
|
||||
\\end{$1}
|
||||
endsnippet
|
||||
|
||||
|
||||
priority 100
|
||||
snippet ... "dots" iA
|
||||
\dots
|
||||
endsnippet
|
||||
|
||||
snippet km "Math" wA
|
||||
$${1}$`!p
|
||||
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
|
||||
snip.rv = ' '
|
||||
else:
|
||||
snip.rv = ''
|
||||
`$2
|
||||
endsnippet
|
||||
|
||||
snippet dm "Math" wA
|
||||
\[
|
||||
${1:${VISUAL}}
|
||||
\] $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
|
||||
|
||||
context "math()"
|
||||
snippet '([A-Za-z])_' "auto subscript2" wrA
|
||||
`!p snip.rv = match.group(1)`_{$1}$0
|
||||
endsnippet
|
||||
|
||||
snippet enum "Enumerate" bA
|
||||
\begin{enumerate}
|
||||
\item $0
|
||||
\end{enumerate}
|
||||
endsnippet
|
||||
|
||||
snippet item "Itemize" bA
|
||||
\begin{itemize}
|
||||
\item $0
|
||||
\end{itemize}
|
||||
endsnippet
|
||||
|
||||
snippet sum "sum" w
|
||||
\sum_{n=${1:1}}^{${2:\infty}} ${3:a_n z^n}
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet mat "Matrice symbol" A
|
||||
\mathcal{M}_{${1:n},${2:p}}(${3:\mathbb{R}})$0
|
||||
endsnippet
|
||||
|
||||
snippet pmat "pmat" bA
|
||||
\begin{pmatrix}
|
||||
$0
|
||||
\end{pmatrix}
|
||||
endsnippet
|
||||
|
||||
snippet // "Fraction" iA
|
||||
\\frac{$1}{$2}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
|
||||
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
priority 1000
|
||||
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 text "text zone" A
|
||||
\text{ $1 }$0
|
||||
endsnippet
|
||||
|
||||
snippet def "definition" bA
|
||||
\begin{definition}[$1]
|
||||
$0
|
||||
\end{definition}
|
||||
endsnippet
|
||||
|
||||
snippet space "space" i
|
||||
\hspace{3ex} $0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet bar "overline bar" iA
|
||||
\overline{$1}$0
|
||||
endsnippet
|
||||
Reference in New Issue
Block a user