This commit is contained in:
Zelong Kuang
2025-09-21 20:43:38 +10:00
parent 9d1536e5af
commit 46c470d1f7
50 changed files with 5465 additions and 214 deletions

View File

@@ -0,0 +1,300 @@
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 = "(%a);", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
-- fmta("\\hat{<>}", {
-- f(function(_, snip)
-- return snip.captures[1]
-- end),
-- }),
-- { condition = tex.in_mathzone_md }
-- ),
s(
{ trig = "([%a%)%]%}])(%d)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("<>_<>", {
f(function(_, snip)
return snip.captures[1]
end),
f(function(_, snip)
return snip.captures[2]
end),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "([%a%)%]%}])_(%d)(%d)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("<>_{<><>}", {
f(function(_, snip)
return snip.captures[1]
end),
f(function(_, snip)
return snip.captures[2]
end),
f(function(_, snip)
return snip.captures[3]
end),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "([%a%)%]%}])(%a)%2", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 100 },
fmta("<>_<>", {
f(function(_, snip)
return snip.captures[1]
end),
f(function(_, snip)
return snip.captures[2]
end),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "([%a%)%]%}])_(%a)(%a)%3", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("<>_{<><>}", {
f(function(_, snip)
return snip.captures[1]
end),
f(function(_, snip)
return snip.captures[2]
end),
f(function(_, snip)
return snip.captures[3]
end),
}),
{ condition = tex.in_mathzone_md }
),
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_md }
),
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_md }
),
s(
{ trig = "%((.+)%)/", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\frac{<>}{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
i(1),
}),
{ condition = tex.in_mathzone_md }
),
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_md }
),
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_md }
),
-- s(
-- { trig = "$(.*)$(%a)", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
-- fmta("$<>$ <>", {
-- f(function(_, snip)
-- return snip.captures[1]
-- end),
-- f(function(_, snip)
-- return snip.captures[2]
-- end),
-- })
-- ),
s(
{ trig = "lim", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\lim_{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "lsup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\limsup_{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "linf", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\liminf_{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
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_md }
),
s(
{ trig = "pd", snippetType = "autosnippet" },
c(1, {
sn(nil, { t("\\prod_{"), i(1), t("} ") }),
sn(nil, { t("\\prod_{"), i(1), t("}^{"), i(2), t("} ") }),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bot", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigotimes_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bop", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigoplus_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bcap", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigcap_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bcup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigcup_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "blor", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigvee_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "band", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigwedge_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bscap", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigsqcap_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bscup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\bigsqcup_{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "int", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\int_{<>}^{<>} <> \\d <>", {
i(1),
i(2),
i(3),
i(4),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "oint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\oint_{<>}^{<>} <> \\d <>", {
i(1),
i(2),
i(3),
i(4),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "2int", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\int_{<>}^{<>}\\int_{<>}^{<>} <> \\d <>\\d <>", {
i(1),
i(2),
i(3),
i(4),
i(5),
i(6),
i(7),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "iint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\iint_{<>}^{<>} <> \\d <>", {
i(1, "-\\infty"),
i(2, "\\infty"),
i(3),
i(4),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "lint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\int_{<>} <> \\d <>", {
i(1, "\\infty"),
i(2),
i(3),
}),
{ condition = tex.in_mathzone_md }
),
}

View File

@@ -5,20 +5,34 @@ local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local d = ls.dynamic_node
local c = ls.choice_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))
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 = "ii", snippetType = "autosnippet" }, fmta("$<>$", i(1))),
-- s({ trig = "dd", snippetType = "autosnippet" }, fmta("$$\n<>\n$$", i(1))),
s(
{ trig = "pv", snippetType = "autosnippet" },
c(1, {
sn(nil, { t("\\frac{\\partial "), i(1), t("}{\\partial "), i(2), t("}") }),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "ov", snippetType = "autosnippet" },
c(1, {
sn(nil, { t("\\frac{\\d "), i(1), t("}{\\d "), i(2), t("}") }),
}),
{ condition = tex.in_mathzone }
),
}

138
LuaSnip/markdown/env.lua Normal file
View File

@@ -0,0 +1,138 @@
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 = ";b", snippetType = "autosnippet" }, fmta("**<>**", i(1)), { condition = tex.in_text_md }),
s({ trig = "b", snippetType = "autosnippet" }, fmta("**<>**", i(1)), { condition = tex.in_text_md }),
s({ trig = ";t", snippetType = "autosnippet" }, fmta("*<>*", i(1)), { condition = tex.in_text_md }),
s({ trig = "t", snippetType = "autosnippet" }, fmta("*<>*", i(1)), { condition = tex.in_text_md }),
s({ trig = ";h", snippetType = "autosnippet" }, fmta("- [ ] <>", i(0)), { condition = tex.in_text_md }),
s({ trig = "h", snippetType = "autosnippet" }, fmta("- [ ] <>", i(0)), { condition = tex.in_text_md }),
s({ trig = ";H", snippetType = "autosnippet" }, fmta("- [x] <>", i(0)), { condition = tex.in_text_md }),
s({ trig = "H", snippetType = "autosnippet" }, fmta("- [x] <>", i(0)), { condition = tex.in_text_md }),
s(
{ trig = ";c", snippetType = "autosnippet" },
fmta(
[[
```<>
<>
```
]],
{ i(1), i(0) }
),
{ condition = tex.in_text_md }
),
s(
{ trig = ";d", snippetType = "autosnippet" },
fmta(
[[
<<!--
<>
-->>
]],
{ i(0) }
),
{ condition = tex.in_text_md }
),
s(
{ trig = "d", snippetType = "autosnippet" },
fmta(
[[
<<!--
<>
-->>
]],
{ i(0) }
),
{ condition = tex.in_text_md }
),
s({ trig = "ii", snippetType = "autosnippet" }, fmta("$<>$", i(1)), { condition = tex.in_text_md }),
s({ trig = "dd", snippetType = "autosnippet" }, fmta("$$\n<>\n$$", i(1)), { condition = tex.in_text_md }),
s(
{ trig = "bff", snippetType = "autosnippet" },
fmta(
[[
**Proof.**
<>
$\square$
]],
{
i(0),
}
),
{ condition = line_begin * tex.in_text }
),
s(
{ trig = "beg", snippetType = "autosnippet" },
fmta(
[[
[!<>] <>
<>
]],
{
i(1),
rep(1),
i(0),
}
),
{ condition = line_begin }
),
s(
{ trig = "case", snippetType = "autosnippet" },
fmta(
[[
\begin{cases}
<>
\end{cases}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bal", snippetType = "autosnippet" },
fmta(
[[
\begin{aligned}
<>
\end{aligned}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bal", snippetType = "autosnippet", priority = 2000 },
fmta(
[[
\begin{aligned}
<>
\end{aligned}
]],
{
d(1, get_visual),
}
),
{ condition = tex.in_mathzone_md }
),
}

104
LuaSnip/markdown/font.lua Normal file
View File

@@ -0,0 +1,104 @@
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_md }
),
s(
{ trig = "msf", snippetType = "autosnippet" },
fmta("\\mathsf{<>}", {
i(0),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bf", snippetType = "autosnippet" },
fmta("\\mathbf{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "cal", snippetType = "autosnippet", priority = 2000 },
fmta("\\mathcal{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "cal", snippetType = "autosnippet" },
fmta("\\mathcal{<>}", {
i(0),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "scr", snippetType = "autosnippet", priority = 2000 },
fmta("\\mathscr{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "scr", snippetType = "autosnippet" },
fmta("\\mathscr{<>}", {
i(0),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "mbb", snippetType = "autosnippet", priority = 2000 },
fmta("\\mathbb{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "mbb", snippetType = "autosnippet" },
fmta("\\mathbb{<>}", {
i(0),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "mrm", snippetType = "autosnippet", priority = 2000 },
fmta("\\mathrm{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "mrm", snippetType = "autosnippet" },
fmta("\\mathrm{<>}", {
i(0),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "qq", wordTrig = false, snippetType = "autosnippet" },
fmta("\\text{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
}

View File

@@ -0,0 +1,172 @@
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local tex = require("util.latex")
return {
s({ trig = "alp", snippetType = "autosnippet", wordTrig = false }, {
t("\\alpha"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Alp", snippetType = "autosnippet", wordTrig = false }, {
t("\\Alpha"),
}, { condition = tex.in_mathzone_md }),
s({ trig = ";a", snippetType = "autosnippet", wordTrig = false }, {
t("\\alpha"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "beta", snippetType = "autosnippet", wordTrig = false }, {
t("\\beta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = ";b", snippetType = "autosnippet", wordTrig = false }, {
t("\\beta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Beta", snippetType = "autosnippet", wordTrig = false }, {
t("\\Beta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "gam", snippetType = "autosnippet", wordTrig = false }, {
t("\\gamma"),
}, { condition = tex.in_mathzone_md }),
s({ trig = ";c", snippetType = "autosnippet", wordTrig = false }, {
t("\\gamma"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Gam", snippetType = "autosnippet", wordTrig = false }, {
t("\\Gamma"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "del", snippetType = "autosnippet", wordTrig = false }, {
t("\\delta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = ";d", snippetType = "autosnippet", wordTrig = false }, {
t("\\delta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Del", snippetType = "autosnippet", wordTrig = false }, {
t("\\Delta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "eps", snippetType = "autosnippet", wordTrig = false }, {
t("\\epsilon"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "vps", snippetType = "autosnippet", wordTrig = false }, {
t("\\varepsilon"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Eps", snippetType = "autosnippet", wordTrig = false }, {
t("\\Epsilon"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "zeta", snippetType = "autosnippet", wordTrig = false }, {
t("\\zeta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Zeta", snippetType = "autosnippet", wordTrig = false }, {
t("\\Zeta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "eta", snippetType = "autosnippet", wordTrig = false }, {
t("\\eta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Eta", snippetType = "autosnippet", wordTrig = false }, {
t("\\Eta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "the", snippetType = "autosnippet", wordTrig = false }, {
t("\\theta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "The", snippetType = "autosnippet", wordTrig = false }, {
t("\\Theta"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "iot", snippetType = "autosnippet", wordTrig = false }, {
t("\\iota"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Iot", snippetType = "autosnippet", wordTrig = false }, {
t("\\Iota"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "kap", snippetType = "autosnippet", wordTrig = false }, {
t("\\kappa"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Kap", snippetType = "autosnippet", wordTrig = false }, {
t("\\Kappa"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "lam", snippetType = "autosnippet", wordTrig = false }, {
t("\\lambda"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Lam", snippetType = "autosnippet", wordTrig = false }, {
t("\\Lambda"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "mu", snippetType = "autosnippet", wordTrig = false }, {
t("\\mu"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Mu", snippetType = "autosnippet", wordTrig = false }, {
t("\\Mu"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "nu", snippetType = "autosnippet", wordTrig = false }, {
t("\\nu"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Nu", snippetType = "autosnippet", wordTrig = false }, {
t("\\Nu"),
}, { condition = tex.in_mathzone_md }),
-- s({ trig = "xi", snippetType = "autosnippet", wordTrig = false }, {
-- t("\\xi"),
-- }, { condition = tex.in_mathzone_md }),
-- s({ trig = "Xi", snippetType = "autosnippet", wordTrig = false }, {
-- t("\\Xi"),
-- }, { condition = tex.in_mathzone_md }),
s({ trig = "omi", snippetType = "autosnippet", wordTrig = false }, {
t("\\omicron"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "pi", snippetType = "autosnippet", wordTrig = false }, {
t("\\pi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\pii", snippetType = "autosnippet", wordTrig = false, priority = 2000 }, {
t("p_i"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Pi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Pi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "rho", snippetType = "autosnippet", wordTrig = false }, {
t("\\rho"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Rho", snippetType = "autosnippet", wordTrig = false }, {
t("\\Rho"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "sig", snippetType = "autosnippet", wordTrig = false }, {
t("\\sigma"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Sig", snippetType = "autosnippet", wordTrig = false }, {
t("\\Sigma"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "tau", snippetType = "autosnippet", wordTrig = false }, {
t("\\tau"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Tau", snippetType = "autosnippet", wordTrig = false }, {
t("\\Tau"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ups", snippetType = "autosnippet", wordTrig = false }, {
t("\\ups"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Ups", snippetType = "autosnippet", wordTrig = false }, {
t("\\Ups"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "phi", snippetType = "autosnippet", wordTrig = false }, {
t("\\phi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Phi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Phi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "vhi", snippetType = "autosnippet", wordTrig = false }, {
t("\\varphi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Vhi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Varphi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "chi", snippetType = "autosnippet", wordTrig = false }, {
t("\\chi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Chi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Chi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "psi", snippetType = "autosnippet", wordTrig = false }, {
t("\\psi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Psi", snippetType = "autosnippet", wordTrig = false }, {
t("\\Psi"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ome", snippetType = "autosnippet", wordTrig = false }, {
t("\\omega"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "Ome", snippetType = "autosnippet", wordTrig = false }, {
t("\\Omega"),
}, { condition = tex.in_mathzone_md }),
}

View File

@@ -0,0 +1,447 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_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 = "sin", snippetType = "autosnippet" }, {
t("\\sin"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "asin", snippetType = "autosnippet" }, {
t("\\arcsin"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cos", snippetType = "autosnippet" }, {
t("\\cos"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "acos", snippetType = "autosnippet" }, {
t("\\arccos"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "tan", snippetType = "autosnippet" }, {
t("\\tan"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "atan", snippetType = "autosnippet" }, {
t("\\arctan"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cot", snippetType = "autosnippet" }, {
t("\\cot"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "acot", snippetType = "autosnippet" }, {
t("\\arccot"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "csc", snippetType = "autosnippet" }, {
t("\\csc"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "acsc", snippetType = "autosnippet" }, {
t("\\arccsc"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "sec", snippetType = "autosnippet" }, {
t("\\sec"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "asec", snippetType = "autosnippet" }, {
t("\\arcsec"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "log", snippetType = "autosnippet" }, {
t("\\log"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ln", snippetType = "autosnippet" }, {
t("\\ln"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "exp", snippetType = "autosnippet" }, {
t("\\exp"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "grad", snippetType = "autosnippet" }, {
t("\\grad"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "curl", snippetType = "autosnippet" }, {
t("\\curl"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "div", snippetType = "autosnippet" }, {
t("\\div"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "lap", snippetType = "autosnippet" }, {
t("\\laplacian"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbr", snippetType = "autosnippet" }, {
t("\\mathbb{R}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbq", snippetType = "autosnippet" }, {
t("\\mathbb{Q}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbh", snippetType = "autosnippet" }, {
t("\\mathbb{H}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbc", snippetType = "autosnippet" }, {
t("\\mathbb{C}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbz", snippetType = "autosnippet" }, {
t("\\mathbb{Z}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbn", snippetType = "autosnippet" }, {
t("\\mathbb{N}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bb1", snippetType = "autosnippet", priority = 2000 }, {
t("\\mathbbm{1}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bbe", snippetType = "autosnippet" }, {
t("\\mathbb{E}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "EE", snippetType = "autosnippet" }, {
t("\\mathbb{E}"),
}, { condition = tex.in_mathzone_md }),
s(
{ trig = "bb(%w)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\mathbb{<>}", {
f(function(_, snip)
return string.upper(snip.captures[1])
end),
}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "exp", snippetType = "autosnippet" }, {
t("\\exp"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cv", snippetType = "autosnippet" }, fmta("\\conv", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "brr", snippetType = "autosnippet" },
fmta("\\bar{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "bar", snippetType = "autosnippet" },
fmta("\\overline{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "(%a)bar", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
fmta("\\overline{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "ob", snippetType = "autosnippet" },
fmta("\\overbrace{<>}^{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "ob", snippetType = "autosnippet", priority = 2000 },
fmta("\\overbrace{<>}^{<>}", {
d(1, get_visual),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "td", snippetType = "autosnippet", priority = 2000 },
fmta("\\tilde{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "td", snippetType = "autosnippet" },
fmta("\\ttlde{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "(\\%a+)~", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
fmta("\\tilde{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "(%a)~", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
fmta("\\tilde{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "dot", snippetType = "autosnippet", priority = 2000 },
fmta("\\dot{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "dot", snippetType = "autosnippet" },
fmta("\\dot{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "doo", snippetType = "autosnippet", priority = 2000 },
fmta("\\ddot{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "vb", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\vb{"), i(1), t("}") }), sn(nil, { t("\\vb*{"), i(1), t("}") }) }),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "vu", snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\vu{"), i(1), t("}") }), sn(nil, { t("\\vu*{"), i(1), t("}") }) }),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "hat", snippetType = "autosnippet", priority = 2000 },
fmta("\\hat{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "hat", snippetType = "autosnippet" },
fmta("\\hat{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "vec", snippetType = "autosnippet", priority = 2000 },
fmta("\\vec{<>}", {
d(1, get_visual),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = ";v", snippetType = "autosnippet" },
fmta("\\vec{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "vec", snippetType = "autosnippet" },
fmta("\\vec{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
-- s({ trig = "rr", snippetType = "autosnippet" }, fmta("\\ran", {}), { condition = tex.in_mathzone_md }),
-- s({ trig = "kk", snippetType = "autosnippet" }, fmta("\\ker", {}), { condition = tex.in_mathzone_md }),
s({ trig = "tr", snippetType = "autosnippet" }, fmta("\\operatorname{tr}", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "span", snippetType = "autosnippet" },
fmta("\\operatorname{span}", {}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "aut", snippetType = "autosnippet" }, fmta("\\Aut", {}), { condition = tex.in_mathzone_md }),
s({ trig = "gal", snippetType = "autosnippet" }, fmta("\\Gal", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "rank", snippetType = "autosnippet" },
fmta("\\operatorname{rank}", {}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "dim", snippetType = "autosnippet" }, fmta("\\operatorname{dim}", {}), { condition = tex.in_mathzone_md }),
s({ trig = "det", snippetType = "autosnippet" }, fmta("\\operatorname{det}", {}), { condition = tex.in_mathzone_md }),
s({ trig = "vol", snippetType = "autosnippet" }, fmta("\\Vol", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "->", snippetType = "autosnippet" },
fmta("\\xlongrightarrow{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "<-", snippetType = "autosnippet" },
fmta("\\xlongleftarrow{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "--", snippetType = "autosnippet" }, fmta("\\longleftrightarrow", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "gt", snippetType = "autosnippet" },
fmta("\\gt{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "min", snippetType = "autosnippet" }, fmta("\\min", {}), { condition = tex.in_mathzone_md }),
s({ trig = "max", snippetType = "autosnippet" }, fmta("\\max", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "amin", snippetType = "autosnippet" },
fmta("\\argmin_{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "amax", snippetType = "autosnippet" },
fmta("\\argmax_{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "sup", snippetType = "autosnippet", priority = 2000 },
fmta("\\sup", {}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "inf", snippetType = "autosnippet", priority = 2000 },
fmta("\\inf", {}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = ";r", wordTrig = false, snippetType = "autosnippet" },
fmta("\\frac{<>}{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = ";r", snippetType = "autosnippet", priority = 2000 },
fmta("\\frac{<>}{<>}", {
d(1, get_visual),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "binom", snippetType = "autosnippet" },
fmta("\\binom{<>}{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "dd", snippetType = "autosnippet" }, fmta("\\d ", {}), { condition = tex.in_mathzone_md }),
s({ trig = "poly", snippetType = "autosnippet" }, fmta("\\poly", {}), { condition = tex.in_mathzone_md }),
s(
{ trig = "sq", wordTrig = false, snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\sqrt{"), i(1), t("}") }), sn(nil, { t("\\sqrt["), i(1), t("]{"), i(2), t("}") }) }),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "mod", wordTrig = false, snippetType = "autosnippet" },
fmta("\\mod{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "nmod", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\nmod{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "pmod", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\pmod{<>}", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "sgn", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\sgn", {}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "SI", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\SI{<>}{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "cond", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\cond(<>)", {
i(1),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "cqty", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\complexqty{<>}{<>}", {
i(1),
i(2),
}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "gcd", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\gcd", {}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "deg", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
fmta("\\degree", {}),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "pr", wordTrig = false, snippetType = "autosnippet" },
fmta("\\Pr", {}),
{ condition = tex.in_mathzone_md }
),
s({ trig = "sch", snippetType = "autosnippet" }, {
t("\\Sch"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\Pii", snippetType = "autosnippet", priority = 2000 }, {
t("P_i"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "bv", snippetType = "autosnippet", priority = 2000 }, {
t("\\bigg\\vert"),
}, { condition = tex.in_mathzone_md }),
s(
{ trig = "ub", snippetType = "autosnippet", priority = 2000 },
fmta("\\underbrace{<>}", { i(1) }),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "ob", snippetType = "autosnippet", priority = 2000 },
fmta("\\overbrace{<>}", { i(1) }),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "ring", snippetType = "autosnippet", priority = 2000 },
fmta("\\mathring{<>}", { i(1) }),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "\\oplusn", snippetType = "autosnippet", priority = 2000 },
fmta("\\operatorname{<>}", { i(1) }),
{ condition = tex.in_mathzone_md }
),
}

199
LuaSnip/markdown/matrix.lua Normal file
View File

@@ -0,0 +1,199 @@
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, 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 = "bmat", snippetType = "autosnippet" },
fmta(
[[
\begin{bmatrix}
<>
\end{bmatrix}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "Bmat", snippetType = "autosnippet" },
fmta(
[[
\begin{Bmatrix}
<>
\end{Bmatrix}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "pmat", snippetType = "autosnippet" },
fmta(
[[
\begin{pmatrix}
<>
\end{pmatrix}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "Vmat", snippetType = "autosnippet" },
fmta(
[[
\begin{Vmatrix}
<>
\end{Vmatrix}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "Bmat", snippetType = "autosnippet" },
fmta(
[[
\Bmat{<>}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "dmat", snippetType = "autosnippet" },
fmta(
[[
\bdiagmat{<>}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "vmat", snippetType = "autosnippet" },
fmta(
[[
\vmat{<>}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "Vmat", snippetType = "autosnippet" },
fmta(
[[
\Vmat{<>}
]],
{
i(0),
}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "pma(%a)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("\\pmat<>{<>}", {
f(function(_, snip)
return snip.captures[1]
end),
i(0),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "II3", snippetType = "autosnippet", priority = 2000 },
fmta(
[[
\begin{bmatrix}
1 & & \\
& 1 & \\
& & 1 \\
\end{bmatrix}
]],
{}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "II4", snippetType = "autosnippet", priority = 2000 },
fmta(
[[
\begin{bmatrix}
1 & & & \\
& 1 & & \\
& & 1 & \\
& & & 1 \\
\end{bmatrix}
]],
{}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "II5", snippetType = "autosnippet", priority = 2000 },
fmta(
[[
\begin{bmatrix}
1 & & & &\\
& 1 & & &\\
& & 1 & &\\
& & & 1 &\\
& & & & 1\\
\end{bmatrix}
]],
{}
),
{ condition = tex.in_mathzone }
),
s(
{ trig = "II6", snippetType = "autosnippet", priority = 2000 },
fmta(
[[
\begin{bmatrix}
1 & & & & &\\
& 1 & & & &\\
& & 1 & & &\\
& & & 1 & &\\
& & & & 1 &\\
& & & & & 1\\
\end{bmatrix}
]],
{}
),
{ condition = tex.in_mathzone }
),
}

View File

@@ -0,0 +1,119 @@
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 = "bra", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
fmta("\\langle <>|", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "ket", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
fmta("|<>\\rangle", {
i(1),
}),
{ condition = tex.in_mathzone }
),
-- s(
-- { trig = "bra", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
-- fmta("\\bra{<>}", {
-- i(1),
-- }),
-- { condition = tex.in_mathzone }
-- ),
-- s(
-- { trig = "ket", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
-- fmta("\\ket{<>}", {
-- i(1),
-- }),
-- { condition = tex.in_mathzone }
-- ),
s(
{ trig = "bk", snippetType = "autosnippet" },
c(1, {
sn(nil, { t("\\braket{"), i(1), t("}{"), i(2), t("}") }),
sn(nil, { t("\\braket[3]{"), i(1), t("}{"), i(2), t("}{"), i(3), t("}") }),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "ev", snippetType = "autosnippet" },
fmta("\\braket[1]{<>}", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "kb", snippetType = "autosnippet" },
c(1, {
sn(nil, { t("\\ketbra{"), i(1), t("}{"), i(2), t("}") }),
sn(nil, { t("\\ketbra{"), i(1), t("}["), i(2), t("]{"), i(3), t("}") }),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "pab", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
fmta("\\left( <> \\right)", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "Bab", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
c(1, {
sn(nil, { t("\\{"), i(1), t("\\}") }),
sn(nil, { t("\\left\\{"), i(1), t("\\right\\}") }),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "bab", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
fmta("\\left[ <> \\right]", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "\\forallb", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
fmta("\\ab<< <> >>", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s(
{ trig = "vab", wordTrig = false, snippetType = "autosnippet" },
c(1, { sn(nil, { t("\\left|"), i(1), t("\\right|") }), sn(nil, { t("\\ab*|"), i(1), t("|") }) }),
{ condition = tex.in_mathzone }
),
s(
{ trig = "Vab", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
fmta("\\left\\| <> \\right\\|", {
i(1),
}),
{ condition = tex.in_mathzone }
),
s({ trig = "\\tof", snippetType = "autosnippet" }, {
t("\\Tof"),
}, { condition = tex.in_mathzone }),
}

View File

@@ -0,0 +1,285 @@
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 = "...", wordTrig = false, snippetType = "autosnippet" }, {
t("\\dots"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "c.", wordTrig = false, snippetType = "autosnippet" }, {
t("\\cdot"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\cdot.", wordTrig = false, snippetType = "autosnippet" }, {
t("\\cdots"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "v.", wordTrig = false, snippetType = "autosnippet" }, {
t("\\vdot"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\vdot.", wordTrig = false, snippetType = "autosnippet" }, {
t("\\vdots"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "iff", wordTrig = false, snippetType = "autosnippet" }, {
t("\\iff"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "inn", wordTrig = false, snippetType = "autosnippet" }, {
t("\\in"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "notin", wordTrig = false, snippetType = "autosnippet" }, {
t("not\\in"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "aa", wordTrig = false, snippetType = "autosnippet" }, {
t("\\forall"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ee", wordTrig = false, snippetType = "autosnippet" }, {
t("\\exists"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "!=", wordTrig = false, snippetType = "autosnippet" }, {
t("\\neq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "==", wordTrig = false, snippetType = "autosnippet" }, {
t("&="),
}, { condition = line_begin }),
s({ trig = "==", wordTrig = false, snippetType = "autosnippet" }, {
t("&="),
}, { condition = tex.in_mathzone }),
s({ trig = "\\leq=", wordTrig = false, snippetType = "autosnippet" }, {
t("&\\leq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\geq=", wordTrig = false, snippetType = "autosnippet" }, {
t("&\\geq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "~=", wordTrig = false, snippetType = "autosnippet" }, {
t("\\approx"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "~~", wordTrig = false, snippetType = "autosnippet" }, {
t("\\sim"),
}, { condition = tex.in_mathzone_md }),
s({ trig = ">=", wordTrig = false, snippetType = "autosnippet" }, {
t("\\geq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "<=", wordTrig = false, snippetType = "autosnippet" }, {
t("\\leq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = ">>", wordTrig = false, snippetType = "autosnippet" }, {
t("\\gg"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "<<", wordTrig = false, snippetType = "autosnippet" }, {
t("\\ll"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cp", wordTrig = false, snippetType = "autosnippet" }, {
t("\\cp"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "get", wordTrig = false, snippetType = "autosnippet" }, {
t("\\gets"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "to", wordTrig = false, snippetType = "autosnippet" }, {
t("\\to"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "mto", wordTrig = false, snippetType = "autosnippet", priority = 1001 }, {
t("\\mapsto"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\\\\\", wordTrig = false, snippetType = "autosnippet" }, {
t("\\setminus"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "||", wordTrig = false, snippetType = "autosnippet" }, {
t("\\mid"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "mid", wordTrig = false, snippetType = "autosnippet" }, {
t("\\mid"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "nmid", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
t("\\nmid"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "sr", wordTrig = false, snippetType = "autosnippet" }, {
t("^2"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cb", wordTrig = false, snippetType = "autosnippet" }, {
t("^3"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "inv", wordTrig = false, snippetType = "autosnippet" }, {
t("^{-1}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "**", wordTrig = false, snippetType = "autosnippet" }, {
t("^*"),
}, { condition = tex.in_mathzone_md }),
s({ trig = " ", wordTrig = false, snippetType = "autosnippet" }, {
t("\\,"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "<>", wordTrig = false, snippetType = "autosnippet" }, {
t("\\diamond"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "+-", wordTrig = false, snippetType = "autosnippet" }, {
t("\\pm"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "-+", wordTrig = false, snippetType = "autosnippet" }, {
t("\\mp"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "rhs", wordTrig = false, snippetType = "autosnippet" }, {
t("\\mathrm{R.H.S}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "lhs", wordTrig = false, snippetType = "autosnippet" }, {
t("\\mathrm{L.H.S}"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cap", wordTrig = false, snippetType = "autosnippet" }, {
t("\\cap"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cup", wordTrig = false, snippetType = "autosnippet" }, {
t("\\cup"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "sub", wordTrig = false, snippetType = "autosnippet" }, {
t("\\subseteq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "suq", wordTrig = false, snippetType = "autosnippet" }, {
t("\\supseteq"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "oo", wordTrig = false, snippetType = "autosnippet" }, {
t("\\infty"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "tp", wordTrig = false, snippetType = "autosnippet" }, {
t("^\\top"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "dr", wordTrig = false, snippetType = "autosnippet" }, {
t("^\\dagger"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "perp", wordTrig = false, snippetType = "autosnippet" }, {
t("\\perp"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ss", wordTrig = false, snippetType = "autosnippet" }, {
t("\\star"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "xx", wordTrig = false, snippetType = "autosnippet" }, {
t("\\times"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "=>", wordTrig = false, snippetType = "autosnippet" }, {
t("\\implies"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "llr", wordTrig = false, snippetType = "autosnippet" }, {
t("\\longleftrightarrow"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "up", wordTrig = false, snippetType = "autosnippet" }, {
t("\\uparrow"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "down", wordTrig = false, snippetType = "autosnippet" }, {
t("\\downarrow"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cir", wordTrig = false, snippetType = "autosnippet" }, {
t("\\circ"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "iso", wordTrig = false, snippetType = "autosnippet" }, {
t("\\cong"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ihbar", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
t("i\\hbar"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "hbar", wordTrig = false, snippetType = "autosnippet", priority = 1500 }, {
t("\\hbar"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ns", wordTrig = false, snippetType = "autosnippet" }, {
t("\\unlhd"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "eqv", wordTrig = false, snippetType = "autosnippet" }, {
t("\\equiv"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "##", wordTrig = false, snippetType = "autosnippet" }, {
t("\\#"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ell", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
t("\\ell"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ot", wordTrig = false, snippetType = "autosnippet" }, {
t("\\otimes"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "op", wordTrig = false, snippetType = "autosnippet" }, {
t("\\oplus"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "not", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
t("\\not"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "par", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
t("\\partial"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "land", snippetType = "autosnippet" }, {
t("\\land"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "lor", snippetType = "autosnippet" }, {
t("\\lor"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "\\tri", snippetType = "autosnippet" }, {
t("\\triangle"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "emp", snippetType = "autosnippet", priority = 2000 }, {
t("\\emptyset"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "po", snippetType = "autosnippet" }, {
t("\\propto"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "neg", snippetType = "autosnippet" }, {
t("\\neg"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "nabla", snippetType = "autosnippet" }, {
t("\\nabla"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "cong", snippetType = "autosnippet" }, {
t("\\cong"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ii", snippetType = "autosnippet" }, {
t("\\int"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "oii", snippetType = "autosnippet", priority = 2000 }, {
t("\\oint"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "rr", snippetType = "autosnippet" }, {
t("\\rangle"),
}, { condition = tex.in_mathzone_md }),
s({ trig = "ll", snippetType = "autosnippet" }, {
t("\\langle"),
}, { condition = tex.in_mathzone_md }),
s(
{ trig = "b|", wordTrig = false, snippetType = "autosnippet" },
fmta(
[[
\Big|_{<>}
]],
{ i(1) }
),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "jk", wordTrig = false, snippetType = "autosnippet" },
fmta(
[[
_{<>}
]],
{ i(1) }
),
{ condition = tex.in_mathzone_md }
),
s(
{ trig = "kj", wordTrig = false, snippetType = "autosnippet" },
fmta(
[[
^{<>}
]],
{ i(1) }
),
{ condition = tex.in_mathzone_md }
),
}

View File

@@ -0,0 +1,106 @@
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 = "ss", snippetType = "autosnippet", priority = 4000 }, {
-- t("\\ss"),
-- }, { condition = tex.in_mathzone }),
-- s({ trig = "pp", snippetType = "autosnippet", priority = 3000 }, {
-- t("\\pp"),
-- }, { condition = tex.in_mathzone }),
-- s({ trig = "dd", snippetType = "autosnippet", priority = 3000 }, {
-- t("\\dd"),
-- }, { condition = tex.in_mathzone }),
-- s({ trig = "ff", snippetType = "autosnippet", priority = 3000 }, {
-- t("\\ff"),
-- }, { condition = tex.in_mathzone }),
s({ trig = "\\psii", snippetType = "autosnippet", priority = 3000 }, {
t("\\psi_i"),
}, { condition = tex.in_mathzone }),
s(
{ trig = "pt", snippetType = "autosnippet" },
fmta("[<>pt]", {
i(1),
}),
{ condition = tex.in_text }
),
s(
{ trig = "pt", snippetType = "autosnippet" },
fmta("\\quad\\text{[<>pt]}", {
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 = "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("\\overline{<>}", {
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

@@ -1,41 +1,137 @@
local ls = require("luasnip")
local c = ls.choice_node
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 c = ls.choice_node
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local tex = require("util.latex")
local rep = require("luasnip.extras").rep
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
local line_begin = require("luasnip.extras.expand_conditions").line_begin
return {
s({ trig = "dps", snippetType = "autosnippet" }, {
t("\\displaystyle"),
}, { condition = tex.in_mathzone }),
s({ trig = "if", snippetType = "autosnippet" }, {
t("\\text{\\ if\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "stt", snippetType = "autosnippet" }, {
t("\\text{ s.t. }"),
}, { condition = tex.in_mathzone }),
s({ trig = "as", snippetType = "autosnippet" }, {
t("\\text{\\ as\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "or", snippetType = "autosnippet" }, { t("\\text{\\ or\\ }") }, { condition = tex.in_mathzone }),
s({ trig = "otherwise", snippetType = "autosnippet" }, {
t("\\text{\\ otherwise\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "then", snippetType = "autosnippet" }, {
t("\\text{\\ then\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "since", snippetType = "autosnippet" }, {
t("\\text{\\ since\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "by", snippetType = "autosnippet" }, {
t("\\text{\\ by\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "and", snippetType = "autosnippet" }, {
t("\\text{\\ and\\ }"),
}, { condition = tex.in_mathzone }),
s({ trig = "qd", snippetType = "autosnippet" }, {
t("\\quad"),
}, { condition = tex.in_mathzone }),
s(
"link",
fmta("[<>](<>)", { i(1), f(function(_, snip)
return snip.env.TM_SELECTED_TEXT[1] or {}
end, {}) })
{ trig = "setc", snippetType = "autosnippet" },
fmta("\\setcounter{<>}{<>}", {
c(1, { t("exercise"), t("theorem") }),
i(2),
}),
{ condition = tex.in_text }
),
s({ trig = ";b", snippetType = "autosnippet" }, fmta("**<>**", i(1))),
s({ trig = ";t", snippetType = "autosnippet" }, fmta("*<>*", i(1))),
s({ trig = "xx", snippetType = "autosnippet" }, fmta("$\\times$", {})),
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 = "thmm", snippetType = "autosnippet" }, {
t("theorem"),
}, { condition = tex.in_text }),
s({ trig = "Thmm", 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 = "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 = "homeo" }, {
t("homeomorphism"),
}, { condition = tex.in_text }),
s({ trig = "homeo" }, {
t("homeomorphic"),
}, { condition = tex.in_text }),
s({ trig = "homo" }, {
t("homomorphism"),
}, { condition = tex.in_text }),
s({ trig = "homo" }, {
t("homomorphic"),
}, { condition = tex.in_text }),
s({ trig = "si ", snippetType = "autosnippet" }, {
t("is "),
}, { condition = tex.in_text }),
s({ trig = "=>", snippetType = "autosnippet" }, {
t("$\\implies$"),
}, { condition = tex.in_text }),
s({ trig = "<=", snippetType = "autosnippet" }, {
t("$\\impliedby$"),
}, { condition = tex.in_text }),
s(
{ trig = ";c", snippetType = "autosnippet" },
{ trig = "(%a)ii", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
fmta("$<>$", {
f(function(_, snip)
return snip.captures[1]
end),
}),
{ condition = tex.in_text }
),
s(
{
trig = "#(%d)",
regTrig = true,
wordTrig = false,
snippetType = "autosnippet",
},
fmta(
[[
```<>
<>
```
]],
{ i(1), i(0) }
)
"<> ",
{ f(function(_, snip)
local n = tonumber(snip.captures[1])
return string.rep("#", n)
end) }
),
{ condition = tex.in_text }
),
}