dotfiles/nvim/ultisnips/tex.snippets
2022-11-19 13:46:44 -05:00

115 lines
1.7 KiB
Plaintext

global !p
# thanks to gilles castel
def math():
return vim.eval('vimtex#syntax#in_mathzone()') == '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}
$2
\\end{$1}$0
endsnippet
snippet sm "Math" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dm "Display Math" wA
\[
$1
.\] $0
endsnippet
snippet sc "Code" wA
\texttt{${1}}`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dc "Display Code" wA
\begin{lstlisting}[$1]
$2
\end{lstlisting} $0
endsnippet
snippet pac "Package" b
\usepackage[$1]{$2}$0
endsnippet
snippet template "Basic template" b
\documentclass[$1]{$2}
$3
\begin{document}
$0
\end{document}
endsnippet
snippet item "Itemize" bA
\begin{itemize}
\item $0
\end{itemize}
endsnippet
snippet enum "Enumerate" bA
\begin{enumerate}
\item $0
\end{enumerate}
endsnippet
snippet alph "Alphabet Enumerate" bA
\begin{enumerate}[label= (\alph*)]
\item $1
\end{enumerate} $0
endsnippet
snippet desc "Description" bA
\begin{description}
\item[$1] $2
\end{description} $0
endsnippet
snippet table "Table" b
\begin{table}[${1:htpb}]
\centering
\caption{${2:caption}}
\label{tab:${3:label}}
\begin{tabular}{${5:c}}
$6${5/((?<=.)c|l|r)|./(?1: & )/g}
\end{tabular}
\end{table} $0
endsnippet
snippet ltable "Long table" b
\begin{longtable}{${1:|p{5cm}|p{10cm}|}}
\hline
$2
\hline
\end{longtable} $0
endsnippet
snippet --- "hline" iA
\hline
endsnippet