This commit is contained in:
Zelong Kuang
2025-09-30 22:59:47 +10:00
parent 46c470d1f7
commit b5303f2cdd
28 changed files with 279 additions and 1689 deletions

View File

@@ -88,6 +88,20 @@ return {
),
{ condition = line_begin * tex.in_text }
),
s(
{ trig = "bsol", snippetType = "autosnippet" },
fmta(
[[
\begin{solution}
<>
\end{solution}
]],
{
i(0),
}
),
{ condition = line_begin * tex.in_text }
),
s(
{ trig = "bf", snippetType = "autosnippet" },
fmta(
@@ -230,12 +244,11 @@ return {
{ trig = "ben", snippetType = "autosnippet" },
fmta(
[[
\begin{enumerate}[<>]
\begin{enumerate}
\item <>
\end{enumerate}
]],
{
i(1, "(a)"),
i(0),
}
),

View File

@@ -133,12 +133,6 @@ return {
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "tet", snippetType = "autosnippet" },
fmta("\\text{<>}", {
i(1),
})
),
s({ trig = "CC", snippetType = "autosnippet" },
t("\\mathbb{C}"),
{ condition = tex.in_mathzone() }),

View File

@@ -176,24 +176,6 @@ return {
}),
{ 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 = "(%a)~", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
fmta("\\tilde{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "dot", snippetType = "autosnippet", priority = 2000 },
fmta("\\dot{<>}", {

View File

@@ -1,301 +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 c = ls.choice_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 = "bqu", snippetType = "autosnippet" },
fmta(
[[
\begin{quantikz}
& <>
\end{quantikz}
]],
{
i(0),
}
),
{ condition = tex.in_text }
),
s(
{ trig = "cl", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\ctrl{"), i(1), t("}") }), sn(nil, { t("\\ctrl["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "ocl", snippetType = "autosnippet", priority = 2000 },
c(1, { sn(nil, { t("\\octrl{"), i(1), t("}") }), sn(nil, { t("\\octrl["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "tar", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\targ{"), i(1), t("}") }), sn(nil, { t("\\targX{"), i(1), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "gate", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\gate{"), i(1), t("}") }), sn(nil, { t("\\gate["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "g(%a)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\gate{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "wire", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\wire["), i(1), t("]{"), i(2), t("}") }), sn(nil, { t("\\wire{"), i(1), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "mt", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\meter{"), i(1), t("}") }), sn(nil, { t("\\meter["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "phase", snippetType = "autosnippet" },
fmta("\\phase{<>}", {
i(0),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "swap", snippetType = "autosnippet" },
fmta("\\swap{<>}", {
i(0),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "ls", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\lstick{"), i(1), t("}") }), sn(nil, { t("\\lstick["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "rs", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\rstick{"), i(1), t("}") }), sn(nil, { t("\\rstick["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_quantikz }
),
s(
{ trig = "group", snippetType = "autosnippet" },
fmta("\\gategroup[<>,steps=<>]{<>}", {
i(1),
i(2),
i(0),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "slice", snippetType = "autosnippet" },
fmta("\\slice{<>}", {
i(0),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "push", snippetType = "autosnippet" },
fmta("\\push{<>}", {
i(0),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "ms", snippetType = "autosnippet" },
c(1, {
sn(nil, { t("\\measure{"), i(1), t("}") }),
sn(nil, { t("\\measuretab{"), i(1), t("}") }),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "ket", snippetType = "autosnippet" },
fmta("\\ket{<>}", {
i(0),
}),
{ condition = tex.in_quantikz }
),
s(
{ trig = "bra", snippetType = "autosnippet" },
fmta("\\bra{<>}", {
i(0),
}),
{ condition = tex.in_quantikz }
),
s({ trig = "alp", snippetType = "autosnippet", wordTrig = false }, {
t("\\alpha"),
}, { condition = tex.in_quantikz }),
s({ trig = "Alp", snippetType = "autosnippet", wordTrig = false }, {
t("\\Alpha"),
}, { condition = tex.in_quantikz }),
s({ trig = "beta", snippetType = "autosnippet", wordTrig = false }, {
t("\\beta"),
}, { condition = tex.in_quantikz }),
s({ trig = "Beta", snippetType = "autosnippet", wordTrig = false }, {
t("\\Beta"),
}, { condition = tex.in_quantikz }),
s({ trig = "gam", snippetType = "autosnippet", wordTrig = false }, {
t("\\gamma"),
}, { condition = tex.in_quantikz }),
s({ trig = "Gam", snippetType = "autosnippet", wordTrig = false }, {
t("\\Gamma"),
}, { condition = tex.in_quantikz }),
s({ trig = "del", snippetType = "autosnippet", wordTrig = false }, {
t("\\delta"),
}, { condition = tex.in_quantikz }),
s({ trig = "Del", snippetType = "autosnippet", wordTrig = false }, {
t("\\Delta"),
}, { condition = tex.in_quantikz }),
s({ trig = "eps", snippetType = "autosnippet", wordTrig = false }, {
t("\\epsilon"),
}, { condition = tex.in_quantikz }),
s({ trig = "vps", snippetType = "autosnippet", wordTrig = false }, {
t("\\varepsilon"),
}, { condition = tex.in_quantikz }),
s({ trig = "Eps", snippetType = "autosnippet", wordTrig = false }, {
t("\\Epsilon"),
}, { condition = tex.in_quantikz }),
s({ trig = "zeta", snippetType = "autosnippet", wordTrig = false }, {
t("\\zeta"),
}, { condition = tex.in_quantikz }),
s({ trig = "Zeta", snippetType = "autosnippet", wordTrig = false }, {
t("\\Zeta"),
}, { condition = tex.in_quantikz }),
s({ trig = "eta", snippetType = "autosnippet", wordTrig = false }, {
t("\\eta"),
}, { condition = tex.in_quantikz }),
s({ trig = "Eta", snippetType = "autosnippet", wordTrig = false }, {
t("\\Eta"),
}, { condition = tex.in_quantikz }),
s({ trig = "the", snippetType = "autosnippet", wordTrig = false }, {
t("\\theta"),
}, { condition = tex.in_quantikz }),
s({ trig = "The", snippetType = "autosnippet", wordTrig = false }, {
t("\\Theta"),
}, { condition = tex.in_quantikz }),
s({ trig = "iot", snippetType = "autosnippet", wordTrig = false }, {
t("\\iota"),
}, { condition = tex.in_quantikz }),
s({ trig = "Iot", snippetType = "autosnippet", wordTrig = false }, {
t("\\Iota"),
}, { condition = tex.in_quantikz }),
s({ trig = "kap", snippetType = "autosnippet", wordTrig = false }, {
t("\\kappa"),
}, { condition = tex.in_quantikz }),
s({ trig = "Kap", snippetType = "autosnippet", wordTrig = false }, {
t("\\Kappa"),
}, { condition = tex.in_quantikz }),
s({ trig = "lam", snippetType = "autosnippet", wordTrig = false }, {
t("\\lambda"),
}, { condition = tex.in_quantikz }),
s({ trig = "Lam", snippetType = "autosnippet", wordTrig = false }, {
t("\\Lambda"),
}, { condition = tex.in_quantikz }),
s({ trig = "mu", snippetType = "autosnippet", wordTrig = false }, {
t("\\mu"),
}, { condition = tex.in_quantikz }),
s({ trig = "Mu", snippetType = "autosnippet", wordTrig = false }, {
t("\\Mu"),
}, { condition = tex.in_quantikz }),
s({ trig = "nu", snippetType = "autosnippet", wordTrig = false }, {
t("\\nu"),
}, { condition = tex.in_quantikz }),
s({ trig = "Nu", snippetType = "autosnippet", wordTrig = false }, {
t("\\Nu"),
}, { condition = tex.in_quantikz }),
-- s({ trig = "xi", snippetType = "autosnippet", wordTrig = false }, {
-- t("\\xi"),
-- }, { condition = tex.in_quantikz }),
-- s({ trig = "Xi", snippetType = "autosnippet", wordTrig = false }, {
-- t("\\Xi"),
-- }, { condition = tex.in_quantikz }),
s({ trig = "omi", snippetType = "autosnippet", wordTrig = false }, {
t("\\omicron"),
}, { condition = tex.in_quantikz }),
s({ trig = "pi", snippetType = "autosnippet", wordTrig = false }, {
t("\\pi"),
}, { condition = tex.in_quantikz }),
s({ trig = "\\pii", snippetType = "autosnippet", wordTrig = false, priority = 2000 }, {
t("p_i"),
}, { condition = tex.in_quantikz }),
s({ trig = "Pi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Pi"),
}, { condition = tex.in_quantikz }),
s({ trig = "rho", snippetType = "autosnippet", wordTrig = false }, {
t("\\rho"),
}, { condition = tex.in_quantikz }),
s({ trig = "Rho", snippetType = "autosnippet", wordTrig = false }, {
t("\\Rho"),
}, { condition = tex.in_quantikz }),
s({ trig = "sig", snippetType = "autosnippet", wordTrig = false }, {
t("\\sigma"),
}, { condition = tex.in_quantikz }),
s({ trig = "Sig", snippetType = "autosnippet", wordTrig = false }, {
t("\\Sigma"),
}, { condition = tex.in_quantikz }),
s({ trig = "tau", snippetType = "autosnippet", wordTrig = false }, {
t("\\tau"),
}, { condition = tex.in_quantikz }),
s({ trig = "Tau", snippetType = "autosnippet", wordTrig = false }, {
t("\\Tau"),
}, { condition = tex.in_quantikz }),
s({ trig = "ups", snippetType = "autosnippet", wordTrig = false }, {
t("\\ups"),
}, { condition = tex.in_quantikz }),
s({ trig = "Ups", snippetType = "autosnippet", wordTrig = false }, {
t("\\Ups"),
}, { condition = tex.in_quantikz }),
s({ trig = "phi", snippetType = "autosnippet", wordTrig = false }, {
t("\\phi"),
}, { condition = tex.in_quantikz }),
s({ trig = "Phi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Phi"),
}, { condition = tex.in_quantikz }),
s({ trig = "vhi", snippetType = "autosnippet", wordTrig = false }, {
t("\\varphi"),
}, { condition = tex.in_quantikz }),
s({ trig = "Vhi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Varphi"),
}, { condition = tex.in_quantikz }),
s({ trig = "chi", snippetType = "autosnippet", wordTrig = false }, {
t("\\chi"),
}, { condition = tex.in_quantikz }),
s({ trig = "Chi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Chi"),
}, { condition = tex.in_quantikz }),
s({ trig = "psi", snippetType = "autosnippet", wordTrig = false }, {
t("\\psi"),
}, { condition = tex.in_quantikz }),
s({ trig = "Psi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Psi"),
}, { condition = tex.in_quantikz }),
s({ trig = "ome", snippetType = "autosnippet", wordTrig = false }, {
t("\\omega"),
}, { condition = tex.in_quantikz }),
s({ trig = "Ome", snippetType = "autosnippet", wordTrig = false }, {
t("\\Omega"),
}, { condition = tex.in_quantikz }),
}

View File

@@ -1,96 +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, i(1, 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 = "sp", snippetType = "autosnippet" }, fmta("\\hat{\\$}", {}), { condition = tex.in_mathzone }),
-- s({ trig = "T", snippetType = "autosnippet" }, fmta("\\mathcal{T}", {}), { condition = tex.in_mathzone }),
-- s({ trig = "tv", snippetType = "autosnippet" }, fmta("\\mathrm{TV}", {}), { condition = tex.in_mathzone }),
-- s({ trig = "ce", snippetType = "autosnippet" }, fmta("\\mathrm{couple}", {}), { condition = tex.in_mathzone }),
-- s({ trig = "mix", snippetType = "autosnippet" }, fmta("\\mathrm{mix}", {}), { condition = tex.in_mathzone }),
s({ trig = "\\psii", snippetType = "autosnippet", priority = 3000 }, {
t("\\psi_i"),
}, { condition = tex.in_mathzone }),
s({ trig = "FF", snippetType = "autosnippet", priority = 3000 }, {
t("\\mathcal{F}"),
}, { condition = tex.in_mathzone }),
s({ trig = "SS", snippetType = "autosnippet", priority = 3000 }, {
t("\\mathcal{S}"),
}, { condition = tex.in_mathzone }),
s(
{ trig = "EE", snippetType = "autosnippet" },
fmta("\\E_{\\sigma} \\ab[ <> ]", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s({ trig = "\\varphii", snippetType = "autosnippet", priority = 3000 }, {
t("\\varphi_i"),
}, { condition = tex.in_mathzone }),
s({ trig = "cc", snippetType = "autosnippet" }, {
t("^c"),
}, { condition = tex.in_mathzone }),
s({ trig = "--", snippetType = "autosnippet", priority = 2000 }, {
t("^-"),
}, { condition = tex.in_mathzone }),
s({ trig = "\\oplust", snippetType = "autosnippet", priority = 2000 }, {
t("\\OPT"),
}, { condition = tex.in_mathzone }),
s({ trig = "++", snippetType = "autosnippet" }, {
t("^+"),
}, { condition = tex.in_mathzone }),
s({ trig = "ii", snippetType = "autosnippet" }, {
t("\\int"),
}, { condition = tex.in_mathzone }),
s({ trig = "ed", snippetType = "autosnippet" }, {
t("\\ed"),
}, { condition = tex.in_mathzone }),
-- s({ trig = "cas", snippetType = "autosnippet", priority = 2000 }, {
-- t("\\cas"),
-- }, { condition = tex.in_mathzone }),
s({ trig = "lr", snippetType = "autosnippet" }, {
t("\\leftrightarrow"),
}, { condition = tex.in_mathzone }),
s({ trig = "sa", snippetType = "autosnippet" }, {
t("s_A"),
}, { condition = tex.in_mathzone }),
s({ trig = "sb", snippetType = "autosnippet" }, {
t("s_B"),
}, { condition = tex.in_mathzone }),
s(
{ trig = "(%a);", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\hat{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_mathzone }
),
s({ trig = "\\psi;", snippetType = "autosnippet", priority = 3000 }, {
t("\\tilde{\\psi}"),
}, { condition = tex.in_mathzone }),
s({ trig = "\\varphi;", snippetType = "autosnippet", priority = 3000 }, {
t("\\tilde{\\varphi}"),
}, { condition = tex.in_mathzone }),
s({ trig = "IS", snippetType = "autosnippet", priority = 3000 }, {
t("\\mathcal{IS}"),
}, { condition = tex.in_mathzone }),
}

View File

@@ -136,121 +136,7 @@ return {
s({ trig = "=>", snippetType = "autosnippet" }, {
t("\\(\\implies\\)"),
}, { condition = tex.in_text }),
s(
{ trig = "homework" },
fmta(
[[
\documentclass{article}
\newcommand{\Class}{<>}
\newcommand{\Title}{Homework <>}
\author{Hanyu Yan}
\input{~/Documents/Latex/Package_elegantbook.tex}
\input{~/Documents/Latex/Sample_Homework.tex}
\begin{document}
\maketitle \thispagestyle{empty}
<>
\end{document}
]],
{
c(1, {
t("Numerical Analysis"),
t("Experimental Quantum Information Processing"),
t("Quantum Communication and Cryptography"),
}),
i(2, "number"),
i(0),
}
),
{ condition = tex.in_text * line_begin }
),
s(
{ trig = "note" },
fmta(
[[
\documentclass[letterpaper, 12pt]{article}
\input{~/Documents/Latex/note_template.tex}
\begin{document}
\title{<> \\[1em]
\normalsize <>}
\author{\normalsize Fireond}
\date{\normalsize\vspace{-1ex} Last updated: \today}
\maketitle
\tableofcontents\label{sec:contents}
<>
\end{document}
]],
{
i(1, "title"),
i(2, "subtitle"),
i(0),
}
),
{ condition = tex.in_text * line_begin }
),
s(
{ trig = "algo" },
fmta(
[[
\documentclass[utf8]{article}
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage{setspace}
\usepackage{verbatim}
\usepackage{algorithm}
\usepackage{algpseudocodex}
\algrenewcommand\algorithmicrequire{\textbf{Input:}}
\algrenewcommand\algorithmicensure{\textbf{Output:}}
\input{~/Documents/Latex/Package_elegantbook.tex}
\onehalfspacing
\title{\bf\huge Algorithm Design - Assignment <>}
\author{Hanyu Yan\\2022010860\\Class 23}
\date{\today}
\begin{document}
\maketitle
<>
\end{document}
]],
{ i(1), i(0) }
),
{ condition = tex.in_text * line_begin }
),
s(
{ trig = "report" },
fmta(
[[
%! TeX program = xelatex
\documentclass{article}
\newcommand{\Class}{<>}
\newcommand{\Title}{<>}
\author{严涵宇}
\usepackage[UTF8]{ctex}
\input{~/Documents/Latex/Package_elegantbook.tex}
\input{~/Documents/Latex/Sample_Homework.tex}
\begin{document}
\maketitle \thispagestyle{empty}
<>
\end{document}
]],
{
c(1, {
t("量子信息实验报告"),
}),
i(2),
i(0),
}
),
{ condition = tex.in_text * line_begin }
),
s({ trig = "=<", snippetType = "autosnippet" }, {
t("\\(\\impliedby\\)"),
}, { condition = tex.in_text }),
}