From 46c470d1f7dcb7784bf0c61578b15efc09ca1d40 Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Sun, 21 Sep 2025 20:43:38 +1000 Subject: [PATCH] Update --- .DS_Store | Bin 0 -> 6148 bytes LuaSnip/all.lua | 1 - LuaSnip/lua.lua | 19 +- LuaSnip/markdown/completion.lua | 300 ++++++++++++ LuaSnip/markdown/{math.lua => derivative.lua} | 24 +- LuaSnip/markdown/env.lua | 138 ++++++ LuaSnip/markdown/font.lua | 104 ++++ LuaSnip/markdown/greek-letter.lua | 172 +++++++ LuaSnip/markdown/math-commands.lua | 447 ++++++++++++++++++ LuaSnip/markdown/matrix.lua | 199 ++++++++ LuaSnip/markdown/physics2.lua | 119 +++++ LuaSnip/markdown/symbol-short.lua | 285 +++++++++++ LuaSnip/markdown/temporary.lua | 106 +++++ LuaSnip/markdown/text.lua | 148 +++++- LuaSnip/python/jupyter.lua | 42 ++ LuaSnip/python/manim.lua | 13 + LuaSnip/tex/template.lua | 151 ++++++ LuaSnip/typst/algo.lua | 139 ++++++ LuaSnip/typst/completion.lua | 305 ++++++++++++ LuaSnip/typst/derivative.lua | 58 +++ LuaSnip/typst/env.lua | 437 +++++++++++++++++ LuaSnip/typst/font.lua | 140 ++++++ LuaSnip/typst/greek-letter.lua | 172 +++++++ LuaSnip/typst/math-commands.lua | 262 ++++++++++ LuaSnip/typst/matrix.lua | 133 ++++++ LuaSnip/typst/physics.lua | 305 ++++++++++++ LuaSnip/typst/physics2.lua | 67 +++ LuaSnip/typst/py.lua | 297 ++++++++++++ LuaSnip/typst/symbol-short.lua | 240 ++++++++++ LuaSnip/typst/tikz.lua | 178 +++++++ after/ftplugin/tex.lua | 4 + lazy-lock.json | 111 ++--- lazyvim.json | 6 +- lua/config/autocmds.lua | 8 + lua/config/options.lua | 5 +- lua/plugins/coderunner.lua | 1 + lua/plugins/default/copilot.lua | 26 +- lua/plugins/default/lspconfig.lua | 2 + lua/plugins/default/tree-sitter.lua | 59 --- lua/plugins/default/treesitter.lua | 46 +- lua/plugins/lang/latex.lua | 2 +- lua/plugins/lang/typst.lua | 16 + lua/plugins/mason-workaround.lua | 4 +- lua/plugins/ui/colorscheme.lua | 15 +- lua/util/latex.lua | 66 ++- queries/latex/highlights.scm | 5 + spell/en.utf-8.add | 301 ++++++++++++ spell/en.utf-8.add.spl | Bin 0 -> 3026 bytes spell/nl.utf-8.add | 1 + spell/nl.utf-8.add.spl | Bin 0 -> 33 bytes 50 files changed, 5465 insertions(+), 214 deletions(-) create mode 100644 .DS_Store create mode 100644 LuaSnip/markdown/completion.lua rename LuaSnip/markdown/{math.lua => derivative.lua} (51%) create mode 100644 LuaSnip/markdown/env.lua create mode 100644 LuaSnip/markdown/font.lua create mode 100644 LuaSnip/markdown/greek-letter.lua create mode 100644 LuaSnip/markdown/math-commands.lua create mode 100644 LuaSnip/markdown/matrix.lua create mode 100644 LuaSnip/markdown/physics2.lua create mode 100644 LuaSnip/markdown/symbol-short.lua create mode 100644 LuaSnip/markdown/temporary.lua create mode 100644 LuaSnip/python/jupyter.lua create mode 100644 LuaSnip/tex/template.lua create mode 100644 LuaSnip/typst/algo.lua create mode 100644 LuaSnip/typst/completion.lua create mode 100644 LuaSnip/typst/derivative.lua create mode 100644 LuaSnip/typst/env.lua create mode 100644 LuaSnip/typst/font.lua create mode 100644 LuaSnip/typst/greek-letter.lua create mode 100644 LuaSnip/typst/math-commands.lua create mode 100644 LuaSnip/typst/matrix.lua create mode 100644 LuaSnip/typst/physics.lua create mode 100644 LuaSnip/typst/physics2.lua create mode 100644 LuaSnip/typst/py.lua create mode 100644 LuaSnip/typst/symbol-short.lua create mode 100644 LuaSnip/typst/tikz.lua create mode 100644 after/ftplugin/tex.lua delete mode 100644 lua/plugins/default/tree-sitter.lua create mode 100644 lua/plugins/lang/typst.lua create mode 100644 queries/latex/highlights.scm create mode 100644 spell/en.utf-8.add create mode 100644 spell/en.utf-8.add.spl create mode 100644 spell/nl.utf-8.add create mode 100644 spell/nl.utf-8.add.spl diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..47947cbcfd3c22998752f68899b70a5e58776032 GIT binary patch literal 6148 zcmeHKy-EW?5T3aNa-u~_E4e2Sg0{jLPOz{L(pqQ|h{7e8!t~c$*!m3GSX&8#Z(!pa z*x2|2ezQ9!x1O<7kr~+i_U325yYIqnhKRU38+M4=L=vI3WacbSTSTNS30UzHAUyBZek9su0(@q0kzP_nv zRQazqwm) + <> + end + ]], + { i(1), i(0) } + ), + {} + ), s( "localreq", fmt('local {} = require("{}")', { @@ -21,13 +33,6 @@ return { i(1, "module"), }) ), - s( - { trig = "add", snippetType = "autosnippet" }, - fmta('["<>"] = "<>",', { - i(1), - i(2), - }) - ), ls.parser.parse_snippet("lm", "local M = {}\n\n$1 \n\nreturn M"), s( { trig = "csnip", snippetType = "autosnippet" }, diff --git a/LuaSnip/markdown/completion.lua b/LuaSnip/markdown/completion.lua new file mode 100644 index 0000000..12aebc5 --- /dev/null +++ b/LuaSnip/markdown/completion.lua @@ -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 } + ), +} diff --git a/LuaSnip/markdown/math.lua b/LuaSnip/markdown/derivative.lua similarity index 51% rename from LuaSnip/markdown/math.lua rename to LuaSnip/markdown/derivative.lua index 76ecaf0..ed33d7c 100644 --- a/LuaSnip/markdown/math.lua +++ b/LuaSnip/markdown/derivative.lua @@ -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 } + ), } diff --git a/LuaSnip/markdown/env.lua b/LuaSnip/markdown/env.lua new file mode 100644 index 0000000..c88f815 --- /dev/null +++ b/LuaSnip/markdown/env.lua @@ -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 } + ), +} diff --git a/LuaSnip/markdown/font.lua b/LuaSnip/markdown/font.lua new file mode 100644 index 0000000..4a985c3 --- /dev/null +++ b/LuaSnip/markdown/font.lua @@ -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 } + ), +} diff --git a/LuaSnip/markdown/greek-letter.lua b/LuaSnip/markdown/greek-letter.lua new file mode 100644 index 0000000..0de83d2 --- /dev/null +++ b/LuaSnip/markdown/greek-letter.lua @@ -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 }), +} diff --git a/LuaSnip/markdown/math-commands.lua b/LuaSnip/markdown/math-commands.lua new file mode 100644 index 0000000..fb55005 --- /dev/null +++ b/LuaSnip/markdown/math-commands.lua @@ -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 } + ), +} diff --git a/LuaSnip/markdown/matrix.lua b/LuaSnip/markdown/matrix.lua new file mode 100644 index 0000000..e3d8b11 --- /dev/null +++ b/LuaSnip/markdown/matrix.lua @@ -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 } + ), +} diff --git a/LuaSnip/markdown/physics2.lua b/LuaSnip/markdown/physics2.lua new file mode 100644 index 0000000..9f27849 --- /dev/null +++ b/LuaSnip/markdown/physics2.lua @@ -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 }), +} diff --git a/LuaSnip/markdown/symbol-short.lua b/LuaSnip/markdown/symbol-short.lua new file mode 100644 index 0000000..cf62640 --- /dev/null +++ b/LuaSnip/markdown/symbol-short.lua @@ -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 } + ), +} diff --git a/LuaSnip/markdown/temporary.lua b/LuaSnip/markdown/temporary.lua new file mode 100644 index 0000000..b686dd2 --- /dev/null +++ b/LuaSnip/markdown/temporary.lua @@ -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 }), +} diff --git a/LuaSnip/markdown/text.lua b/LuaSnip/markdown/text.lua index c574c74..0e72d84 100644 --- a/LuaSnip/markdown/text.lua +++ b/LuaSnip/markdown/text.lua @@ -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 } ), } diff --git a/LuaSnip/python/jupyter.lua b/LuaSnip/python/jupyter.lua new file mode 100644 index 0000000..3744a2d --- /dev/null +++ b/LuaSnip/python/jupyter.lua @@ -0,0 +1,42 @@ +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 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 +return { + s( + { trig = "bc", wordTrig = false, snippetType = "autosnippet" }, + fmta( + [[ + # %% + <> + ]], + { + i(0), + } + ), + { condition = line_begin } + ), + s( + { trig = "bm", wordTrig = false, snippetType = "autosnippet" }, + fmta( + [[ + # %% [md] + """ + <> + """ + ]], + { + i(0), + } + ), + { condition = line_begin } + ), +} diff --git a/LuaSnip/python/manim.lua b/LuaSnip/python/manim.lua index d72a971..642e616 100644 --- a/LuaSnip/python/manim.lua +++ b/LuaSnip/python/manim.lua @@ -10,6 +10,19 @@ local fmt = require("luasnip.extras.fmt").fmt local fmta = require("luasnip.extras.fmt").fmta local rep = require("luasnip.extras").rep return { + s( + { trig = "voo", wordTrig = false, snippetType = "autosnippet" }, + fmta( + [[ + with self.voiceover(text="<>") as tracker: + <> + ]], + { + i(1), + i(0), + } + ) + ), s( { trig = "voo", wordTrig = false, snippetType = "autosnippet" }, fmta( diff --git a/LuaSnip/tex/template.lua b/LuaSnip/tex/template.lua new file mode 100644 index 0000000..baa0bcd --- /dev/null +++ b/LuaSnip/tex/template.lua @@ -0,0 +1,151 @@ +local ls = require("luasnip") +local c = ls.choice_node +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_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 = "homework" }, + fmta( + [[ + \documentclass{article} + \newcommand{\Class}{<>} + \newcommand{\Title}{Homework <>} + \author{Hanyu Yan} + \input{/home/fireond/Documents/Latex/preamble.tex} + \input{/home/fireond/Documents/Latex/Sample_Homework.tex} + \begin{document} + \maketitle \thispagestyle{empty} + + <> + + \end{document} + ]], + { + c(1, { + t("Quantum Computation + X"), + t("Advanced Atomic Physics"), + t("Electronics for Experimental Physics"), + }), + i(2, "number"), + i(0), + } + ), + { condition = tex.in_text * line_begin } + ), + s( + { trig = "note" }, + fmta( + [[ +\documentclass[12pt]{article} +\input{/home/fireond/Documents/Latex/preamble.tex} +\begin{document} +\title{<>} +\author{Fireond} +\date{\today} +\maketitle +\tableofcontents +\newpage + +<> + +\end{document} + ]], + { + i(1, "title"), + 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{/home/fireond/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{/home/fireond/Documents/Latex/Package_elegantbook.tex} + \input{/home/fireond/Documents/Latex/Sample_Homework.tex} + \renewcommand{\arraystretch}{1.3} + \begin{document} + \maketitle \thispagestyle{empty} + + <> + + \end{document} + ]], + { + c(1, { + t("量子信息实验报告"), + }), + i(2), + i(0), + } + ), + { condition = tex.in_text * line_begin } + ), + s( + { trig = "cpho" }, + fmta( + [[ +%! TEX program = xelatex +\documentclass[10pt]{article} +\input{/home/fireond/Documents/Latex/preamble.tex} +\usepackage{ctex} +\begin{document} + +<> +\begin{enumerate}[1.] + \item +\end{enumerate} + +\end{document} + ]], + { i(0) } + ), + { condition = tex.in_text * line_begin } + ), +} diff --git a/LuaSnip/typst/algo.lua b/LuaSnip/typst/algo.lua new file mode 100644 index 0000000..36ba1cc --- /dev/null +++ b/LuaSnip/typst/algo.lua @@ -0,0 +1,139 @@ +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 } + ), +} diff --git a/LuaSnip/typst/completion.lua b/LuaSnip/typst/completion.lua new file mode 100644 index 0000000..caa4cce --- /dev/null +++ b/LuaSnip/typst/completion.lua @@ -0,0 +1,305 @@ +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 } + -- ), + 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 } + ), + 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 } + ), + 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 } + ), + 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 } + ), + 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(") <>", { + f(function(_, snip) + return snip.captures[1] + end), + }) + ), + s( + { trig = "](%a)", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("] <>", { + f(function(_, snip) + return snip.captures[1] + end), + }) + ), + s( + { trig = "lim", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("lim_(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "lsup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("limsup_(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "linf", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("liminf_(<>)", { + i(1), + }), + { 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("} ") }), + }), + { condition = tex.in_mathzone } + ), + 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 } + ), + s( + { trig = "bot", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("times.big.circle(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "bcap", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("inter.big_(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "bcup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("union.big_(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "blor", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("bigvee_(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "band", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("bigwedge_(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "bscap", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("bigsqcap_(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "bscup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("bigsqcup_(<>)^(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "int", regTrig = true, wordTrig = false, snippetType = "autosnippet" }, + fmta("integral_(<>)^(<>) <> dif <>", { + i(1), + i(2), + i(3), + i(4), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "oint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("ointegral_(<>)^(<>) <> dif <>", { + i(1), + i(2), + i(3), + i(4), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "2int", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("integral_(<>)^(<>)integral_(<>)^(<>) <> dif <>dif <>", { + i(1), + i(2), + i(3), + i(4), + i(5), + i(6), + i(7), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "iint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("iintegral_(<>)^(<>) <> dif <>", { + i(1, "-infty"), + i(2, "infty"), + i(3), + i(4), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "lint", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("integral_(<>) <> dif <>", { + i(1, "infty"), + i(2), + i(3), + }), + { condition = tex.in_mathzone } + ), +} diff --git a/LuaSnip/typst/derivative.lua b/LuaSnip/typst/derivative.lua new file mode 100644 index 0000000..7f0011e --- /dev/null +++ b/LuaSnip/typst/derivative.lua @@ -0,0 +1,58 @@ +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 } + ), +} diff --git a/LuaSnip/typst/env.lua b/LuaSnip/typst/env.lua new file mode 100644 index 0000000..1a41384 --- /dev/null +++ b/LuaSnip/typst/env.lua @@ -0,0 +1,437 @@ +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 = "mk", snippetType = "autosnippet" }, + fmta( + [[ + $<>$ + ]], + { + i(1), + } + ), + { condition = tex.in_text } + ), + s( + { trig = "dm", snippetType = "autosnippet" }, + fmta( + [[ + $ + <> + $ + ]], + { + i(1), + } + ), + { condition = tex.in_text } + ), + s( + { trig = "(%d+)bp", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta( + [[ + \begin{homeworkProblem}[Problem <>.] + <> + \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), + i(0), + } + ), + { condition = line_begin } + ), + s( + { trig = "bff", snippetType = "autosnippet" }, + fmta( + [[ + \begin{proof} + <> + \end{proof} + ]], + { + i(0), + } + ), + { condition = line_begin * tex.in_text } + ), + s( + { trig = "bep", snippetType = "autosnippet" }, + fmta( + [[ + \begin{problem}[<>] + <> + \end{problem} + ]], + { + i(1), + i(0), + } + ), + { condition = line_begin } + ), + s( + { trig = "bex", snippetType = "autosnippet" }, + fmta( + [[ + \begin{exercise}[<>] + <> + \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 } + ), +} diff --git a/LuaSnip/typst/font.lua b/LuaSnip/typst/font.lua new file mode 100644 index 0000000..792c626 --- /dev/null +++ b/LuaSnip/typst/font.lua @@ -0,0 +1,140 @@ +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), + }) + ), +} diff --git a/LuaSnip/typst/greek-letter.lua b/LuaSnip/typst/greek-letter.lua new file mode 100644 index 0000000..ca6939b --- /dev/null +++ b/LuaSnip/typst/greek-letter.lua @@ -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 }), + s({ trig = "Alp", snippetType = "autosnippet", wordTrig = false }, { + t("Alpha"), + }, { condition = tex.in_mathzone }), + s({ trig = ";a", snippetType = "autosnippet", wordTrig = false }, { + t("alpha"), + }, { condition = tex.in_mathzone }), + s({ trig = "beta", snippetType = "autosnippet", wordTrig = false }, { + t("beta"), + }, { condition = tex.in_mathzone }), + s({ trig = ";b", snippetType = "autosnippet", wordTrig = false }, { + t("beta"), + }, { condition = tex.in_mathzone }), + s({ trig = "Beta", snippetType = "autosnippet", wordTrig = false }, { + t("Beta"), + }, { condition = tex.in_mathzone }), + s({ trig = "gam", snippetType = "autosnippet", wordTrig = false }, { + t("gamma"), + }, { condition = tex.in_mathzone }), + s({ trig = ";c", snippetType = "autosnippet", wordTrig = false }, { + t("gamma"), + }, { condition = tex.in_mathzone }), + s({ trig = "Gam", snippetType = "autosnippet", wordTrig = false }, { + t("Gamma"), + }, { condition = tex.in_mathzone }), + s({ trig = "del", snippetType = "autosnippet", wordTrig = false }, { + t("delta"), + }, { condition = tex.in_mathzone }), + s({ trig = ";d", snippetType = "autosnippet", wordTrig = false }, { + t("delta"), + }, { condition = tex.in_mathzone }), + s({ trig = "Del", snippetType = "autosnippet", wordTrig = false }, { + t("Delta"), + }, { condition = tex.in_mathzone }), + s({ trig = "eps", snippetType = "autosnippet", wordTrig = false }, { + t("epsilon"), + }, { condition = tex.in_mathzone }), + s({ trig = "vps", snippetType = "autosnippet", wordTrig = false }, { + t("varepsilon"), + }, { condition = tex.in_mathzone }), + s({ trig = "Eps", snippetType = "autosnippet", wordTrig = false }, { + t("Epsilon"), + }, { condition = tex.in_mathzone }), + s({ trig = "zeta", snippetType = "autosnippet", wordTrig = false }, { + t("zeta"), + }, { condition = tex.in_mathzone }), + s({ trig = "Zeta", snippetType = "autosnippet", wordTrig = false }, { + t("Zeta"), + }, { condition = tex.in_mathzone }), + s({ trig = "eta", snippetType = "autosnippet", wordTrig = false }, { + t("eta"), + }, { condition = tex.in_mathzone }), + s({ trig = "Eta", snippetType = "autosnippet", wordTrig = false }, { + t("Eta"), + }, { condition = tex.in_mathzone }), + s({ trig = "the", snippetType = "autosnippet", wordTrig = false }, { + t("theta"), + }, { condition = tex.in_mathzone }), + s({ trig = "The", snippetType = "autosnippet", wordTrig = false }, { + t("Theta"), + }, { condition = tex.in_mathzone }), + s({ trig = "iot", snippetType = "autosnippet", wordTrig = false }, { + t("iota"), + }, { condition = tex.in_mathzone }), + s({ trig = "Iot", snippetType = "autosnippet", wordTrig = false }, { + t("Iota"), + }, { condition = tex.in_mathzone }), + s({ trig = "kap", snippetType = "autosnippet", wordTrig = false }, { + t("kappa"), + }, { condition = tex.in_mathzone }), + s({ trig = "Kap", snippetType = "autosnippet", wordTrig = false }, { + t("Kappa"), + }, { condition = tex.in_mathzone }), + s({ trig = "lam", snippetType = "autosnippet", wordTrig = false }, { + t("lambda"), + }, { condition = tex.in_mathzone }), + s({ trig = "Lam", snippetType = "autosnippet", wordTrig = false }, { + t("Lambda"), + }, { condition = tex.in_mathzone }), + s({ trig = "mu", snippetType = "autosnippet", wordTrig = false }, { + t("mu"), + }, { condition = tex.in_mathzone }), + s({ trig = "Mu", snippetType = "autosnippet", wordTrig = false }, { + t("Mu"), + }, { condition = tex.in_mathzone }), + s({ trig = "nu", snippetType = "autosnippet", wordTrig = false }, { + t("nu"), + }, { condition = tex.in_mathzone }), + s({ trig = "Nu", snippetType = "autosnippet", wordTrig = false }, { + t("Nu"), + }, { condition = tex.in_mathzone }), + -- s({ trig = "xi", snippetType = "autosnippet", wordTrig = false }, { + -- t("xi"), + -- }, { condition = tex.in_mathzone }), + -- s({ trig = "Xi", snippetType = "autosnippet", wordTrig = false }, { + -- t("Xi"), + -- }, { condition = tex.in_mathzone }), + s({ trig = "omi", snippetType = "autosnippet", wordTrig = false }, { + t("omicron"), + }, { condition = tex.in_mathzone }), + s({ trig = "pi", snippetType = "autosnippet", wordTrig = false }, { + t("pi"), + }, { condition = tex.in_mathzone }), + s({ trig = "pii", snippetType = "autosnippet", wordTrig = false, priority = 2000 }, { + t("p_i"), + }, { condition = tex.in_mathzone }), + s({ trig = "Pi", snippetType = "autosnippet", wordTrig = false }, { + t("Pi"), + }, { condition = tex.in_mathzone }), + s({ trig = "rho", snippetType = "autosnippet", wordTrig = false }, { + t("rho"), + }, { condition = tex.in_mathzone }), + s({ trig = "Rho", snippetType = "autosnippet", wordTrig = false }, { + t("Rho"), + }, { condition = tex.in_mathzone }), + s({ trig = "sig", snippetType = "autosnippet", wordTrig = false }, { + t("sigma"), + }, { condition = tex.in_mathzone }), + s({ trig = "Sig", snippetType = "autosnippet", wordTrig = false }, { + t("Sigma"), + }, { condition = tex.in_mathzone }), + s({ trig = "tau", snippetType = "autosnippet", wordTrig = false }, { + t("tau"), + }, { condition = tex.in_mathzone }), + s({ trig = "Tau", snippetType = "autosnippet", wordTrig = false }, { + t("Tau"), + }, { condition = tex.in_mathzone }), + s({ trig = "ups", snippetType = "autosnippet", wordTrig = false }, { + t("ups"), + }, { condition = tex.in_mathzone }), + s({ trig = "Ups", snippetType = "autosnippet", wordTrig = false }, { + t("Ups"), + }, { condition = tex.in_mathzone }), + s({ trig = "phi", snippetType = "autosnippet", wordTrig = false }, { + t("phi"), + }, { condition = tex.in_mathzone }), + s({ trig = "Phi", snippetType = "autosnippet", wordTrig = false }, { + t("Phi"), + }, { condition = tex.in_mathzone }), + s({ trig = "vhi", snippetType = "autosnippet", wordTrig = false }, { + t("varphi"), + }, { condition = tex.in_mathzone }), + s({ trig = "Vhi", snippetType = "autosnippet", wordTrig = false }, { + t("Varphi"), + }, { condition = tex.in_mathzone }), + s({ trig = "chi", snippetType = "autosnippet", wordTrig = false }, { + t("chi"), + }, { condition = tex.in_mathzone }), + s({ trig = "Chi", snippetType = "autosnippet", wordTrig = false }, { + t("Chi"), + }, { condition = tex.in_mathzone }), + s({ trig = "psi", snippetType = "autosnippet", wordTrig = false }, { + t("psi"), + }, { condition = tex.in_mathzone }), + s({ trig = "Psi", snippetType = "autosnippet", wordTrig = false }, { + t("Psi"), + }, { condition = tex.in_mathzone }), + s({ trig = "ome", snippetType = "autosnippet", wordTrig = false }, { + t("omega"), + }, { condition = tex.in_mathzone }), + s({ trig = "Ome", snippetType = "autosnippet", wordTrig = false }, { + t("Omega"), + }, { condition = tex.in_mathzone }), +} diff --git a/LuaSnip/typst/math-commands.lua b/LuaSnip/typst/math-commands.lua new file mode 100644 index 0000000..038cdef --- /dev/null +++ b/LuaSnip/typst/math-commands.lua @@ -0,0 +1,262 @@ +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 = "atan", snippetType = "autosnippet" }, { + t("arctan"), + }, { condition = tex.in_mathzone }), + s({ trig = "acot", snippetType = "autosnippet" }, { + t("arccot"), + }, { condition = tex.in_mathzone }), + s({ trig = "acsc", snippetType = "autosnippet" }, { + t("arccsc"), + }, { condition = tex.in_mathzone }), + s({ trig = "asec", snippetType = "autosnippet" }, { + t("arcsec"), + }, { condition = tex.in_mathzone }), + s({ trig = "lap", snippetType = "autosnippet" }, { + t("laplace"), + }, { condition = tex.in_mathzone }), + s( + { trig = "bar", snippetType = "autosnippet" }, + fmta("overline(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "ob", snippetType = "autosnippet" }, + fmta("overbrace(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "td", snippetType = "autosnippet" }, + fmta("ttlde(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "dot", snippetType = "autosnippet" }, + fmta("dot(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "doo", snippetType = "autosnippet", priority = 2000 }, + fmta("dot.double(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "hat", snippetType = "autosnippet", priority = 2000 }, + fmta("hat(<>)", { + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "hat", snippetType = "autosnippet" }, + fmta("hat(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "vec", snippetType = "autosnippet", priority = 2000 }, + fmta("vec(<>)", { + d(1, get_visual), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = ";v", snippetType = "autosnippet" }, + fmta("vec(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "vec", snippetType = "autosnippet" }, + fmta("vec(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + -- s({ trig = "rr", snippetType = "autosnippet" }, fmta("ran", {}), { condition = tex.in_mathzone }), + -- s({ trig = "kk", snippetType = "autosnippet" }, fmta("ker", {}), { condition = tex.in_mathzone }), + s({ trig = "tr", snippetType = "autosnippet" }, fmta("tr", {}), { condition = tex.in_mathzone }), + s({ trig = "span", snippetType = "autosnippet" }, fmta("span", {}), { condition = tex.in_mathzone }), + s({ trig = "aut", snippetType = "autosnippet" }, fmta("Aut", {}), { condition = tex.in_mathzone }), + s({ trig = "gal", snippetType = "autosnippet" }, fmta("Gal", {}), { condition = tex.in_mathzone }), + s({ trig = "rank", snippetType = "autosnippet" }, fmta("rank", {}), { condition = tex.in_mathzone }), + 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( + { trig = "amin", snippetType = "autosnippet" }, + fmta("argmin_(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "amax", snippetType = "autosnippet" }, + fmta("argmax_(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s({ trig = "sup", snippetType = "autosnippet", priority = 2000 }, fmta("sup", {}), { condition = tex.in_mathzone }), + s({ trig = "inf", snippetType = "autosnippet", priority = 2000 }, fmta("inf", {}), { condition = tex.in_mathzone }), + s( + { trig = ";r", wordTrig = false, snippetType = "autosnippet" }, + fmta("frac(<>)(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = ";r", snippetType = "autosnippet", priority = 2000 }, + fmta("frac(<>)(<>)", { + d(1, get_visual), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "binom", snippetType = "autosnippet" }, + fmta("binom(<>)(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s({ trig = "dd", snippetType = "autosnippet" }, fmta("dif ", {}), { condition = tex.in_mathzone }), + s({ trig = "poly", snippetType = "autosnippet" }, fmta("poly", {}), { condition = tex.in_mathzone }), + s( + { trig = "sq", wordTrig = false, snippetType = "autosnippet" }, + fmta("sqrt(<>)", { i(1) }), + { condition = tex.in_mathzone } + ), + s( + { trig = "mod", wordTrig = false, snippetType = "autosnippet" }, + fmta("mod(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "nmod", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("nmod(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "pmod", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("pmod(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "sgn", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("sgn", {}), + { condition = tex.in_mathzone } + ), + s( + { trig = "SI", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("SI(<>)(<>)", { + i(1), + i(2), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "cond", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("cond(<>)", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "gcd", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("gcd", {}), + { condition = tex.in_mathzone } + ), + s( + { trig = "deg", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, + fmta("degree", {}), + { condition = tex.in_mathzone } + ), + s({ trig = "pr", wordTrig = false, snippetType = "autosnippet" }, fmta("Pr", {}), { condition = tex.in_mathzone }), + s({ trig = "Pii", snippetType = "autosnippet", priority = 2000 }, { + t("P_i"), + }, { condition = tex.in_mathzone }), + s({ trig = "bv", snippetType = "autosnippet", priority = 2000 }, { + t("biggvert"), + }, { condition = tex.in_mathzone }), + s( + { trig = "ub", snippetType = "autosnippet", priority = 2000 }, + fmta("underbrace(<>)", { i(1) }), + { condition = tex.in_mathzone } + ), + s( + { trig = "ob", snippetType = "autosnippet", priority = 2000 }, + fmta("overbrace(<>)", { i(1) }), + { condition = tex.in_mathzone } + ), + s( + { trig = "ring", snippetType = "autosnippet", priority = 2000 }, + fmta("mathring(<>)", { i(1) }), + { condition = tex.in_mathzone } + ), +} diff --git a/LuaSnip/typst/matrix.lua b/LuaSnip/typst/matrix.lua new file mode 100644 index 0000000..0dcc19c --- /dev/null +++ b/LuaSnip/typst/matrix.lua @@ -0,0 +1,133 @@ +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( + [[ + mat(delim: "[", <>) + ]], + { + i(0), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "Bmat", snippetType = "autosnippet" }, + fmta( + [[ + mat(delim: "{", <>) + ]], + { + i(0), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "pmat", snippetType = "autosnippet" }, + fmta( + [[ + mat(<>) + ]], + { + i(0), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "Vmat", snippetType = "autosnippet" }, + fmta( + [[ + mat(delim: "|", <>) + ]], + { + i(0), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "II3", snippetType = "autosnippet", priority = 2000 }, + fmta( + [[ + mat( + 1,,; + ,1,; + ,,1; + ) + ]], + {} + ), + { 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 } + ), +} diff --git a/LuaSnip/typst/physics.lua b/LuaSnip/typst/physics.lua new file mode 100644 index 0000000..bf7f6ff --- /dev/null +++ b/LuaSnip/typst/physics.lua @@ -0,0 +1,305 @@ +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 = "qb", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\qty(<>)", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "qb", snippetType = "autosnippet" }, + -- -- fmta("\\qty(<>)", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "qB", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\qty{<>}", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "qB", snippetType = "autosnippet" }, + -- -- fmta("\\qty{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "qp", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\qty[<>]", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "qp", snippetType = "autosnippet" }, + -- -- fmta("\\qty[<>]", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "mb", snippetType = "autosnippet" }, + -- -- fmta("\\mqty(<>)", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "mB", snippetType = "autosnippet" }, + -- -- fmta("\\mqty{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "mp", snippetType = "autosnippet" }, + -- -- fmta("\\mqty[<>]", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "im", snippetType = "autosnippet" }, + -- -- fmta("\\imat{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "xm", snippetType = "autosnippet" }, + -- -- fmta("\\xmat{<>}{<>}{<>}", { + -- -- i(1), + -- -- i(2), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "zm", snippetType = "autosnippet" }, + -- -- fmta("\\zmat{<>}{<>}", { + -- -- i(1), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "pmat", snippetType = "autosnippet" }, + -- -- fmta("\\pmat{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "dm", snippetType = "autosnippet" }, + -- -- fmta("\\dmat{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "adm", snippetType = "autosnippet" }, + -- -- fmta("\\admat{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "comm", snippetType = "autosnippet" }, + -- -- fmta("\\comm{<>}{<>}", { + -- -- i(1), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "acom", snippetType = "autosnippet" }, + -- -- fmta("\\acomm{<>}{<>}", { + -- -- i(1), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "ket", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\ket{<>}", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "ket", snippetType = "autosnippet" }, + -- -- fmta("\\ket{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "bra", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\bra{<>}", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "bra", snippetType = "autosnippet" }, + -- -- fmta("\\bra{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "norm", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\norm{<>}", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "norm", snippetType = "autosnippet" }, + -- -- fmta("\\norm{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "abs", snippetType = "autosnippet", priority = 2000 }, + -- -- fmta("\\abs{<>}", { + -- -- d(1, get_visual), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "abs", snippetType = "autosnippet" }, + -- -- fmta("\\abs*{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "vu", snippetType = "autosnippet" }, + -- -- fmta("\\vu{<>}", { + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "bk", snippetType = "autosnippet" }, + -- -- fmta("\\ip{<>}{<>}", { + -- -- i(1), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "kb", snippetType = "autosnippet" }, + -- -- fmta("\\op{<>}{<>}", { + -- -- i(1), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- s( + -- { trig = "ev", snippetType = "autosnippet" }, + -- fmta("\\ev{<>}", { + -- i(0), + -- }), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "mev", snippetType = "autosnippet" }, + -- fmta("\\ev{<>}{<>}", { + -- i(1), + -- i(0), + -- }), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "mel", snippetType = "autosnippet" }, + -- fmta("\\mel{<>}{<>}{<>}", { + -- i(1), + -- i(2), + -- i(0), + -- }), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "mdet", snippetType = "autosnippet" }, + -- fmta("\\mdet{<>}", { + -- i(0), + -- }), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "ord", wordTrig = false, snippetType = "autosnippet" }, + -- fmta("\\order{<>}", { + -- i(0), + -- }), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "qif", wordTrig = false, snippetType = "autosnippet" }, + -- fmta("\\qif", {}), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "qq", wordTrig = false, snippetType = "autosnippet" }, + -- fmta("\\qq{<>}", { + -- i(0), + -- }), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "qor", wordTrig = false, snippetType = "autosnippet" }, + -- fmta("\\qor", {}), + -- { condition = tex.in_mathzone } + -- ), + -- s( + -- { trig = "qif", wordTrig = false, snippetType = "autosnippet" }, + -- fmta("\\qif", {}), + -- { condition = tex.in_mathzone } + -- ), + -- -- s( + -- -- { trig = "dv", wordTrig = false, snippetType = "autosnippet" }, + -- -- fmta("\\dv[<>]{<>}{<>}", { + -- -- i(1), + -- -- i(2), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- -- s( + -- -- { trig = "pv", wordTrig = false, snippetType = "autosnippet" }, + -- -- fmta("\\pdv{<>}{<>}", { + -- -- i(1), + -- -- i(0), + -- -- }), + -- -- { condition = tex.in_mathzone } + -- -- ), + -- s({ trig = "tr", wordTrig = false, snippetType = "autosnippet" }, fmta("\\tr", {}), { condition = tex.in_mathzone }), +} diff --git a/LuaSnip/typst/physics2.lua b/LuaSnip/typst/physics2.lua new file mode 100644 index 0000000..78483ef --- /dev/null +++ b/LuaSnip/typst/physics2.lua @@ -0,0 +1,67 @@ +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("|<> angle.r", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s( + { trig = "ket", wordTrig = false, snippetType = "autosnippet", priority = 1000 }, + fmta("angle.r <>|", { + i(1), + }), + { condition = tex.in_mathzone } + ), + s({ trig = "ar", snippetType = "autosnippet" }, { + t("angle.r"), + }, { condition = tex.in_mathzone }), + s({ trig = "al", snippetType = "autosnippet" }, { + t("angle.l"), + }, { 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 } + ), +} diff --git a/LuaSnip/typst/py.lua b/LuaSnip/typst/py.lua new file mode 100644 index 0000000..0cd1ad4 --- /dev/null +++ b/LuaSnip/typst/py.lua @@ -0,0 +1,297 @@ +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) + ), +} diff --git a/LuaSnip/typst/symbol-short.lua b/LuaSnip/typst/symbol-short.lua new file mode 100644 index 0000000..477fd6f --- /dev/null +++ b/LuaSnip/typst/symbol-short.lua @@ -0,0 +1,240 @@ +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 }), + s({ trig = "c.", wordTrig = false, snippetType = "autosnippet" }, { + t("dot"), + }, { condition = tex.in_mathzone }), + s({ trig = "cdot.", wordTrig = false, snippetType = "autosnippet" }, { + t("cdots"), + }, { condition = tex.in_mathzone }), + s({ trig = "v.", wordTrig = false, snippetType = "autosnippet" }, { + t("dots.v"), + }, { condition = tex.in_mathzone }), + s({ trig = "iff", wordTrig = false, snippetType = "autosnippet" }, { + t("iff"), + }, { condition = tex.in_mathzone }), + s({ trig = "notin", wordTrig = false, snippetType = "autosnippet" }, { + t("in.not"), + }, { condition = tex.in_mathzone }), + s({ trig = "aa", wordTrig = false, snippetType = "autosnippet" }, { + t("forall"), + }, { condition = tex.in_mathzone }), + 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 }), + s({ trig = "~~", wordTrig = false, snippetType = "autosnippet" }, { + t("sim"), + }, { condition = tex.in_mathzone }), + s({ trig = ">>", wordTrig = false, snippetType = "autosnippet" }, { + t("gg"), + }, { condition = tex.in_mathzone }), + s({ trig = "<<", wordTrig = false, snippetType = "autosnippet" }, { + t("ll"), + }, { condition = tex.in_mathzone }), + s({ trig = "cp", wordTrig = false, snippetType = "autosnippet" }, { + t("cp"), + }, { condition = tex.in_mathzone }), + s({ trig = "get", wordTrig = false, snippetType = "autosnippet" }, { + t("gets"), + }, { condition = tex.in_mathzone }), + s({ trig = "to", wordTrig = false, snippetType = "autosnippet" }, { + t("to"), + }, { condition = tex.in_mathzone }), + 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 }), + s({ trig = "nmid", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, { + t("nmid"), + }, { condition = tex.in_mathzone }), + s({ trig = "sr", wordTrig = false, snippetType = "autosnippet" }, { + t("^2"), + }, { condition = tex.in_mathzone }), + s({ trig = "cb", wordTrig = false, snippetType = "autosnippet" }, { + t("^3"), + }, { condition = tex.in_mathzone }), + s({ trig = "inv", wordTrig = false, snippetType = "autosnippet" }, { + 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"), + }, { condition = tex.in_mathzone }), + s({ trig = "-+", wordTrig = false, snippetType = "autosnippet" }, { + t("mp"), + }, { condition = tex.in_mathzone }), + s({ trig = "rhs", wordTrig = false, snippetType = "autosnippet" }, { + t("mathrm{R.H.S}"), + }, { condition = tex.in_mathzone }), + s({ trig = "lhs", wordTrig = false, snippetType = "autosnippet" }, { + t("mathrm{L.H.S}"), + }, { condition = tex.in_mathzone }), + s({ trig = "cap", wordTrig = false, snippetType = "autosnippet" }, { + t("inter"), + }, { condition = tex.in_mathzone }), + s({ trig = "cup", wordTrig = false, snippetType = "autosnippet" }, { + t("union"), + }, { condition = tex.in_mathzone }), + s({ trig = "sub", wordTrig = false, snippetType = "autosnippet" }, { + t("subset.eq"), + }, { condition = tex.in_mathzone }), + s({ trig = "suq", wordTrig = false, snippetType = "autosnippet" }, { + t("supset.eq"), + }, { condition = tex.in_mathzone }), + s({ trig = "tp", wordTrig = false, snippetType = "autosnippet" }, { + t("^top"), + }, { condition = tex.in_mathzone }), + s({ trig = "dr", wordTrig = false, snippetType = "autosnippet" }, { + t("^dagger"), + }, { condition = tex.in_mathzone }), + s({ trig = "perp", wordTrig = false, snippetType = "autosnippet" }, { + t("perp"), + }, { condition = tex.in_mathzone }), + s({ trig = "ss", wordTrig = false, snippetType = "autosnippet" }, { + t("star"), + }, { condition = tex.in_mathzone }), + 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 }), + s({ trig = "up", wordTrig = false, snippetType = "autosnippet" }, { + t("uparrow"), + }, { condition = tex.in_mathzone }), + s({ trig = "down", wordTrig = false, snippetType = "autosnippet" }, { + t("downarrow"), + }, { condition = tex.in_mathzone }), + s({ trig = "cir", wordTrig = false, snippetType = "autosnippet" }, { + t("circ"), + }, { condition = tex.in_mathzone }), + s({ trig = "iso", wordTrig = false, snippetType = "autosnippet" }, { + t("cong"), + }, { condition = tex.in_mathzone }), + s({ trig = "ihbar", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, { + t("ihbar"), + }, { condition = tex.in_mathzone }), + s({ trig = "hbar", wordTrig = false, snippetType = "autosnippet", priority = 1500 }, { + t("hbar"), + }, { condition = tex.in_mathzone }), + s({ trig = "ns", wordTrig = false, snippetType = "autosnippet" }, { + t("unlhd"), + }, { condition = tex.in_mathzone }), + s({ trig = "eqv", wordTrig = false, snippetType = "autosnippet" }, { + t("equiv"), + }, { condition = tex.in_mathzone }), + s({ trig = "##", wordTrig = false, snippetType = "autosnippet" }, { + t("#"), + }, { condition = tex.in_mathzone }), + s({ trig = "ell", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, { + t("ell"), + }, { condition = tex.in_mathzone }), + s({ trig = "ot", wordTrig = false, snippetType = "autosnippet" }, { + t("times.circle"), + }, { condition = tex.in_mathzone }), + s({ trig = "op", wordTrig = false, snippetType = "autosnippet" }, { + t("xor"), + }, { condition = tex.in_mathzone }), + s({ trig = "par", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, { + t("diff"), + }, { condition = tex.in_mathzone }), + s({ trig = "land", snippetType = "autosnippet" }, { + t("land"), + }, { condition = tex.in_mathzone }), + s({ trig = "lor", snippetType = "autosnippet" }, { + t("lor"), + }, { condition = tex.in_mathzone }), + s({ trig = "tri", snippetType = "autosnippet" }, { + t("triangle"), + }, { condition = tex.in_mathzone }), + s({ trig = "emp", snippetType = "autosnippet", priority = 2000 }, { + t("emptyset"), + }, { condition = tex.in_mathzone }), + s({ trig = "po", snippetType = "autosnippet" }, { + t("prop"), + }, { condition = tex.in_mathzone }), + s({ trig = "cong", snippetType = "autosnippet" }, { + t("cong"), + }, { condition = tex.in_mathzone }), + s( + { trig = "b|", wordTrig = false, snippetType = "autosnippet" }, + fmta( + [[ + \Big|_(<>) + ]], + { i(1) } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "jk", wordTrig = false, snippetType = "autosnippet" }, + fmta( + [[ + _(<>) + ]], + { i(1) } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "kj", wordTrig = false, snippetType = "autosnippet" }, + fmta( + [[ + ^(<>) + ]], + { i(1) } + ), + { condition = tex.in_mathzone } + ), +} diff --git a/LuaSnip/typst/tikz.lua b/LuaSnip/typst/tikz.lua new file mode 100644 index 0000000..2fedabe --- /dev/null +++ b/LuaSnip/typst/tikz.lua @@ -0,0 +1,178 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local f = ls.function_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 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 = "vsp", snippetType = "autosnippet" }, { + t("\\vspace{\\baselineskip}"), + }), + s( + { trig = "bti", snippetType = "autosnippet" }, + fmta( + [[ + \begin{tikzpicture}<> + <> + \end{tikzpicture} + ]], + { + c(1, { t("[overlay,remember picture,>=stealth,nodes={align=left,inner ysep=1pt},<-]"), t("") }), + i(0), + } + ), + { condition = line_begin } + ), + s( + { trig = "tm", snippetType = "autosnippet" }, + fmta( + [[ + \tikzmarknode{<>}{<>} + ]], + { + i(1, "markname"), + i(0), + } + ), + { condition = tex.in_tikz } + ), + s( + { trig = "tm", snippetType = "autosnippet", priority = 2000 }, + fmta( + [[ + \tikzmarknode{<>}{<>} + ]], + { + i(1, "markname"), + d(2, get_visual), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "lu", snippetType = "autosnippet", dscr = "Left up annotate" }, + fmta( + [[ + \path (<>.north) ++ (0,1em) node[anchor=south east,color=<>!67] (<>_node){<>}; + \draw [color=<>!57](<>.north) |- ([xshift=-0.3ex,color=<>]<>_node.south west); + ]], + { + i(1, "markname"), + i(2, "color"), + rep(1), + i(3, "text"), + rep(2), + rep(1), + rep(2), + rep(1), + } + ), + { condition = tex.in_tikz } + ), + s( + { trig = "rd", snippetType = "autosnippet", dscr = "Right down annotate" }, + fmta( + [[ + \path (<>.south) ++ (0,-0.8em) node[anchor=north west,color=<>!67] (<>_node){<>}; + \draw [color=<>!57](<>.south) |- ([xshift=-0.3ex,color=<>]<>_node.south east); + ]], + { + i(1, "markname"), + i(2, "color"), + rep(1), + i(3, "text"), + rep(2), + rep(1), + rep(2), + rep(1), + } + ), + { condition = tex.in_tikz } + ), + s( + { trig = "ld", snippetType = "autosnippet", dscr = "Left down annotate" }, + fmta( + [[ + \path (<>.south) ++ (0,-0.8em) node[anchor=north east,color=<>!67] (<>_node){<>}; + \draw [color=<>!57](<>.south) |- ([xshift=-0.3ex,color=<>]<>_node.south west); + ]], + { + i(1, "markname"), + i(2, "color"), + rep(1), + i(3, "text"), + rep(2), + rep(1), + rep(2), + rep(1), + } + ), + { condition = tex.in_tikz } + ), + s( + { trig = "hl", snippetType = "autosnippet" }, + fmta( + [[ + \hlmath{<>}{<>} + ]], + { + i(1, "red"), + i(2), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "hl", snippetType = "autosnippet", priority = 2000 }, + fmta( + [[ + \hlmath{<>}{<>} + ]], + { + i(1, "red"), + d(2, get_visual), + } + ), + { condition = tex.in_mathzone } + ), + s( + { trig = "hl", snippetType = "autosnippet" }, + fmta( + [[ + \hltext{<>}{<>} + ]], + { + i(1, "red"), + i(2), + } + ), + { condition = tex.in_text } + ), + s( + { trig = "hl", snippetType = "autosnippet", priority = 2000 }, + fmta( + [[ + \hltext{<>}{<>} + ]], + { + i(1, "red"), + d(2, get_visual), + } + ), + { condition = tex.in_text } + ), +} diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua new file mode 100644 index 0000000..752b0a7 --- /dev/null +++ b/after/ftplugin/tex.lua @@ -0,0 +1,4 @@ +vim.opt.conceallevel = 2 + +vim.keymap.set({ "n", "i" }, "", "VimtexView", { desc = "Vimtex: View" }) +vim.keymap.set({ "n", "i" }, "", "VimtexCompile", { desc = "Vimtex: Compile" }) diff --git a/lazy-lock.json b/lazy-lock.json index 8f60042..045dafa 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,70 +1,71 @@ { - "LazyVim": { "branch": "main", "commit": "25abbf546d564dc484cf903804661ba12de45507" }, - "LuaSnip": { "branch": "master", "commit": "c1851d5c519611dfc451b6582961b2602e0af89b" }, - "SchemaStore.nvim": { "branch": "main", "commit": "df87d16fc4ea7c2c67cfc00b513861738693fe07" }, - "aerial.nvim": { "branch": "master", "commit": "2e00d1d4248f08dddfceacb8d2996e51e13e00f6" }, - "avante.nvim": { "branch": "main", "commit": "f755861d939df35b9d28ca3eb667af798750747f" }, + "LazyVim": { "branch": "main", "commit": "b4606f9df3395a261bb6a09acc837993da5d8bfc" }, + "LuaSnip": { "branch": "master", "commit": "b3104910bb5ebf40492aadffae18f2528fa757d9" }, + "SchemaStore.nvim": { "branch": "main", "commit": "22f0c2f7c727a15b45b7bfcbbab533720223b840" }, + "aerial.nvim": { "branch": "master", "commit": "c7cbbad40c2065fccfd1f1863bb2c08180c0533d" }, + "alpha-nvim": { "branch": "main", "commit": "2b3cbcdd980cae1e022409289245053f62fb50f6" }, + "avante.nvim": { "branch": "main", "commit": "26e40e5483db90c593bf09466bc6cbe5a7711381" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, - "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, + "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "catppuccin": { "branch": "main", "commit": "1bf070129c0b6f77cc23f6a2212dcdc868308c52" }, - "chezmoi.nvim": { "branch": "main", "commit": "838378806cac89ded93a4a27be32e98e066c0d2e" }, - "chezmoi.vim": { "branch": "main", "commit": "abf37336437867cbd99ce2f8849b717415391cc3" }, - "clangd_extensions.nvim": { "branch": "main", "commit": "db28f29be928d18cbfb86fbfb9f83f584f658feb" }, - "cmake-tools.nvim": { "branch": "master", "commit": "1ee065c33ca777c0e03cd7c358010202ee70bb88" }, - "code_runner.nvim": { "branch": "main", "commit": "4f694af54ff29834a6e0b2aaf1ed5e8809708c6d" }, - "competitest.nvim": { "branch": "master", "commit": "c9be46ff8f0649987459b21006215bc5be20a95b" }, - "conform.nvim": { "branch": "master", "commit": "374aaf384e2e841607b8e2fe63fa3ad01d111c91" }, - "copilot.lua": { "branch": "master", "commit": "2fe34db04570f6c47db0b752ca421a49b7357c03" }, - "dial.nvim": { "branch": "master", "commit": "2c7e2750372918f072a20f3cf754d845e143d7c9" }, - "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, - "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "43b0c856ae5f32a195d83f4a27fe21d63e6c966c" }, - "grug-far.nvim": { "branch": "main", "commit": "5ddfc2e9d1967084162c2c77e7036a43029abf78" }, - "inc-rename.nvim": { "branch": "main", "commit": "2eaff20526ff6101337b84f4b0d238c11f47d7f4" }, + "catppuccin": { "branch": "main", "commit": "f19cab18ec4dc86d415512c7a572863b2adbcc18" }, + "chezmoi.nvim": { "branch": "main", "commit": "e0b3ebafd910b63acdfbf6677b44b03eb3d09f19" }, + "chezmoi.vim": { "branch": "main", "commit": "ca5f2ed602046d5662cb76d845c4b510aae0ce84" }, + "clangd_extensions.nvim": { "branch": "main", "commit": "b67cc417d9020fb4b83d46662351b4d16894905e" }, + "cmake-tools.nvim": { "branch": "master", "commit": "88e07c6bff838a5bda2f461e9c1122b79ff0829f" }, + "code_runner.nvim": { "branch": "main", "commit": "a0aa4325ea2958ba21d77d181a838e74be6267cd" }, + "competitest.nvim": { "branch": "master", "commit": "b42c06ca308906f07912ba9aff015ac2c0831f85" }, + "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, + "copilot.lua": { "branch": "master", "commit": "af3114aeb915beb14fcbc46849c7b08a5e3e2c1a" }, + "dial.nvim": { "branch": "master", "commit": "f0404ec1f83a03f2c3457e60087c6331d1cbb83f" }, + "flash.nvim": { "branch": "main", "commit": "b68bda044d68e4026c4e1ec6df3c5afd7eb8e341" }, + "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, + "grug-far.nvim": { "branch": "main", "commit": "50d9ee2b5a19634670441948e7e4afaa042f1059" }, + "inc-rename.nvim": { "branch": "main", "commit": "8ae25b35ae16ca4bd5de3d3c472eec3b574018d4" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "lean.nvim": { "branch": "main", "commit": "a9beb8c8d366362063088dad5c348f8848442f47" }, - "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" }, + "lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" }, + "lean.nvim": { "branch": "main", "commit": "f6e6ecb8f1a140315f7bfb4ea88c4a39846617b0" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, - "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, - "mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" }, - "mini.hipatterns": { "branch": "main", "commit": "e5083df391171dc9d8172645606f8496d9443374" }, - "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, - "mini.pairs": { "branch": "main", "commit": "69864a2efb36c030877421634487fd90db1e4298" }, - "mini.surround": { "branch": "main", "commit": "5aab42fcdcf31fa010f012771eda5631c077840a" }, - "neo-tree.nvim": { "branch": "main", "commit": "56f383aa157f1ff20a59154907cc5f9fe26e4db9" }, - "neotest": { "branch": "master", "commit": "862afb2a2219d9ca565f67416fb7003cc0f22c4f" }, - "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7f9a39fcd2ac6e979001f857727d606888f5909c" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "86389a3dd687cfaa647b6f44731e492970034baa" }, + "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "mini.ai": { "branch": "main", "commit": "dcd346a3eda9121e917950680e5eb59f59f78aae" }, + "mini.hipatterns": { "branch": "main", "commit": "96d07d32a0db0d8d8a10c83a964ec557cca005e7" }, + "mini.icons": { "branch": "main", "commit": "f9a177c11daa7829389b7b6eaaec8b8a5c47052d" }, + "mini.pairs": { "branch": "main", "commit": "3738ea30ff33e0cbf2983dc67319a5468d25b0a9" }, + "mini.surround": { "branch": "main", "commit": "4b92d30fb5e021cced6cbb68698c73018211fbfa" }, + "neo-tree.nvim": { "branch": "main", "commit": "b2dfcc74b99f7b16a4c7cfef9dc1b38b7cf3fcda" }, + "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, + "neotest-python": { "branch": "master", "commit": "1b1b1abf928f32bbd6a7d183f7ffc80a591eb162" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-conda": { "branch": "main", "commit": "7e63124d98f48a3bb255eaa71d1602db610b9047" }, - "nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" }, - "nvim-dap-python": { "branch": "master", "commit": "261ce649d05bc455a29f9636dc03f8cdaa7e0e2c" }, - "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, - "nvim-lint": { "branch": "master", "commit": "9dfb77ef6c5092a19502883c02dc5a02ec648729" }, - "nvim-lspconfig": { "branch": "master", "commit": "61e5109c8cf24807e4ae29813a3a82b31821dd45" }, + "nvim-dap": { "branch": "master", "commit": "7367cec8e8f7a0b1e4566af9a7ef5959d11206a7" }, + "nvim-dap-python": { "branch": "master", "commit": "bfe572e4458e0ac876b9539a1e9f301c72db8ea0" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "107c2458cdc780c4ed2c2b5e1b7800cd019010bd" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, - "nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "e10df91b312c86af6d7ea9b0d525a3f5762b5dec" }, - "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, - "overseer.nvim": { "branch": "master", "commit": "72c68aab0358c92f451168b704c411c4a3e3410e" }, + "nvim-treesitter": { "branch": "main", "commit": "bd99d6bd2bdd346c5da090db5e3956de0e0a2f3f" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "1b2d85d3de6114c4bcea89ffb2cd1ce9e3a19931" }, + "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, + "overseer.nvim": { "branch": "master", "commit": "fe7b2f9ba263e150ab36474dfc810217b8cf7400" }, "persistence.nvim": { "branch": "main", "commit": "166a79a55bfa7a4db3e26fc031b4d92af71d0b51" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, - "render-markdown.nvim": { "branch": "main", "commit": "a1b0988f5ab26698afb56b9c2f0525a4de1195c1" }, - "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "67f2c7c8850bb11eefa6b22054a6f4cef1146de2" }, + "snacks.nvim": { "branch": "main", "commit": "d67a47739dfc652cfcf66c59e929c704a854b37a" }, + "solarized.nvim": { "branch": "main", "commit": "c0dfe1cbfabd93b546baf5f1408f5df7e02e2050" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, - "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "tokyonight.nvim": { "branch": "main", "commit": "14fd5ff7f84027064724ec3157fe903199e77ded" }, + "trouble.nvim": { "branch": "main", "commit": "f176232e7759c4f8abd923c21e3e5a5c76cd6837" }, "ts-comments.nvim": { "branch": "main", "commit": "1bd9d0ba1d8b336c3db50692ffd0955fe1bb9f0c" }, + "typst-preview.nvim": { "branch": "master", "commit": "dea4525d5420b7c32eebda7de15a6beb9d6574fa" }, + "venv-selector.nvim": { "branch": "main", "commit": "2b49d1f8b8fcf5cfbd0913136f48f118225cca5d" }, "vim-startuptime": { "branch": "master", "commit": "b6f0d93f6b8cf6eee0b4c94450198ba2d6a05ff6" }, - "vimtex": { "branch": "master", "commit": "7d16d56c765476f3101b2daa2a09f8ab82df9c5d" }, + "vimtex": { "branch": "master", "commit": "77f31bd02cec678823c8614e6400db97390b5ce7" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }, - "yazi.nvim": { "branch": "main", "commit": "82873628a2b78dce48b5bcf8d1d8ed14f0ee985f" } + "yazi.nvim": { "branch": "main", "commit": "4e37e76f504677ac7f1ecef42d615d9ea1221608" } } diff --git a/lazyvim.json b/lazyvim.json index 8aecc14..177b0e3 100644 --- a/lazyvim.json +++ b/lazyvim.json @@ -4,7 +4,6 @@ "lazyvim.plugins.extras.coding.blink", "lazyvim.plugins.extras.coding.luasnip", "lazyvim.plugins.extras.coding.mini-surround", - "lazyvim.plugins.extras.coding.nvim-cmp", "lazyvim.plugins.extras.coding.yanky", "lazyvim.plugins.extras.dap.core", "lazyvim.plugins.extras.editor.aerial", @@ -20,17 +19,18 @@ "lazyvim.plugins.extras.lang.python", "lazyvim.plugins.extras.lang.tex", "lazyvim.plugins.extras.lang.toml", + "lazyvim.plugins.extras.lang.typescript", "lazyvim.plugins.extras.lang.yaml", "lazyvim.plugins.extras.test.core", + "lazyvim.plugins.extras.ui.alpha", "lazyvim.plugins.extras.util.chezmoi", "lazyvim.plugins.extras.util.dot", "lazyvim.plugins.extras.util.mini-hipatterns", - "lazyvim.plugins.extras.util.project", "lazyvim.plugins.extras.util.startuptime" ], "install_version": 8, "news": { - "NEWS.md": "10960" + "NEWS.md": "11866" }, "version": 8 } \ No newline at end of file diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 0cc0bb3..5bb30d3 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -5,3 +5,11 @@ if vim.g.neovide then vim.cmd([[ cd $HOME ]]) end + +-- Disable spell checking for markdown and text files +vim.api.nvim_create_autocmd("FileType", { + pattern = { "markdown", "text", "tex" }, + callback = function() + vim.opt_local.spell = false + end, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua index 41f9a63..2032104 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -2,6 +2,7 @@ -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here +vim.lsp.log.set_level(vim.log.levels.OFF) vim.opt.timeoutlen = 150 vim.opt.spell = true vim.opt.spelllang = { "en", "cjk" } @@ -10,13 +11,15 @@ vim.opt.backup = false vim.g.maplocalleader = "\\" vim.g.autoformat = false -vim.g.node_host_prog = "/opt/homebrew/bin/neovim-node-host" local indent = 2 -- vim.opt.expandtab = true -- Use spaces instead of tabs vim.opt.softtabstop = indent -- Number of spaces that a counts for while performing editing operations vim.opt.tabstop = indent -- Number of spaces tabs count for vim.opt.shiftwidth = indent -- Size of an indent +vim.g.node_host_prog = "/opt/homebrew/bin/neovim-node-host" +-- vim.opt.expandtab = true -- Use spaces instead of tabs + if vim.g.neovide then vim.o.guifont = "Maple Mono:h16" vim.g.neovide_scale_factor = 1.0 diff --git a/lua/plugins/coderunner.lua b/lua/plugins/coderunner.lua index 2b9d139..9c51f4e 100644 --- a/lua/plugins/coderunner.lua +++ b/lua/plugins/coderunner.lua @@ -50,6 +50,7 @@ return { python = "python -u", sh = "bash", rust = "cd $dir && rustc $fileName && $dir$fileNameWithoutExt", + r = "cd $dir && R < $filename --no-save", }, project_path = "", -- No default path defined project = {}, diff --git a/lua/plugins/default/copilot.lua b/lua/plugins/default/copilot.lua index 38d5d1c..b6ea42a 100644 --- a/lua/plugins/default/copilot.lua +++ b/lua/plugins/default/copilot.lua @@ -1,15 +1,15 @@ return { - -- { - -- "zbirenbaum/copilot.lua", - -- opts = { - -- copilot_model = "claude-3.7-sonnet", - -- suggestion = { - -- keymap = { - -- accept = "", - -- next = "", - -- prev = "", - -- }, - -- }, - -- }, - -- }, + { + "zbirenbaum/copilot.lua", + opts = { + copilot_model = "claude-opus-4", + suggestion = { + keymap = { + accept = "", + next = "", + prev = "", + }, + }, + }, + }, } diff --git a/lua/plugins/default/lspconfig.lua b/lua/plugins/default/lspconfig.lua index 982b6fd..a7b68f7 100644 --- a/lua/plugins/default/lspconfig.lua +++ b/lua/plugins/default/lspconfig.lua @@ -18,6 +18,8 @@ return { }, }, }, + + tinymist = {}, }, }, }, diff --git a/lua/plugins/default/tree-sitter.lua b/lua/plugins/default/tree-sitter.lua deleted file mode 100644 index 268563f..0000000 --- a/lua/plugins/default/tree-sitter.lua +++ /dev/null @@ -1,59 +0,0 @@ -return { - { - "nvim-treesitter/nvim-treesitter", - opts = function() - return { - highlight = { - enable = true, - disable = { "latex" }, - additional_vim_regex_highlighting = { "latex", "markdown" }, - }, - indent = { enable = true, disable = { "python" } }, - context_commentstring = { enable = true, enable_autocmd = false }, - ensure_installed = { - "bash", - "c", - "cpp", - "html", - "json", - "lua", - "luap", - "markdown", - "make", - "markdown_inline", - "scala", - "python", - "query", - "toml", - "regex", - "vim", - "yaml", - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = "\\", - node_decremental = "", - }, - }, - } - end, - rainbow = { - enable = true, - -- list of languages you want to disable the plugin for - disable = { "jsx", "cpp" }, - -- Which query to use for finding delimiters - query = "rainbow-parens", - -- Highlight the entire buffer all at once - }, - - keys = function() - return { - { "", desc = "Increment selection" }, - { "", desc = "Decrement selection", mode = "x" }, - } - end, - }, -} diff --git a/lua/plugins/default/treesitter.lua b/lua/plugins/default/treesitter.lua index abeac3f..5197c88 100644 --- a/lua/plugins/default/treesitter.lua +++ b/lua/plugins/default/treesitter.lua @@ -1,36 +1,40 @@ return { { "nvim-treesitter/nvim-treesitter", + -- commit = "a1332a7925e5b3234a94480f77713d396ca895c1", opts = function() + local parsers = { + "typst", + "bash", + "c", + "cpp", + "html", + "json", + "lua", + "luap", + "markdown", + "make", + "markdown_inline", + "scala", + "python", + "latex", + "query", + "toml", + "regex", + "vim", + "yaml", + } + table.insert(parsers, "latex") return { highlight = { enable = true, - disable = { "latex" }, + disable = { "tex, latex" }, -- additional_vim_regex_highlighting = { "markdown" }, }, -- ignore_install = { "latex" }, indent = { enable = true, disable = { "python" } }, context_commentstring = { enable = true, enable_autocmd = false }, - ensure_installed = { - "latex", - "bash", - "c", - "cpp", - "html", - "json", - "lua", - "luap", - "markdown", - "make", - "markdown_inline", - "scala", - "python", - "query", - "toml", - "regex", - "vim", - "yaml", - }, + ensure_installed = parsers, incremental_selection = { enable = true, keymaps = { diff --git a/lua/plugins/lang/latex.lua b/lua/plugins/lang/latex.lua index 160124a..75f7727 100644 --- a/lua/plugins/lang/latex.lua +++ b/lua/plugins/lang/latex.lua @@ -5,7 +5,7 @@ return { init = function() vim.g.vimtex_syntax_conceal_disable = 1 vim.g.vimtex_mappings_disable = { ["n"] = { "K" } } -- disable `K` as it conflicts with LSP hover - vim.g.vimtex_view_method = "sioyek" + vim.g.vimtex_view_method = "skim" -- vim.g.vimtex_view_general_viewer = "open -a UPDF" vim.g.vimtex_view_skim_sync = 1 vim.g.vimtex_compiler_silent = 1 diff --git a/lua/plugins/lang/typst.lua b/lua/plugins/lang/typst.lua new file mode 100644 index 0000000..a7202a2 --- /dev/null +++ b/lua/plugins/lang/typst.lua @@ -0,0 +1,16 @@ +return { + { + "chomosuke/typst-preview.nvim", + ft = "typst", + version = "1.*", + opts = { + dependencies_bin = { + ["tinymist"] = "tinymist", + }, + -- open_cmd = "brave %s --class typst-preview", + }, + keys = { + { "lp", "TypstPreview", desc = "Open Typst Preview" }, + }, + }, +} diff --git a/lua/plugins/mason-workaround.lua b/lua/plugins/mason-workaround.lua index 949039d..fac7e67 100644 --- a/lua/plugins/mason-workaround.lua +++ b/lua/plugins/mason-workaround.lua @@ -1,4 +1,4 @@ return { - { "mason-org/mason.nvim", version = "^1.0.0" }, - { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" }, + -- { "mason-org/mason.nvim", version = "^1.0.0" }, + -- { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" }, } diff --git a/lua/plugins/ui/colorscheme.lua b/lua/plugins/ui/colorscheme.lua index 4ce4118..652165b 100644 --- a/lua/plugins/ui/colorscheme.lua +++ b/lua/plugins/ui/colorscheme.lua @@ -1,5 +1,18 @@ return { -- Lazy + { + "maxmx03/solarized.nvim", + lazy = false, + priority = 1000, + ---@type solarized.config + opts = {}, + config = function(_, opts) + vim.o.termguicolors = true + vim.o.background = "light" + require("solarized").setup(opts) + vim.cmd.colorscheme("solarized") + end, + }, { "catppuccin/nvim", name = "catppuccin", @@ -13,7 +26,7 @@ return { { "LazyVim/LazyVim", opts = { - colorscheme = "catppuccin", + colorscheme = "solarized", }, }, } diff --git a/lua/util/latex.lua b/lua/util/latex.lua index eccbafb..8bbf666 100644 --- a/lua/util/latex.lua +++ b/lua/util/latex.lua @@ -6,10 +6,9 @@ local MATH_NODES = { math_environment = true, } -local ts_utils = require("nvim-treesitter.ts_utils") - M.in_env_md = function(env) - local node = ts_utils.get_node_at_cursor() + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local node = vim.treesitter.get_node({ bufnr = 0, pos = { row - 1, col } }) local bufnr = vim.api.nvim_get_current_buf() while node do if node:type() == "generic_environment" then @@ -29,12 +28,56 @@ M.in_env = function(env) return pos[1] ~= 0 or pos[2] ~= 0 end +-- For markdown +M.in_mathzone_md = function() + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local node = vim.treesitter.get_node({ bufnr = 0, pos = { row - 1, col } }) + while node do + if MATH_NODES[node:type()] then + return true + end + node = node:parent() + end + return false +end +M.in_text_md = function() + return not M.in_mathzone_md() +end + +-- For typst +M.in_mathzone_typ = function() + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local node = vim.treesitter.get_node({ bufnr = 0, pos = { row - 1, col } }) + while node do + if node:type() == "math" then + return true + end + node = node:parent() + end + return false +end + +M.in_mathzone_tex = function() + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local node = vim.treesitter.get_node({ bufnr = 0, pos = { row - 1, col } }) + while node do + if MATH_NODES[node:type()] then + return true + end + node = node:parent() + end + + return false +end + M.in_mathzone = function() local ft = vim.bo.filetype if ft == "tex" then - return vim.api.nvim_eval("vimtex#syntax#in_mathzone()") == 1 + return M.in_mathzone_tex() elseif ft == "markdown" then return M.in_mathzone_md() + elseif ft == "typst" then + return M.in_mathzone_typ() end end @@ -58,21 +101,6 @@ M.in_algo = function() return M.in_env("algorithmic") end --- For markdown -M.in_mathzone_md = function() - local node = ts_utils.get_node_at_cursor() - while node do - if MATH_NODES[node:type()] then - return true - end - node = node:parent() - end - return false -end -M.in_text_md = function() - return not M.in_mathzone_md() -end - -- M.clean = function() -- local current_dir = vim.fn.expand("%:p:h") -- local file_types = { "aux", "log", "out", "fls", "fdb_latexmk", "bcf", "run.xml", "toc", "DS_Store", "bak*", "dvi" } diff --git a/queries/latex/highlights.scm b/queries/latex/highlights.scm new file mode 100644 index 0000000..dd02813 --- /dev/null +++ b/queries/latex/highlights.scm @@ -0,0 +1,5 @@ +;; extends +((generic_command + command: (command_name) @_name + arg: (curly_group (_) @text.strong)) + (#match? @_name "^(\\\\vb)$")) diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add new file mode 100644 index 0000000..12b97f1 --- /dev/null +++ b/spell/en.utf-8.add @@ -0,0 +1,301 @@ +nvim +luasnip +exponationally +abelian +nonidentity +iff +Eigenspectrum +xshift +Superoprator +POVM +Neovim +dotfiles +cosets +BHK +Lindenstrauss +Minkowski +Brunn +Hoeffding's +mixedness +Subadditivity +subadditivity +superoperators +Hermiticity +LRU +struct +Sylow +EPR +Kraus +Markovian +dephasing +move +LOCC +decoherence +nonnegative +PPT +NPPT +Superscalar +PID +syscall +Ctrl +Syscalls +func +SVD +JL +adaptic +Rabi +mutex +FCFS +renormalization +DMRG +TNS +RBM +qudits +CHSH +subring +datapoints +subrings +Dicke +Frobenius +Preprocess +qudit +Untar +comaximal +adic +Pokemons +MCMC +by +by +by +by +by +since +braket +Toffoli +CNOT +nontrivially +squarefree +sympy +monic +irreducibles +QCircuit +MCMT +infimum +between +stationarity +Jozsa +QFT +FFT +Vazirani +DIT +QIT +DFT +cheeger +PTE +ns +inode +coset +subgraph +Hölder +ancilla +ancillas +Distinguishability +Glauber +subsubsection +url +superdense +eigenspace +HJW +primality +HC +Eulerian +CSAT +Yan +DFS +BFS +eq +AGI +GPT +NLP +eqnarray +eqnarray +we +we +SFT +RLHF +ASG +CFD +AST +Kutzbach +Grubler +DOF +Chu +Ji +equ +TODO +superluminal +th +distinguishability +Hanyu +SCC +idx +heapify +algo +tmp +Kruskal's +Laplacian +yue +Yu +SVRG +Prox +ish +subsequences +matroid +BBBB +subtree +learnable +VC +orthonormality +colorable +Hölder's +Massart +supremum +polytope +Chebyshev's +Chebyshev +Borel +submodular +DS +NPC +Fatou's +Fubini's +Clauser +Hao +Hu +DCT +WLLN +Cantelli +CPTP +FPTAS +PTAS +subgraphs +lem +SVM +Paseval's +keymap +hw7 +subsequential +CDF +CDFs +Gini +SLLN +Kolmogorov +LSH +sparsifies +WTA +Fulkerson +derandomize +NPT +Helly's +RKHS +MRF +adjugate +FPRAS +Chernoff +CLT +Slutsky's +iso +SNE +hyperparameter +LLM +Yue's +Schwarz +Bayesion +hyperparameters +UCB +UCB1 +submatrix +Ghouila +submatrices +OLS +TUMs +makespan +qutrit +C2b +C2a +Fano's +Jenson's +Rao +Cramér +BB84 +SPD +Gershgorin's +Logmag +logmag +Ising +sidebands +unentangled +const +htbp +wavefunction +nondimensionalized +discretization +Qiskit +Eigenenergies +eigenenergy +eigenenergies +KKT +ansatz +Hund's +Balmer +antisym +sym +Lindblad +Homeomorphic +cohomology +Rham +homeomorphic +imine +svg +homeomorphism +preimage +Acetamide +NISQ +Peano +Urysohn's +subcover +surjectivity +closedness +Lindelöf +neovide +ui +campactify +compactify +compactification +bilibili +MBQC +TQC +unitaries +Parallelisable +Knill +Gottesman +WQC +Lindelöf's +parallelisability +wieldy +sth +sb +sp +QOTP +FTQC +aa +Lec +ECC +cyphertext +indistinguishability +desc +QHE +neovim +FHE +pulldown +semidirect diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl new file mode 100644 index 0000000000000000000000000000000000000000..c6d84936e8d8252a0b4302c139cd8eef42a5b1da GIT binary patch literal 3026 zcmZ`*zi%8x6rPzqpAAYR0xrN3qFAJ$KqQhN5hc152?DtYQgk>g(e3W--Hva6d4HVm zTv0@XA_^UH=Tu0@ic+AYO_9b${suw`!UY9NfrQ}u-kj4R%eTAp-n<{*``(+my?L{# zk}SLUuTraDz7t0AC>c*uyFJbFqO5l6rtN0C^Tiq^ldNd8(uvNr)uGl(`31gOyysXM z;oTT7wA;GEBE*|klw#fK36x~bPoQdgSm6HBi<=e;8U8|}xYWGT+=HOe3sKAsWWj_# z?Q3C_j8j|IR9~2E0rv^D1~r}yc9rr~n9Gs=M4NB;6-4mA>-5fxcF@TBRMLqg2pY7S zR%k6VVW+3=!t}qw{}X=oH8J+I1}@C37BnC|ny-Zv$H~~{l12kj2(=Op3U0m9_Tq~5 z-DKo$cOoJ+jPV^xnW?ILQma7j%uwPR?g?24ZqR~Y@}%n3sfk-DuggTwNwESrcX$$i zB0@G=1hg>97-)0*L@bV56oFz!nDk>??R0aI$5N}pprR~6ttThA5hJtF=n59}^Dq%y zYge{GE}Lsl6>#Era9=xz$05AXjwH12uqhyC;3a%ejy=cOS{M_{aaz@FXNne5e6OFC zr`Z>J96Hh@rj|+_N?q_H z7R(%%Xv6H2r^M1RUi`ddu#Tl{L3RWgYU&)T5#H3j?DY_jAWpW+w%c7iGlXMMy4FX3 zgqe8%trELtpAF9nS%AqWwPj2MyC%s|qcP}k53%~q7Y^Sps9J|{QDJp&gD9y zE&o$ck>Hcj>=KR_#toUR^%F$FSqBi#)cw&oFKX9vLIs};f#R_6Mq~1s-2Ok3LGPGS z;lW%$8jj$St=vg+i1mZWV^FCyB5RMY!K9b)!L*9QO1%fM`Mv2wtglUrvhDyQ z?R#6Hi|i=}5{H2+oHX-bMpS+dJJ^{bV|?sq2z(C+aTL&3x)vs=J-SlA-*f+g@{e%UBk;w`ShbNSt84D_emO1NnHxN1F&82vP;KcBToDl)r zf^EeV>}m*|$5D*w-}R=L!N5v(e^?=K=3=TDR#-R&#dc>E7~4p@Q-pyAElH+7p3AOX zXXE7*5vVW7zTu2pg0Zm6yPK>gfLec-l@*r#W(K1(O)4oA41CI+g2F|b&Aj&iB+ z!w@Bc;y-rTp_mBZCT9hw3C9}0B82TdBz3NGS*zaK49kvKr8h5sND(3`HZjgyM4)LjQk#u()!zy1EU7X z_=L(qYnCH>N`rT;88LBvhgy&y*?!0fqa>YXbn`O855~m_5+slQn%dWLP-*>~^PNpWxbzj!TG}=! zfDno3y*u?(2uA@Mnbqg;HRmkSqwNIWlEyHRw((OI@?@xE|07CQe!;Dvs#n8!lB0sE z|3-^g7!7q{Z=DQ80B@5oJRacDrY0<*00IFPbB;Xs=h)Su^w8bl0FWx%iAg%W0|990 zbOmCNJVMMe+xB9EYf0T3WhGZ+->|_JcgpGn_Z`uI`{k)~g`o&Z@0Y0O@{GFA8hDQr zy$v(&dc-tmyb1v%#3Hr zSV1fD!oUKVKSHul`51{3K#QJbZOMlI9!cU3Xr3r5f69BnIhIQO)X|tO_QMWGPr}S_ zWGkgUTDgAX)>m8ly1tB?tJ0t8&#_;fYV-|p{HjS#wR($^H*Z36U34yBzf%7Jit#oa literal 0 HcmV?d00001 diff --git a/spell/nl.utf-8.add b/spell/nl.utf-8.add new file mode 100644 index 0000000..732ff53 --- /dev/null +++ b/spell/nl.utf-8.add @@ -0,0 +1 @@ +nvim diff --git a/spell/nl.utf-8.add.spl b/spell/nl.utf-8.add.spl new file mode 100644 index 0000000000000000000000000000000000000000..82cca22ff0a18fd3d48115b346fa6fc6bd59b145 GIT binary patch literal 33 hcmWIZ^erw(&B-zP&%nUI#hAxf#+b>N%LwE^0RWK?1_uBD literal 0 HcmV?d00001