vimrc

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules

commit 1633f3284a0be2e3f600a78bfe8fc95a6986e017
parent bc2b19329b1face094dc4a6cdc6cf74c6f3971f3
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Thu,  2 Mar 2023 06:58:00 -0500

Ultisnippet: move amsthm to separate file

Diffstat:
MUltiSnips/tex.snippets | 40++++------------------------------------
AUltiSnips/tex/amsthm.snippets | 50++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 36 deletions(-)

diff --git a/UltiSnips/tex.snippets b/UltiSnips/tex.snippets @@ -19,20 +19,7 @@ snippet template "Basic template" b \usepackage{amssymb, mathtools, mathrsfs} \usepackage[paperwidth=11cm,paperheight=13cm,left=5mm,right=5mm,top=5mm,bottom=5mm]{geometry} -\usepackage{amsthm} -\newtheorem{proposition}{Proposition} -\newtheorem{theorem}{Theorem} -\newtheorem{lemma}{Lemma} -\newtheorem{affirmation}{Affirmation} -\newtheorem{exercise}{Exercise} -\newtheorem{problem}{Problem} -\theoremstyle{definition} -\newtheorem{definition}{Definition} -\theoremstyle{remark} -\newtheorem{example}{Example} -\newtheorem{corolary}{Corolary} -\newtheorem{observation}{Observation} -\newtheorem{remark}{Remark} +$1 \begin{document} $0 @@ -484,7 +471,7 @@ endsnippet snippet bigfun "Big function" \begin{align*} - $1: ${2:X} &\longrightarrow ${3:R} \\\\ + $1: ${2:X} &\longrightarrow ${3:\mathbb{R}} \\\\ $4 &\longmapsto $1($4) \coloneqq $0 .\end{align*} endsnippet @@ -493,27 +480,16 @@ endsnippet context "math()" snippet fun "f: A -> B" w -${1:f}\colon ${2:U} \to ${3:\mathbb{R}} +${1:f}\colon ${2:X} \to ${3:\mathbb{R}} endsnippet context "not math()" snippet fun "f: A -> B" w -$${1:f}\colon ${2:U} \to ${3:\mathbb{R}}$ +$${1:f}\colon ${2:X} \to ${3:\mathbb{R}}$ endsnippet # --------------------------------------------- # -snippet newt "\newtheorem" b -\newtheorem{${1:theorem}}{${2:`!p snip.rv = t[1].title()`}} -endsnippet - -snippet thmsty "\theoremstyle" b -\theoremstyle{$1`!p snip.rv = complete(t[1], ['plain', 'definition', 'remark'])`}$0 -endsnippet - - -# --------------------------------------------- # - snippet h1 "section" bA \section{${1:${VISUAL:}}} $0 @@ -531,14 +507,6 @@ endsnippet # --------------------------------------------- # -priority 1 -snippet def "begin{definition}" b -\begin{definition}[${1}] - $2 `!p snip.rv = " ".join(f'\\emph{{{s.strip().lower()}}}' for s in t[1].split(','))` $0 -\end{definition} -endsnippet - - context "math()" snippet ## "#" iA \#(${1:${VISUAL}})$0 diff --git a/UltiSnips/tex/amsthm.snippets b/UltiSnips/tex/amsthm.snippets @@ -0,0 +1,50 @@ +priority 1 + +global !p +def math(): + return vim.eval('vimtex#syntax#in_mathzone()') == '1' +def comment(): + return vim.eval('vimtex#syntax#in_comment()') == '1' +def env(name): + x, y = vim.eval("vimtex#env#is_inside('" + name + "')") + return x != '0' and y != '0' +endglobal + + +context "not math()" +snippet amsthm "amsthm" b +\usepackage{amsthm} +\newtheorem{theorem}{Theorem} +\newtheorem{proposition}{Proposition} +\newtheorem{lemma}{Lemma} +\newtheorem{corolary}{Corolary} +\newtheorem{affirmation}{Affirmation} +\newtheorem{exercise}{Exercise} +\newtheorem{problem}{Problem} +\theoremstyle{definition} +\newtheorem{definition}{Definition} +\theoremstyle{remark} +\newtheorem{example}{Example} +\newtheorem{observation}{Observation} +\newtheorem{remark}{Remark} +endsnippet + +context "not math()" +snippet newthm "\newtheorem" b +\newtheorem{${1:theorem}}{${2:`!p snip.rv = t[1].title()`}} +endsnippet + +context "not math()" +snippet thmsty "\theoremstyle" b +\theoremstyle{$1`!p snip.rv = complete(t[1], ['plain', 'definition', 'remark'])`}$0 +endsnippet + +# --------------------------------------------- # + +context "not math()" +snippet def "begin{definition}" b +\begin{definition}[${1}] + $2 `!p snip.rv = " ".join(f'\\emph{{{s.strip().lower()}}}' for s in t[1].split(','))` $3 +\end{definition} +$0 +endsnippet