Update
This commit is contained in:
@@ -1,139 +0,0 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
local tex = require("util.latex")
|
||||
local get_visual = function(args, parent)
|
||||
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
return sn(nil, t(parent.snippet.env.SELECT_RAW))
|
||||
else -- If SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "bal", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{algorithm}
|
||||
\caption{<>}
|
||||
\label{algo:<>}
|
||||
\begin{algorithmic}[1]
|
||||
\Require <>
|
||||
\end{algorithmic}
|
||||
|
||||
\end{algorithm}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
rep(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s({ trig = "ss", snippetType = "autosnippet" }, {
|
||||
t("\\State "),
|
||||
}, { condition = tex.in_algo * line_begin }),
|
||||
s({ trig = "sx", snippetType = "autosnippet" }, {
|
||||
t("\\Statex "),
|
||||
}, { condition = tex.in_algo * line_begin }),
|
||||
s({ trig = "return", snippetType = "autosnippet" }, {
|
||||
t("\\Return"),
|
||||
}, { condition = tex.in_algo }),
|
||||
s(
|
||||
{ trig = "while", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\While{<>}
|
||||
<>
|
||||
\EndWhile
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_algo * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "for", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\For{<>}
|
||||
<>
|
||||
\EndFor
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_algo * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "if", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\If{<>}
|
||||
<>
|
||||
\EndIf
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_algo * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "elif", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\ElsIf{<>}
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_algo * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "else", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\Else
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_algo * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "fn", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\Function{<>}{<>}
|
||||
<>
|
||||
\EndFunction
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_algo * line_begin }
|
||||
),
|
||||
}
|
||||
@@ -83,56 +83,6 @@ return {
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%d+)/", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 100 },
|
||||
fmta("frac(<>)(<>)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%a)/", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 100 },
|
||||
fmta("frac(<>)(<>)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "%((.+)%)/", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("frac(<>)(<>)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%a+)/", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("frac(<>)(<>)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%a+%{%a+%})/", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 3000 },
|
||||
fmta("frac(<>)(<>)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "%)(%a)", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta(") <>", {
|
||||
@@ -170,22 +120,22 @@ return {
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
-- s(
|
||||
-- { trig = "sum", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
-- fmta("sumlimits_(<>)^(<>)", {
|
||||
-- i(1),
|
||||
-- i(1),
|
||||
-- }),
|
||||
-- { condition = tex.in_mathzone }
|
||||
-- ),
|
||||
s(
|
||||
{ trig = "sum", snippetType = "autosnippet" },
|
||||
c(1, {
|
||||
sn(nil, { t("sum_{"), i(1), t("} ") }),
|
||||
sn(nil, { t("sum_{"), i(1), t("}^{"), i(2), t("} ") }),
|
||||
{ trig = "sum", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("sum_(<>)^(<>)", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
-- s(
|
||||
-- { trig = "sum", snippetType = "autosnippet" },
|
||||
-- c(1, {
|
||||
-- sn(nil, { t("sum_{"), i(1), t("} ") }),
|
||||
-- sn(nil, { t("sum_{"), i(1), t("}^{"), i(2), t("} ") }),
|
||||
-- }),
|
||||
-- { condition = tex.in_mathzone }
|
||||
-- ),
|
||||
s(
|
||||
{ trig = "pd", snippetType = "autosnippet" },
|
||||
c(1, {
|
||||
@@ -252,7 +202,7 @@ return {
|
||||
),
|
||||
s(
|
||||
{ trig = "int", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("integral_(<>)^(<>) <> dif <>", {
|
||||
fmta("integral<>_(<>)^(<>) <>", {
|
||||
i(1),
|
||||
i(2),
|
||||
i(3),
|
||||
@@ -262,11 +212,10 @@ return {
|
||||
),
|
||||
s(
|
||||
{ trig = "oint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("ointegral_(<>)^(<>) <> dif <>", {
|
||||
fmta("integral.cont_(<>)^(<>) <> ", {
|
||||
i(1),
|
||||
i(2),
|
||||
i(3),
|
||||
i(4),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
@@ -285,7 +234,7 @@ return {
|
||||
),
|
||||
s(
|
||||
{ trig = "iint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("iintegral_(<>)^(<>) <> dif <>", {
|
||||
fmta("integral.double_(<>)^(<>) <> dif <>", {
|
||||
i(1, "-infty"),
|
||||
i(2, "infty"),
|
||||
i(3),
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
local tex = require("util.latex")
|
||||
|
||||
local get_visual = function(args, parent)
|
||||
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
return sn(nil, t(parent.snippet.env.SELECT_RAW))
|
||||
else -- If SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
-- s(
|
||||
-- { trig = "pv", snippetType = "autosnippet" },
|
||||
-- fmta("\\pdv[order={<>}]{<>}{<>}", {
|
||||
-- i(0),
|
||||
-- i(1),
|
||||
-- i(2),
|
||||
-- }),
|
||||
-- { condition = tex.in_mathzone }
|
||||
-- ),
|
||||
s(
|
||||
{ trig = "pv", snippetType = "autosnippet" },
|
||||
c(1, {
|
||||
sn(nil, { t("\\pdv{"), i(1), t("}{"), i(2), t("}") }),
|
||||
sn(nil, { t("\\pdv[order={"), i(3), t("}]{"), i(1), t("}{"), i(2), t("}") }),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "ov", snippetType = "autosnippet" },
|
||||
c(1, {
|
||||
sn(nil, { t("\\odv{"), i(1), t("}{"), i(2), t("}") }),
|
||||
sn(nil, { t("\\odv[order={"), i(3), t("}]{"), i(1), t("}{"), i(2), t("}") }),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "ov", snippetType = "autosnippet" },
|
||||
fmta("\\odv[order={<>}]{<>}{<>}", {
|
||||
i(0),
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
}
|
||||
@@ -45,29 +45,12 @@ return {
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%d+)bp", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
{ trig = "#thm", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{homeworkProblem}[Problem <>.]
|
||||
#theorem(<>)[
|
||||
<>
|
||||
\end{homeworkProblem}
|
||||
]],
|
||||
{
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bp", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{homeworkProblem}[Problem <>.]
|
||||
<>
|
||||
\end{homeworkProblem}
|
||||
]
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
@@ -77,26 +60,26 @@ return {
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bff", snippetType = "autosnippet" },
|
||||
{ trig = "#pf", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{proof}
|
||||
#proof[
|
||||
<>
|
||||
\end{proof}
|
||||
]
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin * tex.in_text }
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
s(
|
||||
{ trig = "bep", snippetType = "autosnippet" },
|
||||
{ trig = "#def", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{problem}[<>]
|
||||
#definition(<>)[
|
||||
<>
|
||||
\end{problem}
|
||||
]
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
@@ -106,332 +89,17 @@ return {
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bex", snippetType = "autosnippet" },
|
||||
{ trig = "#exa", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{exercise}[<>]
|
||||
#example[
|
||||
<>
|
||||
\end{exercise}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bve", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{verbatim}
|
||||
<>
|
||||
\end{verbatim}
|
||||
]
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bbi", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{thebibliography}
|
||||
<>
|
||||
\end{thebibliography}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s({ trig = "bib", snippetType = "autosnippet" }, {
|
||||
t("\\bibitem"),
|
||||
}, { condition = tex.in_bib * line_begin }),
|
||||
s(
|
||||
{ trig = "bfi", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\includegraphics[width=0.8\textwidth]{<>}
|
||||
\caption{<>}
|
||||
\label{fig:<>}
|
||||
\end{figure}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
rep(2),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bmf", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{figure}[htbp]
|
||||
\centering
|
||||
\begin{minipage}[t]{0.48\textwidth}
|
||||
\centering
|
||||
\includegraphics[width=6cm]{}
|
||||
\caption{}
|
||||
\label{fig:}
|
||||
\end{minipage}
|
||||
\begin{minipage}[t]{0.48\textwidth}
|
||||
\centering
|
||||
\includegraphics[width=6cm]{}
|
||||
\caption{}
|
||||
\label{fig:}
|
||||
\end{minipage}
|
||||
\end{figure}
|
||||
]],
|
||||
{}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "beg", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}[<>]
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
i(0),
|
||||
rep(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "ben", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{enumerate}[<>]
|
||||
\item <>
|
||||
\end{enumerate}
|
||||
]],
|
||||
{
|
||||
i(1, "(a)"),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "blst", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{lstlisting}[language=<>]
|
||||
<>
|
||||
\end{lstlisting}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "box", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{framed}
|
||||
<>
|
||||
\end{framed}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "dcase", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta(
|
||||
[[
|
||||
\begin{dcases}
|
||||
<>
|
||||
\end{dcases}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "case", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{cases}
|
||||
<>
|
||||
\end{cases}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bal", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{aligned}
|
||||
<>
|
||||
\end{aligned}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bal", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta(
|
||||
[[
|
||||
\begin{aligned}
|
||||
<>
|
||||
\end{aligned}
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bit", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{itemize}
|
||||
\item <>
|
||||
\end{itemize}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s({ trig = "im", snippetType = "autosnippet" }, {
|
||||
t("\\item"),
|
||||
}, { condition = tex.in_item * line_begin }),
|
||||
s(
|
||||
{ trig = "bcr", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{center}
|
||||
<>
|
||||
\end{center}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bta", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{table}[htbp]
|
||||
\centering
|
||||
\begin{tabular}{<>}
|
||||
\hline
|
||||
<>
|
||||
\hline
|
||||
\end{tabular}
|
||||
\caption{<>}
|
||||
\label{tab:<>}
|
||||
\end{table}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
i(3),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "btr", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{tabular}{<>}
|
||||
\hline
|
||||
<>
|
||||
\hline
|
||||
\end{tabular}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "cha", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\chapter{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "par", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\paragraph{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "sec", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\section{"), i(1), t("}") }), sn(nil, { t("\\section*{"), i(1), t("}") }) }),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "ssec", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\subsection{"), i(1), t("}") }), sn(nil, { t("\\subsection*{"), i(1), t("}") }) }),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "sss", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\subsubsection{"), i(1), t("}") }), sn(nil, { t("\\subsubsection*{"), i(1), t("}") }) }),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "sss", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\subsubsection{<>}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin * line_begin }
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local i = ls.insert_node
|
||||
local d = ls.dynamic_node
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
local get_visual = function(args, parent)
|
||||
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
return sn(nil, t(parent.snippet.env.SELECT_RAW))
|
||||
else -- If SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
local tex = require("util.latex")
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "msf", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\mathsf{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "msf", snippetType = "autosnippet" },
|
||||
fmta("\\mathsf{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bf", snippetType = "autosnippet" },
|
||||
fmta("\\mathbf{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "cal", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\mathcal{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "cal", snippetType = "autosnippet" },
|
||||
fmta("\\mathcal{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "scr", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\mathscr{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "scr", snippetType = "autosnippet" },
|
||||
fmta("\\mathscr{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "mbb", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\mathbb{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "mbb", snippetType = "autosnippet" },
|
||||
fmta("\\mathbb{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "mrm", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\mathrm{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "mrm", snippetType = "autosnippet" },
|
||||
fmta("\\mathrm{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "tit", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\textit{<>}", {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "tit", snippetType = "autosnippet" },
|
||||
fmta("\\textit{<>}", {
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "ttt", snippetType = "autosnippet" },
|
||||
fmta("\\texttt{<>}", {
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "tbf", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\textbf{<>}", {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "tbf", snippetType = "autosnippet" },
|
||||
fmta("\\textbf{<>}", {
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "qq", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\text{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "tet", snippetType = "autosnippet" },
|
||||
fmta("\\text{<>}", {
|
||||
i(1),
|
||||
})
|
||||
),
|
||||
}
|
||||
@@ -52,6 +52,9 @@ return {
|
||||
s({ trig = "zeta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("zeta"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = ";z", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("zeta"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "Zeta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("Zeta"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
|
||||
@@ -42,6 +42,22 @@ return {
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "td", snippetType = "autosnippet"},
|
||||
fmta("tilde(<>)", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%a)~", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
|
||||
fmta("tilde(<>)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "ob", snippetType = "autosnippet" },
|
||||
fmta("overbrace(<>)", {
|
||||
@@ -84,6 +100,31 @@ return {
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "mrm", snippetType = "autosnippet" },
|
||||
fmta("upright(<>)", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bb(%w)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("bb(<>)", {
|
||||
f(function(_, snip)
|
||||
return string.upper(snip.captures[1])
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "cal(%w)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("cal(<>)", {
|
||||
f(function(_, snip)
|
||||
return string.upper(snip.captures[1])
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "vec", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("vec(<>)", {
|
||||
@@ -115,28 +156,6 @@ return {
|
||||
s({ trig = "dim", snippetType = "autosnippet" }, fmta("dim", {}), { condition = tex.in_mathzone }),
|
||||
s({ trig = "det", snippetType = "autosnippet" }, fmta("det", {}), { condition = tex.in_mathzone }),
|
||||
s({ trig = "vol", snippetType = "autosnippet" }, fmta("Vol", {}), { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = "->", snippetType = "autosnippet" },
|
||||
fmta("xlongrightarrow(<>)", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "<-", snippetType = "autosnippet" },
|
||||
fmta("xlongleftarrow(<>)", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s({ trig = "--", snippetType = "autosnippet" }, fmta("longleftrightarrow", {}), { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = "gt", snippetType = "autosnippet" },
|
||||
fmta("gt(<>)", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s({ trig = "min", snippetType = "autosnippet" }, fmta("min", {}), { condition = tex.in_mathzone }),
|
||||
s({ trig = "max", snippetType = "autosnippet" }, fmta("max", {}), { condition = tex.in_mathzone }),
|
||||
s(
|
||||
@@ -157,7 +176,7 @@ return {
|
||||
s({ trig = "inf", snippetType = "autosnippet", priority = 2000 }, fmta("inf", {}), { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = ";r", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("frac(<>)(<>)", {
|
||||
fmta("(<>)/(<>)", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
@@ -165,7 +184,7 @@ return {
|
||||
),
|
||||
s(
|
||||
{ trig = ";r", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("frac(<>)(<>)", {
|
||||
fmta("(<>)/(<>)", {
|
||||
d(1, get_visual),
|
||||
i(2),
|
||||
}),
|
||||
|
||||
@@ -1,297 +0,0 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
local tex = require("util.latex")
|
||||
local get_visual = function(args, parent)
|
||||
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
return sn(nil, t(parent.snippet.env.SELECT_RAW))
|
||||
else -- If SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "sym", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("sympy <> sympy", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "sym", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("sympy <> sympy", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s( -- This one evaluates anything inside the simpy block
|
||||
{ trig = "sympy.*sympys", regTrig = true, desc = "Sympy block evaluator", snippetType = "autosnippet" },
|
||||
d(1, function(_, parent)
|
||||
local to_eval = string.gsub(parent.trigger, "^sympy(.*)sympys", "%1")
|
||||
to_eval = string.gsub(to_eval, "^%s+(.*)%s+$", "%1")
|
||||
|
||||
local Job = require("plenary.job")
|
||||
|
||||
local sympy_script = string.format(
|
||||
[[
|
||||
from latex2sympy2 import latex2latex
|
||||
import re
|
||||
origin = r'%s'
|
||||
# remove white space
|
||||
standard = re.sub(r"\\d", "d", origin)
|
||||
latex = latex2latex(standard)
|
||||
output = origin + " = " + latex
|
||||
print(output)
|
||||
]],
|
||||
to_eval
|
||||
)
|
||||
|
||||
sympy_script = string.gsub(sympy_script, "^[\t%s]+", "")
|
||||
local result = ""
|
||||
|
||||
Job:new({
|
||||
command = "python3",
|
||||
args = {
|
||||
"-c",
|
||||
sympy_script,
|
||||
},
|
||||
on_exit = function(j)
|
||||
result = j:result()
|
||||
end,
|
||||
}):sync()
|
||||
|
||||
return sn(nil, t(result))
|
||||
end)
|
||||
),
|
||||
s( -- This one evaluates anything inside the simpy block
|
||||
{ trig = "sympy.*sympy ", regTrig = true, desc = "Sympy block evaluator", snippetType = "autosnippet" },
|
||||
d(1, function(_, parent)
|
||||
-- Gets the part of the block we actually want, and replaces spaces
|
||||
-- at the beginning and at the end
|
||||
local to_eval = string.gsub(parent.trigger, "^sympy(.*)sympy", "%1")
|
||||
to_eval = string.gsub(to_eval, "^%s+(.*)%s+$", "%1")
|
||||
local pattern = { "\\ab" }
|
||||
local repl = { "" }
|
||||
for i = 1, #pattern do
|
||||
to_eval = string.gsub(to_eval, pattern[i], repl[i])
|
||||
end
|
||||
|
||||
local Job = require("plenary.job")
|
||||
|
||||
local sympy_script = string.format(
|
||||
[[
|
||||
from sympy import *
|
||||
from latex2sympy2 import latex2sympy, latex2latex
|
||||
import re
|
||||
origin = r'%s'
|
||||
origin = re.sub(r"\\d", "d", origin)
|
||||
latex = latex2latex(origin)
|
||||
print(latex)
|
||||
]],
|
||||
to_eval
|
||||
)
|
||||
|
||||
sympy_script = string.gsub(sympy_script, "^[\t%s]+", "")
|
||||
local result = ""
|
||||
|
||||
Job:new({
|
||||
command = "python3",
|
||||
args = {
|
||||
"-c",
|
||||
sympy_script,
|
||||
},
|
||||
on_exit = function(j)
|
||||
result = j:result()
|
||||
end,
|
||||
}):sync()
|
||||
|
||||
return sn(nil, t(result))
|
||||
end)
|
||||
),
|
||||
s(
|
||||
{ trig = "qcircuit", wordTrig = false },
|
||||
fmta("QCircuit <> QCircuit", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
s(
|
||||
{ trig = "qcircuit", wordTrig = false, priority = 2000 },
|
||||
fmta("QCircuit <> QCircuit", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
s( -- This one evaluates anything inside the simpy block
|
||||
{ trig = "QCircuit.*QCircuit ", regTrig = true, desc = "QCircuit block evaluator", snippetType = "autosnippet" },
|
||||
d(1, function(_, parent)
|
||||
-- Gets the part of the block we actually want, and replaces spaces
|
||||
-- at the beginning and at the end
|
||||
local to_eval = string.gsub(parent.trigger, "^QCircuit(.*)QCircuit ", "%1")
|
||||
to_eval = string.gsub(to_eval, "^%s+(.*)%s+$", "%1")
|
||||
|
||||
-- Replace lash with rash for to_evil
|
||||
local pattern = {
|
||||
"ts",
|
||||
"I_?(%d)",
|
||||
"C(%w)",
|
||||
"dagger",
|
||||
"\\ket{0}",
|
||||
"\\ket{1}",
|
||||
"\\ket{%+}",
|
||||
"\\ket{%-}",
|
||||
"\\ket{%+i}",
|
||||
"\\ket{i}",
|
||||
"\\ket{%-i}",
|
||||
"\\bra{0}",
|
||||
"\\bra{1}",
|
||||
"\\bra{%+}",
|
||||
"\\bra{%-}",
|
||||
"\\bra{%+i}",
|
||||
"\\bra{i}",
|
||||
"\\bra{%-i}",
|
||||
}
|
||||
local repl = {
|
||||
"TensorProduct",
|
||||
"eye(%1)",
|
||||
"controlled_gate_12(%1)",
|
||||
".conjugate().transpose()",
|
||||
"ket0",
|
||||
"ket1",
|
||||
"ketp",
|
||||
"ketm",
|
||||
"ketpi",
|
||||
"ketpi",
|
||||
"ketmi",
|
||||
"bra0",
|
||||
"bra1",
|
||||
"brap",
|
||||
"bram",
|
||||
"brapi",
|
||||
"brapi",
|
||||
"brami",
|
||||
}
|
||||
for i = 1, #pattern do
|
||||
to_eval = string.gsub(to_eval, pattern[i], repl[i])
|
||||
end
|
||||
print(to_eval)
|
||||
|
||||
local Job = require("plenary.job")
|
||||
|
||||
local sympy_script = string.format(
|
||||
[[
|
||||
from sympy import *
|
||||
from sympy.physics.quantum import *
|
||||
def controlled_gate_12(gate):
|
||||
return TensorProduct(Matrix([ [1, 0], [0, 0] ]), eye(2))+TensorProduct(Matrix([ [0, 0], [0, 1] ]), gate)
|
||||
def controlled_gate_21(gate):
|
||||
return TensorProduct(eye(2), Matrix([ [1, 0], [0, 0] ]))+TensorProduct(gate, Matrix([ [0, 0], [0, 1] ]))
|
||||
H = Matrix([ [1, 1], [1, -1] ]) / sqrt(2)
|
||||
X = Matrix([ [0, 1], [1, 0] ])
|
||||
Y = Matrix([ [0, -I], [I, 0] ])
|
||||
Z = Matrix([ [1, 0], [0, -1] ])
|
||||
e1 = Matrix([ [1], [0], [0], [0] ])
|
||||
e2 = Matrix([ [0], [1], [0], [0] ])
|
||||
e3 = Matrix([ [0], [0], [1], [0] ])
|
||||
e4 = Matrix([ [0], [0], [0], [1] ])
|
||||
ket0 = Matrix([ [1], [0] ])
|
||||
ket1 = Matrix([ [0], [1] ])
|
||||
ketp = Matrix([ [1], [1] ]) / sqrt(2)
|
||||
ketm = Matrix([ [1], [-1] ]) / sqrt(2)
|
||||
ketpi = Matrix([ [1], [I] ]) / sqrt(2)
|
||||
ketmi = Matrix([ [1], [-I] ]) / sqrt(2)
|
||||
bra0 = Matrix([ [1, 0] ])
|
||||
bra1 = Matrix([ [0, 1] ])
|
||||
brap = Matrix([ [1, 1] ]) / sqrt(2)
|
||||
bram = Matrix([ [1, -1] ]) / sqrt(2)
|
||||
brapi = Matrix([ [1, -I] ]) / sqrt(2)
|
||||
brami = Matrix([ [1, I] ]) / sqrt(2)
|
||||
out00 = e1*e1.transpose()
|
||||
out01 = e2*e2.transpose()
|
||||
out10 = e3*e3.transpose()
|
||||
out11 = e4*e4.transpose()
|
||||
%s
|
||||
output = latex(res)
|
||||
print(output)
|
||||
]],
|
||||
to_eval
|
||||
)
|
||||
|
||||
sympy_script = string.gsub(sympy_script, "^[\t%s]+", "")
|
||||
local result = ""
|
||||
|
||||
Job:new({
|
||||
command = "python3",
|
||||
args = {
|
||||
"-c",
|
||||
sympy_script,
|
||||
},
|
||||
on_exit = function(j)
|
||||
result = j:result()
|
||||
end,
|
||||
}):sync()
|
||||
|
||||
return sn(nil, t(result))
|
||||
end)
|
||||
),
|
||||
s(
|
||||
{ trig = "exd", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("expand <> expand", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s( -- This one evaluates anything inside the simpy block
|
||||
{ trig = "expand.*expand ", regTrig = true, desc = "expand block evaluator", snippetType = "autosnippet" },
|
||||
d(1, function(_, parent)
|
||||
-- Gets the part of the block we actually want, and replaces spaces
|
||||
-- at the beginning and at the end
|
||||
local to_eval = string.gsub(parent.trigger, "^expand(.*)expand ", "%1")
|
||||
to_eval = string.gsub(to_eval, "^%s+(.*)%s+$", "%1")
|
||||
local pattern = { "\\ab" }
|
||||
local repl = { "" }
|
||||
for i = 1, #pattern do
|
||||
to_eval = string.gsub(to_eval, pattern[i], repl[i])
|
||||
end
|
||||
|
||||
local Job = require("plenary.job")
|
||||
|
||||
local sympy_script = string.format(
|
||||
[[
|
||||
from sympy import *
|
||||
from latex2sympy2 import latex2sympy, latex2latex
|
||||
x,y,a,b = symbols('x y a b')
|
||||
theta = symbols('theta')
|
||||
origin = r'%s'
|
||||
expand = latex2sympy(origin).expand()
|
||||
print(latex(expand))
|
||||
]],
|
||||
to_eval
|
||||
)
|
||||
|
||||
sympy_script = string.gsub(sympy_script, "^[\t%s]+", "")
|
||||
local result = ""
|
||||
|
||||
Job:new({
|
||||
command = "python3",
|
||||
args = {
|
||||
"-c",
|
||||
sympy_script,
|
||||
},
|
||||
on_exit = function(j)
|
||||
result = j:result()
|
||||
end,
|
||||
}):sync()
|
||||
|
||||
return sn(nil, t(result))
|
||||
end)
|
||||
),
|
||||
}
|
||||
@@ -21,6 +21,9 @@ local get_visual = function(args, parent)
|
||||
end
|
||||
|
||||
return {
|
||||
s({ trig = "!in", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("in.not"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "...", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("dots"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
@@ -33,6 +36,9 @@ return {
|
||||
s({ trig = "v.", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("dots.v"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "to", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("->"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "iff", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("iff"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
@@ -45,15 +51,6 @@ return {
|
||||
s({ trig = "ee", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("exists"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "==", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("&="),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "<==", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("&<="),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = ">==", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("&>="),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "~=", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("approx"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
@@ -78,9 +75,6 @@ return {
|
||||
s({ trig = "mto", wordTrig = false, snippetType = "autosnippet", priority = 1001 }, {
|
||||
t("mapsto"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "||", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("mid"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "mid", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("mid"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
@@ -94,22 +88,19 @@ return {
|
||||
t("^3"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "inv", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("^{-1}"),
|
||||
t("^(-1)"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "**", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("^*"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = " ", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t(","),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "<>", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("diamond"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "+-", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("pm"),
|
||||
t("plus.minus"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "-+", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("mp"),
|
||||
t("minus.plus"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "rhs", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("mathrm{R.H.S}"),
|
||||
@@ -124,9 +115,15 @@ return {
|
||||
t("union"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "sub", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("subset.eq"),
|
||||
t("subset"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "suq", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
s({ trig = "subset=", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("supset.eq"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "sup", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("supset"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "supset=", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("supset.eq"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "tp", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
@@ -144,9 +141,6 @@ return {
|
||||
s({ trig = "xx", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("times"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "=>", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("implies"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "llr", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("longleftrightarrow"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
@@ -180,7 +174,7 @@ return {
|
||||
s({ trig = "ell", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("ell"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "ot", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
s({ trig = "ox", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("times.circle"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "op", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
@@ -218,7 +212,7 @@ return {
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "jk", wordTrig = false, snippetType = "autosnippet" },
|
||||
{ trig = "jo", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
_(<>)
|
||||
|
||||
72
LuaSnip/typst/text.lua
Normal file
72
LuaSnip/typst/text.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
local ls = require("luasnip")
|
||||
local c = ls.choice_node
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local tex = require("util.latex")
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
return {
|
||||
-- s({ trig = "if", snippetType = "autosnippet" }, {
|
||||
-- t("\\text{\\ if\\ }"),
|
||||
-- }, { condition = tex.in_mathzone }),
|
||||
s({ trig = "wlog", snippetType = "autosnippet" }, {
|
||||
t("without loss of generality"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "Wlog", snippetType = "autosnippet" }, {
|
||||
t("Without loss of generality"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "%%", snippetType = "autosnippet" }, {
|
||||
t("\\%"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "&&", snippetType = "autosnippet" }, {
|
||||
t("\\&"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "##", snippetType = "autosnippet" }, {
|
||||
t("\\#"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "thm", snippetType = "autosnippet" }, {
|
||||
t("theorem"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "propp", snippetType = "autosnippet" }, {
|
||||
t("proposition"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "deff", snippetType = "autosnippet" }, {
|
||||
t("definition"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "exaa", snippetType = "autosnippet" }, {
|
||||
t("example"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iee", snippetType = "autosnippet" }, {
|
||||
t("i.e."),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "stt", snippetType = "autosnippet" }, {
|
||||
t("such that"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iff", snippetType = "autosnippet" }, {
|
||||
t("if and only if"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iso" }, {
|
||||
t("isomorphic"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iso" }, {
|
||||
t("isomorphism"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "homo" }, {
|
||||
t("homomorphism"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "homo" }, {
|
||||
t("homomorphic"),
|
||||
}, { condition = tex.in_text })
|
||||
-- s({ trig = "psp", snippetType = "autosnippet" }, {
|
||||
-- t("\\(p\\)-subgroup"),
|
||||
-- }, { condition = tex.in_text }),
|
||||
-- s({ trig = "pgp", snippetType = "autosnippet" }, {
|
||||
-- t("\\(p\\)-subgroup"),
|
||||
-- }, { condition = tex.in_text }),
|
||||
-- s({ trig = "spsp", snippetType = "autosnippet" }, {
|
||||
-- t("Sylow \\(p\\)-subgroup"),
|
||||
-- }, { condition = tex.in_text }),
|
||||
}
|
||||
Reference in New Issue
Block a user