commit 5254cf1ace778e9d18a1de0fe7c988653d3ea379 parent 3106e339a32494ab031b902a8fe368c5c01c3026 Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe> Date: Thu, 23 Jul 2026 03:00:44 -0300 Bye UltiSnips UltiSnips is slow because it relies on Python, which adds noticeable overhead during expansion. Replace it with my own package, `snippets`, to improve performance and reduce dependencies. Diffstat:
| D | UltiSnips/plaintex.snippets | | | 13 | ------------- |
| D | UltiSnips/python.snippets | | | 332 | ------------------------------------------------------------------------------- |
| D | UltiSnips/python/click.snippets | | | 7 | ------- |
| D | UltiSnips/python/gymnasium.snippets | | | 34 | ---------------------------------- |
| D | UltiSnips/python/manim.snippets | | | 16 | ---------------- |
| D | UltiSnips/python/matplotlib.snippets | | | 4 | ---- |
| D | UltiSnips/python/numpy.snippets | | | 7 | ------- |
| D | UltiSnips/python/pandas.snippets | | | 6 | ------ |
| D | UltiSnips/python/pygame.snippets | | | 42 | ------------------------------------------ |
| D | UltiSnips/python/pyside.snippets | | | 49 | ------------------------------------------------- |
| D | UltiSnips/python/torch.snippets | | | 29 | ----------------------------- |
| D | UltiSnips/python/win32clipboard.py | | | 5 | ----- |
| D | UltiSnips/tex.snippets | | | 715 | ------------------------------------------------------------------------------- |
| D | UltiSnips/tex/amsthm.snippets | | | 42 | ------------------------------------------ |
| D | UltiSnips/tex/greek.snippets | | | 159 | ------------------------------------------------------------------------------- |
15 files changed, 0 insertions(+), 1460 deletions(-)
diff --git a/UltiSnips/plaintex.snippets b/UltiSnips/plaintex.snippets @@ -1,13 +0,0 @@ -snippet latex "Basic template" b -\documentclass[a4paper]{article} - -\usepackage{amsmath,amssymb} - -${1:\input macros} - -\begin{document} - -$0 - -\end{document} -endsnippet diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets @@ -1,332 +0,0 @@ -snippet #! "#!/usr/bin/env python" b -#!/usr/bin/env python -$0 -endsnippet - - -snippet ifmain "ifmain" b -if __name__ == "__main__": - ${1:${VISUAL:main()}} -endsnippet - - -snippet with "with" b -with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}: - ${3:${VISUAL:pass}} -$0 -endsnippet - - -snippet for "for loop" b -for ${1:item} in ${2:iterable}: - ${3:${VISUAL:pass}} -$0 -endsnippet - -# --------------------------------------------- # - -snippet sized "Sized" b -def __len__(self): - ${2:pass} -endsnippet - - -snippet sequence "Sequence" b -def __getitem__(self, index): - ${1:pass} - -def __len__(self): - ${2:pass} -endsnippet - - -snippet contextmanager "AbstractContextManager" b -def __enter__(self): - ${1:pass} - -def __exit__(self, exc_type, exc_value, traceback): - ${2:pass} -endsnippet - - -snippet descriptor "Descriptor" b -def __get__(self, instance, owner): - ${1:pass} - -def __set__(self, instance, value): - ${2:pass} - -def __delete__(self, instance): - ${3:pass} -endsnippet - - -snippet repr "__repr__" b -def __repr__(self): - ${1:pass} -endsnippet - -# --------------------------------------------- # - -global !p - -class Arg: - def __init__(self, arg): - self.arg = arg - name_and_type = arg.split('=')[0].split(':') - self.name = name_and_type[0].strip() - self.type = name_and_type[1].strip() if len(name_and_type) == 2 else None - -def get_args(arglist): - args = [] - n = len(arglist) - i = 0 - while i < n: - l_bracket = 0 - start = i - while i < n and (l_bracket > 0 or arglist[i] != ','): - if arglist[i] == '[': - l_bracket += 1 - elif arglist[i] == ']' and l_bracket > 0: - l_bracket -= 1 - i += 1 - arg = arglist[start:i] - if arg: - args.append(Arg(arg)) - i += 1 - - args = [arg for arg in args if arg.name != 'self'] - - return args -endglobal - - -snippet def "function with docstrings" b -def ${1:function}(`!p -if snip.indent: - snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1: Type1}) -> ${3:None}:`!p -snip.rv = "" -if t[4]: - snip >> 1 - snip += '"""' - snip += "" -`${4:TODO: Docstring for $1.}`!p -snip.rv = "" -if t[4]: - snip >> 1 - - args = get_args(t[2]) - for arg in args: - snip += ":param {}: TODO".format(arg.name) - - if t[3] != "None": - snip += ":returns: TODO" - - snip += '"""' -` - ${5:${VISUAL:pass}} -endsnippet - - -snippet defc "class method with docstrings" b -@classmethod -def ${1:function}(`!p -if snip.indent: - snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}) -> ${3:None}: - """${4:TODO: Docstring for $1.}`!p - -snip.rv = "" -snip >> 1 - -args = get_args(t[2]) -for arg in args: - snip += ":param {}: TODO".format(arg.name) - -if t[3] != "None": - snip += ":returns: TODO" -` - """ - ${5:${VISUAL:pass}} -endsnippet - - -snippet defs "static method with docstrings" b -@staticmethod -def ${1:function}(${2:arg1}) -> ${3:None}: - """${4:TODO: Docstring for $1.}`!p -snip.rv = "" -snip >> 1 - -args = get_args(t[2]) -for arg in args: - snip += ":param {}: TODO".format(arg.name) - -if t[3] != "None": - snip += ":returns: TODO" -` - """ - - ${5:${VISUAL:pass}} -endsnippet - - -snippet class "class with docstrings" b -class ${1:MyClass}`!p snip.rv = "(" if t[2] else ""`${2:Parent}`!p snip.rv = ")" if t[2] else ""`: - """${3:Docstring for $1.}`!p -snip.rv = "" -snip >> 1 -args = get_args(t[4]) -if args: - snip.rv += "\n" + snip.mkline("") -for arg in args: - snip += ":param {}: TODO".format(arg.name) -` - """ - def __init__(self`!p snip.rv = ", " if t[4] else ""`${4:arg1: Type1}) -> None:`!p -snip >> 2 -snip.rv = "" -if t[2]: - # If has parent class - snip += "super().__init__()" - -if args and t[2]: - snip.rv += '\n' + snip.mkline("") - -for arg in args: - # Initialize attributes - snip += "self._{} = {}".format(arg.name, arg.name) -` - - $5 -endsnippet - - -snippet dcl "dataclass" b -@dataclass`!p snip.rv = "(" if t[1] or t[2] else ""`${1/(.+)/(?1:frozen=)/}${1:True}`!p snip.rv = ', ' if t[1] and t[2] else ""`${2/(.+)/(?1:order=)/}${2:True}`!p snip.rv = ")" if t[1] or t[2] else ""` -class ${3:MyClass}: - """${4:Docstring for $3.} - """ - var_1: int - var_2: float - var_3: str -endsnippet - - -snippet namedtuple "namedtuple" b -${1:MyNamedTuple} = namedtuple("$1", (${2:"attr1", "attr2"})) -$0 - -endsnippet - - -snippet if "If" b -if ${1:condition}: - ${2:${VISUAL:pass}} -endsnippet - - -snippet ife "If / Else" b -if ${1:condition}: - ${2:${VISUAL:pass}} -else: - ${3:pass} -endsnippet - - -snippet ifee "If / Elif / Else" b -if ${1:condition}: - ${2:${VISUAL:pass}} -elif ${3:condition}: - ${4:pass} -else: - ${5:pass} -endsnippet - - -snippet initpkg "Init file for package" b -"""${1:project_name} - -${2:project_description} -""" - -__version__ = "${3:0.1}" -endsnippet - - -snippet ppe "ProcessPoolExecutor" b -with concurrent.futures.ProcessPoolExecutor(max_workers=${1:4}) as executor: - ${0:emap or cfac} -endsnippet - - -snippet tpe "ThreadPoolExecutor" b -with concurrent.futures.ThreadPoolExecutor(max_workers=${1:4}) as executor: - ${0:emap or cfac} -endsnippet - - -snippet emap "executor.map" b -${1:results} = executor.map(${2:func}, ${3:iterable}) -$0 -endsnippet - - -snippet cfac "concurrent.futures.as_completed" b -futures = (executor.submit(${1:func}, ${2:args}) for $2 in ${3:iterable}) - -for future in concurrent.futures.as_completed(futures): - result = future.result() - $0 -endsnippet - - -snippet perf_counter "time.perf_counter()" b -start_time = time.perf_counter() -print("Start: ${1:name}") - -${2:${VISUAL:pass}} - -end_time = time.perf_counter() -print(f"End: $1 ({end_time - start_time:.2f}s)") -$0 -endsnippet - - -snippet tempdir "tempfile.TemporaryDirectory()" b -with tempfile.TemporaryDirectory() as ${1:tmpdirname}: - ${2:${VISUAL:pass}} -endsnippet - - -snippet zipfile "zipfile.ZipFile" b -with zipfile.ZipFile(${1:zip_path},"r") as zip_ref: - zip_ref.extract(member, target_dir) - zip_ref.extractall(target_dir) - $0 -endsnippet - - -snippet ET "xml.etree.ElementTree" b -tree = ET.parse(${1:path}) -${2:root} = tree.getroot() -endsnippet - - -snippet printf "print(f'{value=}')" b -print(f"{${1:value}=}") -endsnippet - - -snippet importlib "import file" b -spec = importlib.util.spec_from_file_location(${1:module_name}, ${2:file_path}) -${3:module} = importlib.util.module_from_spec(spec) -spec.loader.exec_module($3) -$0 -endsnippet - - -snippet argparse "argparse" b -parser = argparse.ArgumentParser() -parser.add_argument(${1:"arg1"}) -args = parser.parse_args() -endsnippet diff --git a/UltiSnips/python/click.snippets b/UltiSnips/python/click.snippets @@ -1,7 +0,0 @@ -snippet clickio "Click command for input/output" b -@click.command() -@click.argument("input", type=click.File("r"), default="-") -@click.argument("output", type=click.File("w"), default="-") -def main(input, output): - ${0:${VISUAL:pass}} -endsnippet diff --git a/UltiSnips/python/gymnasium.snippets b/UltiSnips/python/gymnasium.snippets @@ -1,34 +0,0 @@ -snippet gym "gym loop" b -from itertools import count - -import gymnasium as gym - - -env = gym.make("${1:CartPole-v1}"`!p -snip.rv = ', render_mode="' if t[2] else "" -`${2:human}`!p -snip.rv = '"' if t[2] else "" -`) - -for episode in count(): - observation, info = env.reset(`!p snip.rv = "seed=" if t[3] else ""`${3:42}) - - for t in count(): - # Select an action - action = env.action_space.sample() - - # Perform action in the enviroment - next_observation, reward, terminated, truncated, info = env.step( - action - ) - - $0 - - if terminated or truncated: - break - observation = next_observation - - print(f"{episode=}, {t+1=}") - -env.close() -endsnippet diff --git a/UltiSnips/python/manim.snippets b/UltiSnips/python/manim.snippets @@ -1,16 +0,0 @@ -snippet scene "Manim scene" b -class ${1:DefaultScene}(Scene): - def construct(self): - ${0:${VISUAL:pass}} -endsnippet - -snippet tempconfig "Manim tempconfig" b -with tempconfig( - { - "quality": "low_quality", - "preview": True, - } -): - scene = ${1:DefaultScene}() - scene.render() -endsnippet diff --git a/UltiSnips/python/matplotlib.snippets b/UltiSnips/python/matplotlib.snippets @@ -1,4 +0,0 @@ -snippet plt "import matplotlib.pyplot as plt" b -import matplotlib.pyplot as plt -$0 -endsnippet diff --git a/UltiSnips/python/numpy.snippets b/UltiSnips/python/numpy.snippets @@ -1,7 +0,0 @@ -snippet np "import numpy as np" b -import numpy as np -from numpy.random import default_rng - -np.set_printoptions(linwidth=80, edgeitems=3) -$0 -endsnippet diff --git a/UltiSnips/python/pandas.snippets b/UltiSnips/python/pandas.snippets @@ -1,6 +0,0 @@ -snippet iterrows "pandas iterrows bucle" b -for i_$1, row_$1 in $2.iterrows(): - ${3:${VISUAL:pass}} -$0 -endsnippet - diff --git a/UltiSnips/python/pygame.snippets b/UltiSnips/python/pygame.snippets @@ -1,42 +0,0 @@ -snippet pygame "pygame template" b -import pygame - -pygame.init() -width, height = 640, 360 -screen = pygame.display.set_mode((width, height)) - -pygame.font.init() -font = pygame.font.Font(None, 20) - -clock = pygame.time.Clock() -running = True -dt = 0 - -player_pos = pygame.Vector2(width / 2, height / 2) - -while running: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - running = False - - - keys = pygame.key.get_pressed() - if keys[pygame.K_k]: - player_pos.y -= 300 * dt - if keys[pygame.K_j]: - player_pos.y += 300 * dt - if keys[pygame.K_h]: - player_pos.x -= 300 * dt - if keys[pygame.K_l]: - player_pos.x += 300 * dt - - screen.fill("purple") - pygame.draw.circle(screen, "red", player_pos, 40) - text = font.render("Hello world", True, "white") - screen.blit(text, player_pos) - pygame.display.flip() - - dt = clock.tick(60) / 1000 - -pygame.quit() -endsnippet diff --git a/UltiSnips/python/pyside.snippets b/UltiSnips/python/pyside.snippets @@ -1,49 +0,0 @@ -snippet pyside "pyside" b -import sys -from PySide6.QtWidgets import QApplication - - -app = QApplication(sys.argv) - -${0:${VISUAL:# ...}} - -sys.exit(app.exec()) -endsnippet - - -snippet QWidget "QWidget" b -from PySide6.QtWidgets import QWidget - -class ${1:MyWidget}(QWidget): - def __init__(self): - super().__init__() - - self.hello = ['uno', 'dos', 'tres'] - self.button = QPushButton('Click me!') - self.text = QLabel("Hello World") - - self.layout = QVBoxLayout() - self.layout.addWidget(self.text) - self.layout.addWidget(self.button) - - self.setLayout(self.layout) - - self.button.clicked.connect(self.magic) - - def magic(self): - self.text.setText(random.choice(self.hello)) -endsnippet - - -snippet QUILoader "QUILoader" b -from PySide6.QtUiTools import QUiLoader -from PySide6.QtCore import QFile - -ui_file = QFile(${1:"mainwindow.ui"}) -ui_file.open(QFile.ReadOnly) - -loader = QUiLoader() -window = loader.load(ui_file) -ui_file.close() -window.show() -endsnippet diff --git a/UltiSnips/python/torch.snippets b/UltiSnips/python/torch.snippets @@ -1,29 +0,0 @@ -snippet torch "import torch" b -import torch -import torch.nn as nn -import torch.optim as optim -import torch.nn.functional as F -$0 -endsnippet - - -snippet device "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')" b -device = torch.device("cuda" if not torch.cuda.is_available() else "cpu") -endsnippet - - -snippet no_grad "with torch.no_grad()" b -with torch.no_grad(): - ${0:${VISUAL:pass}} -endsnippet - - -snippet loss "zero_grad, backward, step" b -loss = criterion(${3:input}, ${4:target}) -optimizer.zero_grad() -loss.backward() -# nn.utils.clip_grad_norm_(${1:model}.parameters(), max_norm=${2:1}) -# nn.utils.clip_grad_value_($1.parameters(), clip_value=$2) -optimizer.step() -$0 -endsnippet diff --git a/UltiSnips/python/win32clipboard.py b/UltiSnips/python/win32clipboard.py @@ -1,5 +0,0 @@ -snippet win32clipboard "win32clipboard" b -win32clipboard.OpenClipboard() -clipboard = win32clipboard.GetClipboardData() -win32clipboard.CloseClipboard() -endsnippet diff --git a/UltiSnips/tex.snippets b/UltiSnips/tex.snippets @@ -1,715 +0,0 @@ -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 - - -snippet latex "Basic template" b -\documentclass[a4paper]{article} - -\usepackage{amsmath,amssymb} - -${1:\input macros} - -\begin{document} - -$0 - -\end{document} -endsnippet - -snippet standalone "standalone" b -\documentclass{standalone} -\usepackage{amsmath,amssymb} -\begin{document} -$0 -\end{document} -endsnippet - -snippet beg "begin{} / end{}" bA -\\begin{$1} -$0 -\\end{$1} -endsnippet - -snippet ... "dots" iA -\dots -endsnippet - -snippet table "Table environment" b -\begin{table}[${1:htpb}] - \centering - \caption{${2:caption}} - \label{tab:${3:label}} - \begin{tabular}{${5:c}} - $0${5/((?<=.)c|l|r)|./(?1: & )/g} - \end{tabular} -\end{table} -endsnippet - - -snippet svg "Figure SVG" b -\begin{figure}[${1:htpb}] - \centering - \def\svgwidth{0.8\linewidth} - \import{${2:img/}}{${3:name}.pdf_tex} - \caption{${4:$3}} - \label{fig:${5:${3/\W+/-/g}}} -\end{figure} - -endsnippet - -snippet xopp "Figure Xournalpp" b -\begin{figure}[${1:htpb}] - \centering - \includegraphics[width=0.8\textwidth]{${2:img/name}_annotated.pdf} - \caption{${3:$2}} - \label{fig:${4:${2/\W+/-/g}}} -\end{figure} -endsnippet - -snippet fig "Figure environment" b -\begin{figure}[${1:htpb}] - \centering - ${2:\includegraphics[width=0.8\textwidth]{$3}} - \caption{${4:$3}} - \label{fig:${5:${3/\W+/-/g}}} -\end{figure} -endsnippet - -snippet enum "Enumerate" bA -\begin{enumerate} - \item $0 -\end{enumerate} -endsnippet - -snippet item "Itemize" bA -\begin{itemize} - \item $0 -\end{itemize} -endsnippet - -snippet desc "Description" b -\begin{description} - \item[$1] $0 -\end{description} -endsnippet - -snippet pac "Package" b -\usepackage${1/(.+)/(?1:[)/}${1:option}${1/(.+)/(?1:])/}{${2:package}}$0 -endsnippet - -context "not math()" -snippet mk "Math" wA -\($1\)$0 -endsnippet - -snippet dm "Math" wA -\[ - ${1:${VISUAL}} -.\] -$0 -endsnippet - - -snippet ali "Align" bA -\begin{align*} - $0 -.\end{align*} -endsnippet - - -context "math()" -snippet // "Fraction" iA -\\frac{$1}{$2}$0 -endsnippet - -snippet / "Fraction" i -\\frac{${VISUAL}}{$1}$0 -endsnippet - -context "math()" -snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA -\\frac{`!p snip.rv = match.group(1)`}{$1}$0 -endsnippet - -context "math()" -snippet '^.*\)/' "() frac" wrA -`!p -stripped = match.string[:-1] -depth = 0 -i = len(stripped) - 1 -while True: - if stripped[i] == ')': depth += 1 - if stripped[i] == '(': depth -= 1 - if depth == 0: break; - i-=1 -snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}" -`{$1}$0 -endsnippet - - - -context "math()" -snippet && "align" iA -&${1:${VISUAL}} \\\\$0 -endsnippet - -context "math()" -snippet != "not equals" iA -\neq $0 -endsnippet - -context "math()" -snippet ceil "ceil" iA -\left\lceil $1 \right\rceil $0 -endsnippet - -context "math()" -snippet floor "floor" iA -\left\lfloor $1 \right\rfloor$0 -endsnippet - -snippet pmat "pmat" iA -\begin{pmatrix} $1 \end{pmatrix} $0 -endsnippet - -snippet bmat "bmat" iA -\begin{bmatrix} $1 \end{bmatrix} $0 -endsnippet - -# --------------------------------------------- # -context "math()" -snippet () "left( right)" iA -(${1:${VISUAL}})$0 -endsnippet - -context "math()" -snippet [] "left[ right]" iA -[${1:${VISUAL}}]$0 -endsnippet - -context "math()" -snippet {} "left\{ right\}" iA -\\{${1:${VISUAL}}\\}$0 -endsnippet - -context "math()" -snippet vv "left| right|" iA -\lvert ${1:${VISUAL}} \rvert $0 -endsnippet - -context "math()" -snippet VV "left| right|" iA -\lVert ${1:${VISUAL}} \rVert $0 -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet lim "limit" w -\lim_{${1:n \to \infty}}$0 -endsnippet - -context "math()" -snippet limsup "superior limit" w -\limsup_{${1:n \to \infty}}$0 -endsnippet - -context "math()" -snippet liminf "inferior limit" w -\liminf_{${1:n \to \infty}}$0 -endsnippet - -context "math()" -snippet uuu "bigcup" w -\bigcup${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 -endsnippet - -context "math()" -snippet nnn "bigcap" w -\bigcap${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 -endsnippet - -context "math()" -snippet uu+ "biguplus" w -\biguplus${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 -endsnippet - -context "math()" -snippet sum "sum" w -\sum${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 -endsnippet - -context "math()" -snippet prod "product" w -\prod${1/(.+)/(?1:_{)/}${1:n \in \mathbb{N}}${1/(.+)/(?1:})/}$0 -endsnippet - -context "math()" -snippet int "real integral" w -\int${1/(.+)/(?1:_{)/}${1:-\infty}${1/(.+)/(?1:})/}${2/(.+)/(?1:^{)/}${2:+\infty}${2/(.+)/(?1:})/}{${3:${VISUAL}}}\:d${4:x}$0 -endsnippet - -context "math()" -snippet mint "measure integral" w -\int${1/(.+)/(?1:_{)/}${1:X}${1/(.+)/(?1:})/}{${2:${VISUAL:f}}}\,\mathrm{d}${3:\mu}$0 -endsnippet - -context "math()" -snippet mintu "upper measure integral" w -\overline{\int${1/(.+)/(?1:_{)/}${1:X}${1/(.+)/(?1:})/}}{${3:${VISUAL:f}}}\,\mathrm{d}${4:\mu}$0 -endsnippet - -context "math()" -snippet mintl "lower measure integral" w -\underline{\int${1/(.+)/(?1:_{)/}${1:X}${1/(.+)/(?1:})/}}{${3:${VISUAL:f}}}\,\mathrm{d}${4:\mu}$0 -endsnippet - -context "math()" -snippet seq "Sequence" w -\\{${1:x_n}\\}${2/(.+)/(?1:_{)/}${2:n = 1}${2/(.+)/(?1:})/}${3/(.+)/(?1:^{)/}${3:\infty}${3/(.+)/(?1:})/}${4/(.+)/(?1: \\\\subset )/}${4:\mathbb{R}}$0 -endsnippet - -context "not math()" -snippet seq "Sequence" w -\\(\\{${1:x_n}\\}${2/(.+)/(?1:_{)/}${2:n = 1}${2/(.+)/(?1:})/}${3/(.+)/(?1:^{)/}${3:\infty}${3/(.+)/(?1:})/}${4/(.+)/(?1: \\\\subset )/}${4:\mathbb{R}}\\)$0 -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet ubb "The \underbrace command" w -\underbrace{${1:${VISUAL:}}}_{$2} $0 -endsnippet - -context "math()" -snippet obb "The \overbrace command" w -\overbrace{${1:${VISUAL:}}}^{$2} $0 -endsnippet - -context "math()" -snippet op "\operatorname" w -\operatorname{$1}$0 -endsnippet - -context "math()" -snippet sq "\sqrt{}" iA -\sqrt{${1:${VISUAL}}}$0 -endsnippet - -context "math()" -snippet ^^ "to the ... power" iA -^{$1}$0 -endsnippet - -context "math()" -snippet __ "subscript" iA -_{$1}$0 -endsnippet - -context "math()" -snippet ooo "\infty" iA -\infty$0 -endsnippet - -context "math()" -snippet << "ll" iA -\ll $0 -endsnippet - -context "math()" -snippet <= "leq" iA -\le $0 -endsnippet - -context "math()" -snippet >= "geq" iA -\ge $0 -endsnippet - -context "math()" -snippet EE "geq" iA -\exists $0 -endsnippet - -context "math()" -snippet ~~ "sim" iA -\sim $0 -endsnippet - -context "math()" -snippet AA "forall" iA -\forall $0 -endsnippet - - -snippet plot "Plot" w -\begin{figure}[$1] - \centering - \begin{tikzpicture} - \begin{axis}[ - xmin= ${2:-10}, xmax= ${3:10}, - ymin= ${4:-10}, ymax = ${5:10}, - axis lines = middle, - ] - \addplot[domain=$2:$3, samples=${6:100}]{$7}; - \end{axis} - \end{tikzpicture} - \caption{$8} - \label{${9:$8}} -\end{figure} -endsnippet - -snippet nn "Tikz node" w -\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$}; -$0 -endsnippet - -context "math()" -snippet nabl "nabla" iA -\nabla $0 -endsnippet - -context "math()" -snippet xx "cross" iA -\times $0 -endsnippet - -context "math()" -snippet ** "cdot" iA -\cdot $0 -endsnippet - -context "math()" -snippet -> "to" iA -\to $0 -endsnippet - -context "math()" -snippet uto "to" iA -\mathop{\uparrow} -endsnippet - -context "math()" -snippet dto "to" iA -\mathop{\downarrow} -endsnippet - -context "math()" -snippet <-> "leftrightarrow" iA -\leftrightarrow -endsnippet - -context "math()" -snippet !> "mapsto" iA -\mapsto $0 -endsnippet - -context "math()" -snippet \\\ "setminus" iA -\setminus $0 -endsnippet - -context "math()" -snippet || "mid" iA -\mid $0 -endsnippet - -context "math()" -snippet cc "subset" A -\subset $0 -endsnippet - -context "math()" -snippet notin "not in " iA -\not\in $0 -endsnippet - -context "math()" -snippet inn "in" iA -\in $0 -endsnippet - -context "math()" -snippet NN "cap" iA -\cap $0 -endsnippet - -context "math()" -snippet UU "cup" iA -\cup $0 -endsnippet - -context "math()" -snippet U+ "uplus" iA -\uplus $0 -endsnippet - -context "math()" -snippet O+ "\oplus" iA -\oplus $0 -endsnippet - -context "math()" -snippet Ox "\otimes" iA -\otimes $0 -endsnippet - -context "math()" -snippet OO "emptyset" iA -\emptyset -endsnippet - - - -# --------------------------------------------- # - -context "math()" -snippet "([A-Z])(cal|bb|frak|scr)" "\mathcal" rA -\math`!p snip.rv = match.group(2)`{`!p snip.rv = match.group(1)`}$0 -endsnippet - -context "math()" -snippet "([a-zA-Z])(bf)" "\mathcal" rA -\math`!p snip.rv = match.group(2)`{`!p snip.rv = match.group(1)`}$0 -endsnippet - -context "math()" -snippet "([0-9a-z])(vec|hat)" "\vec hat" rA -\\`!p snip.rv = match.group(2)`{`!p snip.rv = match.group(1)`}$0 -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet tt "text" iA -\text{$1}$0 -endsnippet - -context "math()" -snippet case "cases" wA -\begin{cases} - $1 -\end{cases} -$0 -endsnippet - -snippet bigfun "Big function" -\begin{align*} - $1\colon ${2:X} &\longrightarrow ${3:\mathbb{R}} \\\\ - $4 &\longmapsto $1($4) \coloneqq $5 -.\end{align*} -$0 -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet fun "f: A -> B" w -${1:f}\colon ${2:X} \to ${3:\mathbb{R}} -endsnippet - -context "not math()" -snippet fun "f: A -> B" w -\(${1:f}\colon ${2:X} \to ${3:\mathbb{R}}\) -endsnippet - -context "not math()" -snippet func "f: A -> B" w -\(${1:f}\colon ${2:X} \stackrel{C^${4:0}}{\longrightarrow} ${3:\mathbb{R}}\) -endsnippet - -# --------------------------------------------- # - -snippet h1 "section" bA -\section{${1:${VISUAL:}}} -$0 -endsnippet - -snippet h2 "subsection" bA -\subsection{${1:${VISUAL:}}} -$0 -endsnippet - -snippet h3 "subsubsection" bA -\subsubsection{${1:${VISUAL:}}} -$0 -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet ## "#" iA -\#(${1:${VISUAL}})$0 -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet inv "inverse" iA -^{-1} -endsnippet - -context "math()" -snippet compl "complement" iA -^{c} -endsnippet - -context "math()" -snippet '\\Rb' "\bar{\R}" wrA -\overline{\R} -endsnippet - -# --------------------------------------------- # - -context "math()" -snippet '([A-Za-z]|\\math[^{]*{[A-Za-z]})(\d)' "auto subscript" wrA -`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` -endsnippet - -context "math()" -snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA -`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`} -endsnippet - -context "math()" -snippet "([^\\\w][A-Za-ex-z])([ijknm])" "fast subscript" rA -`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)` -endsnippet - -context "math()" -snippet "([^\\\w][A-Za-ex-z])_([ijknm][+-])" "fast subscript" rA -`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`$1}$0 -endsnippet - -# --------------------------------------------- # - -snippet :: "\colon" iA -\colon $0 -endsnippet - - -context "math()" -snippet and "static snippet: quad-spaced 'and' in equation" A -\quad \text{and} \quad $0 -endsnippet - -context "math()" -snippet or "static snippet: quad-spaced 'or' in equation" A -\quad \text{or} \quad $0 -endsnippet - -# --------------------------------------------- # - -context "not math()" -snippet sss "sí y solo sí" A -si y solo si $0 -endsnippet - -context "not math()" -snippet ee "En efecto," A -En efecto, $0 -endsnippet - -context "not math()" -snippet plt "Por lo tanto," A -Por lo tanto, $0 -endsnippet - -context "not math()" -snippet alg "algebra" -álgebra$0 -endsnippet - -context "not math()" -snippet salg "σ-álgebra" -\(\sigma\)-álgebra$0 -endsnippet - -context "not math()" -snippet psis "π-sistema" -\(\pi\)-sistema$0 -endsnippet - -context "not math()" -snippet lsis "λ-sistema" -\(\lambda\)-sistema$0 -endsnippet - -context "not math()" -snippet mctp "μ-ctp" w -\(\mu\)-ctp$0 -endsnippet - -context "math()" -snippet st "such that" w -\text{ such that } -endsnippet - - -context "not math()" -snippet => "(=>)" iA -(\(\Rightarrow\)) -endsnippet - -context "not math()" -snippet =< "(=<)" iA -(\(\Leftarrow\)) -endsnippet - -context "not math()" -snippet >< "(=><=)" iA -(\(\Rightarrow\!\Leftarrow\)) -endsnippet - -context "math()" -snippet => "\Rightarrow" Ai -\Rightarrow $0 -endsnippet - -context "math()" -snippet =< "\Leftarrow" Ai -\Leftarrow $0 -endsnippet - -context "math()" -snippet iff "iff" Ai -\iff $0 -endsnippet - -context "math()" -snippet := "≔" iA -\coloneqq $0 -endsnippet - -priority 2 -context "math()" -snippet thr4 "\therefore" wiA -\therefore $0 -endsnippet - -context "math()" -snippet ==> "implies" Ai -\implies $0 -endsnippet - -context "not math()" -snippet ==> "implies" Ai -\(\implies\) $0 -endsnippet - - -context "math()" -snippet ==< "implied by" Ai -\impliedby $0 -endsnippet - -priority 1 diff --git a/UltiSnips/tex/amsthm.snippets b/UltiSnips/tex/amsthm.snippets @@ -1,42 +0,0 @@ -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{corollary}{Corollary} -\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 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 diff --git a/UltiSnips/tex/greek.snippets b/UltiSnips/tex/greek.snippets @@ -1,159 +0,0 @@ -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 "math()" -snippet ;f "\phi" iA -\phi -endsnippet - -context "math()" -snippet ;vf "\varphi" iA -\varphi -endsnippet - -context "math()" -snippet ;p "\psi" iA -\psi -endsnippet - -context "math()" -snippet ;P "\Psi" iA -\Psi -endsnippet - -context "math()" -snippet ;F "\Phi" iA -\Phi -endsnippet - -context "math()" -snippet ;g "\gamma" iA -\gamma -endsnippet - -context "math()" -snippet ;G "\Gamma" iA -\Gamma -endsnippet - -context "math()" -snippet ;s "\sigma" iA -\sigma -endsnippet - -context "math()" -snippet ;S "\Sigma" iA -\Sigma -endsnippet - -context "math()" -snippet ;l "\lambda" iA -\lambda -endsnippet - -context "math()" -snippet ;L "\Lambda" iA -\Lambda -endsnippet - -context "math()" -snippet ;m "\mu" iA -\mu -endsnippet - -context "math()" -snippet ;n "\nu" iA -\nu -endsnippet - -context "math()" -snippet ;a "\alpha" iA -\alpha -endsnippet - -context "math()" -snippet ;ve "\varepsilon" iA -\varepsilon -endsnippet - -context "math()" -snippet ;c "\chi" iA -\chi -endsnippet - -context "math()" -snippet ;W "\Omega" iA -\Omega -endsnippet - -context "math()" -snippet ;w "\omega" iA -\omega -endsnippet - -context "math()" -snippet ;D "\Delta" iA -\Delta -endsnippet - -context "math()" -snippet ;d "\delta" iA -\delta -endsnippet - -context "math()" -snippet ;b "\beta" iA -\beta -endsnippet - -context "math()" -snippet ;k "\kappa" iA -\kappa -endsnippet - -context "math()" -snippet ;h "\eta" iA -\eta -endsnippet - -context "math()" -snippet ;r "\rho" iA -\rho -endsnippet - -context "math()" -snippet ;t "\tau" iA -\tau -endsnippet - -context "math()" -snippet ;z "\zeta" iA -\zeta -endsnippet - -context "math()" -snippet ;x "\xi" iA -\xi -endsnippet - -context "math()" -snippet ;X "\Xi" iA -\Xi -endsnippet - -context "math()" -snippet ;o "\theta" iA -\theta -endsnippet - -context "math()" -snippet ;O "\Theta" iA -\Theta -endsnippet