2024-03-14 18:12:35 -05:00
|
|
|
global !p
|
|
|
|
|
|
|
|
# def math():
|
|
|
|
# return vim.eval('vimtex#syntax#in_mathzone()') == '1'
|
|
|
|
def itemize_like():
|
2024-03-15 09:21:36 -05:00
|
|
|
try:
|
|
|
|
return get_env() in ["itemize", "enumerate"]
|
|
|
|
except:
|
|
|
|
return False
|
2024-03-14 18:12:35 -05:00
|
|
|
def get_env():
|
|
|
|
return vim.eval('vimtex#env#get_inner()["name"]')
|
|
|
|
|
|
|
|
endglobal
|
|
|
|
|
2024-03-13 14:07:20 -05:00
|
|
|
priority -10
|
|
|
|
|
|
|
|
extends tex
|
|
|
|
|
2024-03-14 18:12:35 -05:00
|
|
|
context itemize_like()
|
2024-03-14 19:13:50 -05:00
|
|
|
snippet "\\item\s*\S+.*" "create next item" rb
|
2024-03-14 18:12:35 -05:00
|
|
|
`!p snip.rv = match.group(0)`
|
|
|
|
\item $0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
context itemize_like()
|
2024-03-15 09:21:36 -05:00
|
|
|
pre_expand "del snip.buffer[snip.line]; snip.cursor.set(snip.line, len(snip.buffer[snip.line]))"
|
2024-03-14 18:12:35 -05:00
|
|
|
snippet "\\item\s*$" "exit itemize_like envs" rb
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
context not itemize_like()
|
|
|
|
snippet "\\begin\{(\w+)\}" "multiline begin{} / end{}" rb
|
2024-03-13 14:07:20 -05:00
|
|
|
\begin{`!p snip.rv = match.group(1)`}
|
|
|
|
$1
|
|
|
|
\end{`!p snip.rv = match.group(1)`}
|
|
|
|
endsnippet
|
|
|
|
|
2024-03-14 18:12:35 -05:00
|
|
|
context itemize_like()
|
|
|
|
snippet "\\begin\{(\w+)\}" "multiline begin{} / end{}" rb
|
|
|
|
\begin{`!p snip.rv = match.group(1)`}
|
|
|
|
\item $1
|
|
|
|
\end{`!p snip.rv = match.group(1)`}
|
|
|
|
endsnippet
|
|
|
|
|
2024-03-13 14:07:20 -05:00
|
|
|
priority -20
|
|
|
|
|
2024-03-14 18:12:35 -05:00
|
|
|
snippet "(?<!^)\\begin\{(\w+)\}" "inline begin{} / end{}" ri
|
2024-03-13 14:07:20 -05:00
|
|
|
\begin{`!p snip.rv = match.group(1)`} $1 \end{`!p snip.rv = match.group(1)`} $0
|
|
|
|
endsnippet
|
|
|
|
|