diff --git a/custom-snippets/tex.snippets b/custom-snippets/tex.snippets index 43c594d..f9ca19d 100644 --- a/custom-snippets/tex.snippets +++ b/custom-snippets/tex.snippets @@ -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)`}