From d426810e81a9db2583e1b2e2aec85f96940383f1 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sat, 16 Mar 2024 15:55:28 -0500 Subject: [PATCH] fix: Weird extra jump --- custom-snippets/tex.snippets | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/custom-snippets/tex.snippets b/custom-snippets/tex.snippets index f9ca19d..74e4f82 100644 --- a/custom-snippets/tex.snippets +++ b/custom-snippets/tex.snippets @@ -2,9 +2,9 @@ global !p # def math(): # return vim.eval('vimtex#syntax#in_mathzone()') == '1' -def itemize_like(): +def in_env(lst): try: - return get_env() in ["itemize", "enumerate"] + return get_env() in lst except: return False def get_env(): @@ -19,28 +19,26 @@ endglobal priority -10 -extends tex - -context itemize_like() +context in_env(["itemize", "enumerate"]) snippet "\\item\s*\S+.*" "create next item" rb `!p snip.rv = match.group(0)` \item $0 endsnippet -context itemize_like() +context in_env(["itemize", "enumerate"]) post_jump "delline_exititemize(snip)" snippet "\\item\s*$" "exit itemize_like envs" rb endsnippet -snippet "\\begin\{((?!itemize|enumerate))\}" "multiline begin{} / end{}" rb +snippet "\\begin\{(itemize|enumerate)\}" "multiline begin{} / end{}" rb \begin{`!p snip.rv = match.group(1)`} - $1 + \item $0 \end{`!p snip.rv = match.group(1)`} endsnippet -snippet "\\begin\{(itemize|enumerate)\}" "multiline begin{} / end{}" rb +snippet "\\begin\{((?!itemize|enumerate))\}" "multiline begin{} / end{}" rb \begin{`!p snip.rv = match.group(1)`} - \item $1 + $0 \end{`!p snip.rv = match.group(1)`} endsnippet