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