fix: The exit itemize snippet
This commit is contained in:
parent
9189537120
commit
b6118c1985
1 changed files with 8 additions and 6 deletions
|
@ -9,6 +9,11 @@ def itemize_like():
|
||||||
return False
|
return False
|
||||||
def get_env():
|
def get_env():
|
||||||
return vim.eval('vimtex#env#get_inner()["name"]')
|
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
|
endglobal
|
||||||
|
|
||||||
|
@ -23,20 +28,17 @@ snippet "\\item\s*\S+.*" "create next item" rb
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
context itemize_like()
|
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
|
snippet "\\item\s*$" "exit itemize_like envs" rb
|
||||||
$0
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
context not itemize_like()
|
snippet "\\begin\{((?!itemize|enumerate))\}" "multiline begin{} / end{}" rb
|
||||||
snippet "\\begin\{(\w+)\}" "multiline begin{} / end{}" rb
|
|
||||||
\begin{`!p snip.rv = match.group(1)`}
|
\begin{`!p snip.rv = match.group(1)`}
|
||||||
$1
|
$1
|
||||||
\end{`!p snip.rv = match.group(1)`}
|
\end{`!p snip.rv = match.group(1)`}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
context itemize_like()
|
snippet "\\begin\{(itemize|enumerate)\}" "multiline begin{} / end{}" rb
|
||||||
snippet "\\begin\{(\w+)\}" "multiline begin{} / end{}" rb
|
|
||||||
\begin{`!p snip.rv = match.group(1)`}
|
\begin{`!p snip.rv = match.group(1)`}
|
||||||
\item $1
|
\item $1
|
||||||
\end{`!p snip.rv = match.group(1)`}
|
\end{`!p snip.rv = match.group(1)`}
|
||||||
|
|
Loading…
Reference in a new issue