fix: The exit itemize snippet

This commit is contained in:
Sayantan Santra 2024-03-16 01:01:42 -05:00
parent 9189537120
commit b6118c1985
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F

View file

@ -9,6 +9,11 @@ def itemize_like():
return False
def get_env():
return vim.eval('vimtex#env#get_inner()["name"]')
def delline_exititemize(snip):
cursorline = snip.cursor[0]
del snip.buffer[cursorline]
snip.buffer.append("\n", cursorline + 1)
snip.cursor.set(cursorline + 1, 0)
endglobal
@ -23,20 +28,17 @@ snippet "\\item\s*\S+.*" "create next item" rb
endsnippet
context itemize_like()
pre_expand "del snip.buffer[snip.line]; snip.cursor.set(snip.line, len(snip.buffer[snip.line]))"
post_jump "delline_exititemize(snip)"
snippet "\\item\s*$" "exit itemize_like envs" rb
$0
endsnippet
context not itemize_like()
snippet "\\begin\{(\w+)\}" "multiline begin{} / end{}" rb
snippet "\\begin\{((?!itemize|enumerate))\}" "multiline begin{} / end{}" rb
\begin{`!p snip.rv = match.group(1)`}
$1
\end{`!p snip.rv = match.group(1)`}
endsnippet
context itemize_like()
snippet "\\begin\{(\w+)\}" "multiline begin{} / end{}" rb
snippet "\\begin\{(itemize|enumerate)\}" "multiline begin{} / end{}" rb
\begin{`!p snip.rv = match.group(1)`}
\item $1
\end{`!p snip.rv = match.group(1)`}