From 063c2d97218cdabe0634054a8038cd6b5c9a9a12 Mon Sep 17 00:00:00 2001 From: Nanderty Date: Sat, 25 Mar 2023 18:16:24 +0100 Subject: cleanup, snippets --- Snippets/tex/environments.lua | 48 +++++++++++++++++++++++++++++++++++++++++++ Snippets/tex/general.lua | 11 ++++++++++ Snippets/tex/greek.lua | 18 ++++++++++++++++ Snippets/tex/math.lua | 30 +++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 Snippets/tex/environments.lua create mode 100644 Snippets/tex/general.lua create mode 100644 Snippets/tex/greek.lua create mode 100644 Snippets/tex/math.lua (limited to 'Snippets') diff --git a/Snippets/tex/environments.lua b/Snippets/tex/environments.lua new file mode 100644 index 0000000..b9594aa --- /dev/null +++ b/Snippets/tex/environments.lua @@ -0,0 +1,48 @@ +local line_begin = require("luasnip.extras.expand_conditions").line_begin + +return { + -- variable environment + s({ trig = 'beg', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{<>} + <> +\end{<>} +]], + { + i(1), + i(2), + rep(1), + } + ), + { condition = line_begin } + ), + -- enumerate environment + s({ trig = 'enu', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{enumerate*} + \item <> +\end{enumerate*} +]], + { + i(1), + } + ), + { condition = line_begin } + ), + -- align environment + s({ trig = 'ali', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{align*} + <> +\end{align*} +]], + { + i(1), + } + ), + { condition = line_begin } + ), +} diff --git a/Snippets/tex/general.lua b/Snippets/tex/general.lua new file mode 100644 index 0000000..73255da --- /dev/null +++ b/Snippets/tex/general.lua @@ -0,0 +1,11 @@ +return { + s({ trig = "sec", snippetType = "autosnippet" }, + fmta( + '\\section*{<>}', + { + i(1), + } + ), + { condition = line_begin } + ), +} diff --git a/Snippets/tex/greek.lua b/Snippets/tex/greek.lua new file mode 100644 index 0000000..ebcabfe --- /dev/null +++ b/Snippets/tex/greek.lua @@ -0,0 +1,18 @@ +local in_mathzone = function() + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end + +return { + s({ trig = "pi", snippetType = "autosnippet" }, + { + t("\\pi"), + }, + { condition = in_mathzone } + ), + s({ trig = "0eps", snippetType = "autosnippet" }, + { + t("\\epsilon_0"), + }, + { condition = in_mathzone } + ), +} diff --git a/Snippets/tex/math.lua b/Snippets/tex/math.lua new file mode 100644 index 0000000..7299e04 --- /dev/null +++ b/Snippets/tex/math.lua @@ -0,0 +1,30 @@ +local in_mathzone = function() + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end + +return { + s({ trig = '/', snippetType = 'autosnippet' }, + fmta( + '\\frac{<>}{<>}', + { + i(1), + i(2), + } + ), + { condition = in_mathzone } + ), + s({ trig = "in", snippetType = "autosnippet" }, + fmta( + '\\int_{<>}^{<>}', + { + i(1), + i(2), + } + ), + { condition = in_mathzone } + ), + s({ trig = 'df', snippetType = 'autosnippet' }, + { t('\\diff ') }, + { condition = in_mathzone } + ), +} -- cgit v1.2.3