dotfiles/nvim/ultisnips/tex.snippets

115 lines
1.7 KiB
Plaintext
Raw Normal View History

2022-11-09 19:09:19 -05:00
global !p
2022-11-19 13:46:44 -05:00
# thanks to gilles castel
2022-11-09 19:09:19 -05:00
def math():
return vim.eval('vimtex#syntax#in_mathzone()') == '1'
2022-11-19 13:46:44 -05:00
def env(name):
[x,y] = vim.eval("vimtex#env#is_inside('" + name + "')")
return x != '0' and y != '0'
2022-11-09 19:09:19 -05:00
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
2022-11-19 13:46:44 -05:00
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
2022-11-09 19:09:19 -05:00