Update
This commit is contained in:
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
tt.*
|
||||
.tests
|
||||
doc/tags
|
||||
debug
|
||||
.repro
|
||||
foo.*
|
||||
*.log
|
||||
data
|
||||
15
.neoconf.json
Normal file
15
.neoconf.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"neodev": {
|
||||
"library": {
|
||||
"enabled": true,
|
||||
"plugins": true
|
||||
}
|
||||
},
|
||||
"neoconf": {
|
||||
"plugins": {
|
||||
"lua_ls": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
201
LICENSE
Normal file
201
LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
21
LuaSnip/all.lua
Normal file
21
LuaSnip/all.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
return {
|
||||
s(
|
||||
"date",
|
||||
f(function()
|
||||
return os.date("%D - %H:%M")
|
||||
end)
|
||||
),
|
||||
s("choicenode", c(1, { t("choice 1"), t("choice 2"), t("choice 3") })),
|
||||
}
|
||||
-- test
|
||||
100
LuaSnip/lua.lua
Normal file
100
LuaSnip/lua.lua
Normal file
@@ -0,0 +1,100 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
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(
|
||||
"localreq",
|
||||
fmt('local {} = require("{}")', {
|
||||
l(l._1:match("[^.]*$"):gsub("[^%a]+", "_"), 1),
|
||||
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" },
|
||||
fmta(
|
||||
[[
|
||||
s(
|
||||
{ trig = "<>", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\<>{"), i(1), t("}") }), sn(nil, { t("\\<>*{"), i(1), t("{") }) }),
|
||||
{ condition = tex.<> }
|
||||
),
|
||||
]],
|
||||
{ i(1), rep(1), rep(1), c(2, { t("in_text"), t("in_quantikz"), t("in_mathzone") }) }
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "optsnip", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
s(
|
||||
{ trig = "<>", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\<>{"), i(1), t("}") }), sn(nil, { t("\\<>["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.<> }
|
||||
),
|
||||
]],
|
||||
{ i(1), rep(1), rep(1), c(2, { t("in_quantikz"), t("in_mathzone") }) }
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "starsnip", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
s(
|
||||
{ trig = "<>", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\<>{"), i(1), t("}") }), sn(nil, { t("\\<>*{"), i(1), t("}") }) }),
|
||||
{ condition = tex.<> }
|
||||
),
|
||||
]],
|
||||
{ i(1), rep(1), rep(1), c(2, { t("in_quantikz"), t("in_mathzone") }) }
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "fmtasnip", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
s({ trig = "<>", snippetType = "autosnippet" },
|
||||
fmta("\\<>{<<>>}", {
|
||||
<>
|
||||
}),
|
||||
{ condition = tex.<> }),
|
||||
]],
|
||||
{ i(1), rep(1), i(2, "i(1),"), c(3, { t("in_algo"), t("in_quantikz") }) }
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "tsnip", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
s({ trig = "<>", snippetType = "autosnippet" }, {
|
||||
t("\\<>"),
|
||||
}, { condition = tex.<> }),
|
||||
]],
|
||||
{ i(1), rep(1), c(2, { t("in_mathzone"), t("in_quantikz") }) }
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
}
|
||||
24
LuaSnip/markdown/math.lua
Normal file
24
LuaSnip/markdown/math.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
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 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 tex = require("util.latex")
|
||||
|
||||
return {
|
||||
-- s({ trig = "ii", snippetType = "autosnippet" }, fmta("$<>$", i(1))),
|
||||
-- s({ trig = "dd", snippetType = "autosnippet" }, fmta("$$\n<>\n$$", i(1))),
|
||||
}
|
||||
41
LuaSnip/markdown/text.lua
Normal file
41
LuaSnip/markdown/text.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
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 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(
|
||||
"link",
|
||||
fmta("[<>](<>)", { i(1), f(function(_, snip)
|
||||
return snip.env.TM_SELECTED_TEXT[1] or {}
|
||||
end, {}) })
|
||||
),
|
||||
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 = ";c", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
```<>
|
||||
<>
|
||||
```
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
)
|
||||
),
|
||||
}
|
||||
109
LuaSnip/python/manim.lua
Normal file
109
LuaSnip/python/manim.lua
Normal file
@@ -0,0 +1,109 @@
|
||||
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
|
||||
return {
|
||||
s(
|
||||
{ trig = "voo", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
with self.voiceover(text="<>") as tracker:
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "mte", wordTrig = false },
|
||||
fmta(
|
||||
[[
|
||||
<>_string = "<>"
|
||||
<>_tex = MathTex(r"<>", tex_template=myTemplate)
|
||||
with self.voiceover(text=<>_string) as tracker:
|
||||
self.play(Write(<>_tex))
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
rep(1),
|
||||
i(3),
|
||||
rep(1),
|
||||
rep(1),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "text", wordTrig = false },
|
||||
fmta(
|
||||
[[
|
||||
<>_string = "<>"
|
||||
<>_text = Text(<>_string)
|
||||
with self.voiceover(text=<>_string) as tracker:
|
||||
self.play(Write(<>_text), run_time=tracker.duration)
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
rep(1),
|
||||
rep(1),
|
||||
rep(1),
|
||||
rep(1),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "spt", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
self.play(Write(<>), run_time=tracker.duration)
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "spd", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
self.play(FadeOut(<>))
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "spp", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
self.play(<>)
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "mtex", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
<> = MathTex(r"<>", tex_template=myTemplate)
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
}
|
||||
139
LuaSnip/tex/algo.lua
Normal file
139
LuaSnip/tex/algo.lua
Normal file
@@ -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 = 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 }
|
||||
-- ),
|
||||
-- }
|
||||
309
LuaSnip/tex/completion.lua
Normal file
309
LuaSnip/tex/completion.lua
Normal file
@@ -0,0 +1,309 @@
|
||||
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("\\sum\\limits_{<>}^{<>}", {
|
||||
-- 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("\\bigotimes_{<>}^{<>}", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bcap", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\bigcap_{<>}^{<>}", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bcup", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\bigcup_{<>}^{<>}", {
|
||||
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 = "pt", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\int <> \\d P", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "mt", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\int <> d\\mu", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "int", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\int_{<>}^{<>} <> d <>", {
|
||||
i(1),
|
||||
i(2),
|
||||
i(3),
|
||||
i(4),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
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 }
|
||||
),
|
||||
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 }
|
||||
),
|
||||
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 }
|
||||
),
|
||||
}
|
||||
58
LuaSnip/tex/derivative.lua
Normal file
58
LuaSnip/tex/derivative.lua
Normal file
@@ -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 }
|
||||
),
|
||||
}
|
||||
435
LuaSnip/tex/env.lua
Normal file
435
LuaSnip/tex/env.lua
Normal file
@@ -0,0 +1,435 @@
|
||||
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 = "bad", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{adjustbox}{width=0.<>\textwidth}
|
||||
<>
|
||||
\end{adjustbox}
|
||||
]],
|
||||
{
|
||||
i(1, "8"),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bp", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{problem}{<>}
|
||||
<>
|
||||
\end{problem}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "equ", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{equation}
|
||||
<>
|
||||
\end{equation}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin * tex.in_text }
|
||||
),
|
||||
s(
|
||||
{ trig = "bf", 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 = "bdef", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{definition}
|
||||
<>
|
||||
\end{definition}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bth", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{theorem}
|
||||
<>
|
||||
\end{theorem}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "bex", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{example}
|
||||
<>
|
||||
\end{example}
|
||||
]],
|
||||
{
|
||||
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.5\textwidth]{<>}
|
||||
\caption{<>}
|
||||
\label{fig:<>}
|
||||
\end{figure}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
rep(2),
|
||||
}
|
||||
),
|
||||
{ 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 = "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" },
|
||||
fmta(
|
||||
[[
|
||||
\subsection{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{ condition = 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 }
|
||||
),
|
||||
}
|
||||
145
LuaSnip/tex/font.lua
Normal file
145
LuaSnip/tex/font.lua
Normal file
@@ -0,0 +1,145 @@
|
||||
local ls = require("luasnip")
|
||||
local t = ls.text_node
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local i = ls.insert_node
|
||||
local d = ls.dynamic_node
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
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", snippetType = "autosnippet" },
|
||||
fmta("\\text{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "tet", snippetType = "autosnippet" },
|
||||
fmta("\\text{<>}", {
|
||||
i(1),
|
||||
})
|
||||
),
|
||||
s({ trig = "CC", snippetType = "autosnippet" },
|
||||
t("\\mathbb{C}"),
|
||||
{ condition = tex.in_mathzone() }),
|
||||
}
|
||||
172
LuaSnip/tex/greek-letter.lua
Normal file
172
LuaSnip/tex/greek-letter.lua
Normal file
@@ -0,0 +1,172 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local tex = require("util.latex")
|
||||
|
||||
return {
|
||||
s({ trig = "alp", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\alpha"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
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 }),
|
||||
}
|
||||
426
LuaSnip/tex/math-commands.lua
Normal file
426
LuaSnip/tex/math-commands.lua
Normal file
@@ -0,0 +1,426 @@
|
||||
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 }),
|
||||
s({ trig = "asin", snippetType = "autosnippet" }, {
|
||||
t("\\arcsin"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "cos", snippetType = "autosnippet" }, {
|
||||
t("\\cos"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "acos", snippetType = "autosnippet" }, {
|
||||
t("\\arccos"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "tan", snippetType = "autosnippet" }, {
|
||||
t("\\tan"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "atan", snippetType = "autosnippet" }, {
|
||||
t("\\arctan"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "cot", snippetType = "autosnippet" }, {
|
||||
t("\\cot"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "acot", snippetType = "autosnippet" }, {
|
||||
t("\\arccot"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "csc", snippetType = "autosnippet" }, {
|
||||
t("\\csc"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "acsc", snippetType = "autosnippet" }, {
|
||||
t("\\arccsc"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "sec", snippetType = "autosnippet" }, {
|
||||
t("\\sec"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "asec", snippetType = "autosnippet" }, {
|
||||
t("\\arcsec"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "log", snippetType = "autosnippet" }, {
|
||||
t("\\log"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "ln", snippetType = "autosnippet" }, {
|
||||
t("\\ln"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "exp", snippetType = "autosnippet" }, {
|
||||
t("\\exp"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "grad", snippetType = "autosnippet" }, {
|
||||
t("\\grad"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "curl", snippetType = "autosnippet" }, {
|
||||
t("\\curl"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "div", snippetType = "autosnippet" }, {
|
||||
t("\\div"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "lap", snippetType = "autosnippet" }, {
|
||||
t("\\laplacian"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbr", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{R}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbq", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{Q}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbh", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{H}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbc", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{C}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbz", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{Z}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbn", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{N}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bb1", snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("\\mathbbm{1}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "bbe", snippetType = "autosnippet" }, {
|
||||
t("\\mathbb{E}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
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 }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%w)cal", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\mathcal{<>}", {
|
||||
f(function(_, snip)
|
||||
return string.upper(snip.captures[1])
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s({ trig = "exp", snippetType = "autosnippet" }, {
|
||||
t("\\exp"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "cv", snippetType = "autosnippet" }, fmta("\\conv", {}), { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = "br", snippetType = "autosnippet" },
|
||||
fmta("\\bar{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bar", snippetType = "autosnippet" },
|
||||
fmta("\\overline{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%a)bar", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
|
||||
fmta("\\overline{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "ob", snippetType = "autosnippet" },
|
||||
fmta("\\overbrace{<>}^{<>}", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "ob", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\overbrace{<>}^{<>}", {
|
||||
d(1, get_visual),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "td", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\tilde{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "td", snippetType = "autosnippet" },
|
||||
fmta("\\ttlde{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(\\%a+)~", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
|
||||
fmta("\\tilde{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "(%a)~", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
|
||||
fmta("\\tilde{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "dot", snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\dot{<>}", {
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ 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("\\ddot{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
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 }
|
||||
),
|
||||
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 }
|
||||
),
|
||||
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("\\Range", {}), { 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 = ";i", wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\langle <>, <> \\rangle", {
|
||||
i(1),
|
||||
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("\\d ", {}), { condition = tex.in_mathzone }),
|
||||
s({ trig = "poly", snippetType = "autosnippet" }, fmta("\\poly", {}), { condition = tex.in_mathzone }),
|
||||
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 }
|
||||
),
|
||||
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 = "cqty", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\complexqty{<>}{<>}", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "gcd", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\gcd", {}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "abs", wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("\\abs{<>}", {
|
||||
i(1),
|
||||
}),
|
||||
{ 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 = "sch", snippetType = "autosnippet" }, {
|
||||
t("\\Sch"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\Pii", snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("P_i"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
}
|
||||
137
LuaSnip/tex/matrix.lua
Normal file
137
LuaSnip/tex/matrix.lua
Normal file
@@ -0,0 +1,137 @@
|
||||
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 }
|
||||
),
|
||||
}
|
||||
305
LuaSnip/tex/physics.lua
Normal file
305
LuaSnip/tex/physics.lua
Normal file
@@ -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 }),
|
||||
}
|
||||
104
LuaSnip/tex/physics2.lua
Normal file
104
LuaSnip/tex/physics2.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
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("\\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("\\ab( <> )", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "Bab", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
|
||||
fmta("\\ab\\{ <> \\}", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "bab", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
|
||||
fmta("\\ab[ <> ]", {
|
||||
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("\\ab|"), i(1), t("|") }), sn(nil, { t("\\ab*|"), i(1), t("|") }) }),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s(
|
||||
{ trig = "norm", wordTrig = false, snippetType = "autosnippet", priority = 1000 },
|
||||
fmta("\\| <> \\|", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s({ trig = "\\tof", snippetType = "autosnippet" }, {
|
||||
t("\\Tof"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
}
|
||||
297
LuaSnip/tex/py.lua
Normal file
297
LuaSnip/tex/py.lua
Normal file
@@ -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 = symbols('x y')
|
||||
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)
|
||||
),
|
||||
}
|
||||
301
LuaSnip/tex/quantikz.lua
Normal file
301
LuaSnip/tex/quantikz.lua
Normal file
@@ -0,0 +1,301 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
local tex = require("util.latex")
|
||||
|
||||
local get_visual = function(args, parent)
|
||||
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
return sn(nil, t(parent.snippet.env.SELECT_RAW))
|
||||
else -- If SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "bqu", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{quantikz}
|
||||
& <>
|
||||
\end{quantikz}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
s(
|
||||
{ trig = "cl", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\ctrl{"), i(1), t("}") }), sn(nil, { t("\\ctrl["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "ocl", snippetType = "autosnippet", priority = 2000 },
|
||||
c(1, { sn(nil, { t("\\octrl{"), i(1), t("}") }), sn(nil, { t("\\octrl["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "tar", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\targ{"), i(1), t("}") }), sn(nil, { t("\\targX{"), i(1), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "gate", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\gate{"), i(1), t("}") }), sn(nil, { t("\\gate["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "g(%a)", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\gate{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "wire", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\wire["), i(1), t("]{"), i(2), t("}") }), sn(nil, { t("\\wire{"), i(1), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "mt", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\meter{"), i(1), t("}") }), sn(nil, { t("\\meter["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "phase", snippetType = "autosnippet" },
|
||||
fmta("\\phase{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "swap", snippetType = "autosnippet" },
|
||||
fmta("\\swap{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "ls", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\lstick{"), i(1), t("}") }), sn(nil, { t("\\lstick["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "rs", snippetType = "autosnippet" },
|
||||
c(1, { sn(nil, { t("\\rstick{"), i(1), t("}") }), sn(nil, { t("\\rstick["), i(1), t("]{"), i(2), t("}") }) }),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "group", snippetType = "autosnippet" },
|
||||
fmta("\\gategroup[<>,steps=<>]{<>}", {
|
||||
i(1),
|
||||
i(2),
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "slice", snippetType = "autosnippet" },
|
||||
fmta("\\slice{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "push", snippetType = "autosnippet" },
|
||||
fmta("\\push{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "ms", snippetType = "autosnippet" },
|
||||
c(1, {
|
||||
sn(nil, { t("\\measure{"), i(1), t("}") }),
|
||||
sn(nil, { t("\\measuretab{"), i(1), t("}") }),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "ket", snippetType = "autosnippet" },
|
||||
fmta("\\ket{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s(
|
||||
{ trig = "bra", snippetType = "autosnippet" },
|
||||
fmta("\\bra{<>}", {
|
||||
i(0),
|
||||
}),
|
||||
{ condition = tex.in_quantikz }
|
||||
),
|
||||
s({ trig = "alp", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\alpha"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Alp", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Alpha"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "beta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\beta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Beta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Beta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "gam", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\gamma"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Gam", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Gamma"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "del", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\delta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Del", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Delta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "eps", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\epsilon"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "vps", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\varepsilon"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Eps", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Epsilon"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "zeta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\zeta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Zeta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Zeta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "eta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\eta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Eta", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Eta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "the", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\theta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "The", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Theta"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "iot", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\iota"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Iot", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Iota"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "kap", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\kappa"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Kap", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Kappa"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "lam", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\lambda"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Lam", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Lambda"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "mu", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\mu"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Mu", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Mu"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "nu", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\nu"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Nu", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Nu"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
-- s({ trig = "xi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
-- t("\\xi"),
|
||||
-- }, { condition = tex.in_quantikz }),
|
||||
-- s({ trig = "Xi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
-- t("\\Xi"),
|
||||
-- }, { condition = tex.in_quantikz }),
|
||||
s({ trig = "omi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\omicron"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "pi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\pi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "\\pii", snippetType = "autosnippet", wordTrig = false, priority = 2000 }, {
|
||||
t("p_i"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Pi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Pi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "rho", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\rho"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Rho", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Rho"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "sig", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\sigma"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Sig", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Sigma"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "tau", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\tau"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Tau", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Tau"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "ups", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\ups"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Ups", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Ups"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "phi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\phi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Phi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Phi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "vhi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\varphi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Vhi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Varphi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "chi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\chi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Chi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Chi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "psi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\psi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Psi", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Psi"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "ome", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\omega"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
s({ trig = "Ome", snippetType = "autosnippet", wordTrig = false }, {
|
||||
t("\\Omega"),
|
||||
}, { condition = tex.in_quantikz }),
|
||||
}
|
||||
|
||||
266
LuaSnip/tex/symbol-short.lua
Normal file
266
LuaSnip/tex/symbol-short.lua
Normal file
@@ -0,0 +1,266 @@
|
||||
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("\\cdot"),
|
||||
}, { 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("\\vdot"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\vdot.", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\vdots"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "d.", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\ddot"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\ddot.", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\ddots"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "iff", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\iff"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "inn", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\in"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "notin", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("not\\in"),
|
||||
}, { 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("\\neq"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "==", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("&="),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\leq=", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("&\\leq"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\geq=", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("&\\geq"),
|
||||
}, { 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("\\geq"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "<=", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\leq"),
|
||||
}, { 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 = "\\>", wordTrig = false, snippetType = "autosnippet", priority = 1001 }, {
|
||||
t("\\mapsto"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\\\\\", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\setminus"),
|
||||
}, { 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("\\cap"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "cup", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\cup"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "sub", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\subseteq"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
-- s({ trig = "sup", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
-- t("\\supseteq"),
|
||||
-- }, { condition = tex.in_mathzone }),
|
||||
s({ trig = "oo", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\infty"),
|
||||
}, { 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 = "=<", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\impliedby"),
|
||||
}, { 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 = "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("i\\hbar"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "hbar", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
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("\\otimes"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "op", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\oplus"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "od", wordTrig = false, snippetType = "autosnippet" }, {
|
||||
t("\\odot"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "not", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("\\not"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "par", wordTrig = false, snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("\\partial"),
|
||||
}, { 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("\\propto"),
|
||||
-- }, { condition = tex.in_mathzone }),
|
||||
s({ trig = "neg", snippetType = "autosnippet" }, {
|
||||
t("\\neg"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "nabla", snippetType = "autosnippet" }, {
|
||||
t("\\nabla"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = "jo", 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 }
|
||||
),
|
||||
}
|
||||
96
LuaSnip/tex/temporary.lua
Normal file
96
LuaSnip/tex/temporary.lua
Normal file
@@ -0,0 +1,96 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
local tex = require("util.latex")
|
||||
|
||||
local get_visual = function(args, parent)
|
||||
if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
return sn(nil, i(1, parent.snippet.env.SELECT_RAW))
|
||||
else -- If SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
-- s({ trig = "sp", snippetType = "autosnippet" }, fmta("\\hat{\\$}", {}), { condition = tex.in_mathzone }),
|
||||
-- s({ trig = "T", snippetType = "autosnippet" }, fmta("\\mathcal{T}", {}), { condition = tex.in_mathzone }),
|
||||
-- s({ trig = "tv", snippetType = "autosnippet" }, fmta("\\mathrm{TV}", {}), { condition = tex.in_mathzone }),
|
||||
-- s({ trig = "ce", snippetType = "autosnippet" }, fmta("\\mathrm{couple}", {}), { condition = tex.in_mathzone }),
|
||||
-- s({ trig = "mix", snippetType = "autosnippet" }, fmta("\\mathrm{mix}", {}), { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\psii", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\psi_i"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "FF", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\mathcal{F}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "SS", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\mathcal{S}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = "EE", snippetType = "autosnippet" },
|
||||
fmta("\\E_{\\sigma} \\ab[ <> ]", {
|
||||
i(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s({ trig = "\\varphii", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\varphi_i"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "cc", snippetType = "autosnippet" }, {
|
||||
t("^c"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "--", snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("^-"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\oplust", snippetType = "autosnippet", priority = 2000 }, {
|
||||
t("\\OPT"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "++", snippetType = "autosnippet" }, {
|
||||
t("^+"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "ii", snippetType = "autosnippet" }, {
|
||||
t("\\int"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "ed", snippetType = "autosnippet" }, {
|
||||
t("\\ed"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
-- s({ trig = "cas", snippetType = "autosnippet", priority = 2000 }, {
|
||||
-- t("\\cas"),
|
||||
-- }, { condition = tex.in_mathzone }),
|
||||
s({ trig = "lr", snippetType = "autosnippet" }, {
|
||||
t("\\leftrightarrow"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "sa", snippetType = "autosnippet" }, {
|
||||
t("s_A"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "sb", snippetType = "autosnippet" }, {
|
||||
t("s_B"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s(
|
||||
{ trig = "(%a);", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("\\hat{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
s({ trig = "\\psi;", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\tilde{\\psi}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "\\varphi;", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\tilde{\\varphi}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "IS", snippetType = "autosnippet", priority = 3000 }, {
|
||||
t("\\mathcal{IS}"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
}
|
||||
256
LuaSnip/tex/text.lua
Normal file
256
LuaSnip/tex/text.lua
Normal file
@@ -0,0 +1,256 @@
|
||||
local ls = require("luasnip")
|
||||
local c = ls.choice_node
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local tex = require("util.latex")
|
||||
local rep = require("luasnip.extras").rep
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "DeclareMathOperator" },
|
||||
fmta("\\DeclareMathOperator{\\<>}{<>}", {
|
||||
i(1),
|
||||
rep(1),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
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("\\quad\\text{s.t.}\\quad"),
|
||||
}, { 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(
|
||||
{ trig = "setc", snippetType = "autosnippet" },
|
||||
fmta("\\setcounter{<>}{<>}", {
|
||||
c(1, { t("exer"), t("theorem") }),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
s(
|
||||
{ trig = "PP", snippetType = "autosnippet" },
|
||||
fmta("\\section*{Problem <>}", { i(1) }),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
|
||||
-- s({ trig = "label", snippetType = "autosnippet" }, {
|
||||
-- t("\\label{"),
|
||||
-- i(0),
|
||||
-- t("}"),
|
||||
-- }, { condition = tex.in_text, show_condition = tex.in_text }),
|
||||
s(
|
||||
{ trig = "href", snippetType = "autosnippet" },
|
||||
fmta("\\href{<>}{<>}", {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
|
||||
s({ trig = "wlog", snippetType = "autosnippet" }, {
|
||||
t("without loss of generality"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "Wlog", snippetType = "autosnippet" }, {
|
||||
t("Without loss of generality"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "%%", snippetType = "autosnippet" }, {
|
||||
t("\\%"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "&&", snippetType = "autosnippet" }, {
|
||||
t("\\&"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "##", snippetType = "autosnippet" }, {
|
||||
t("\\#"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "thm", snippetType = "autosnippet" }, {
|
||||
t("theorem"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "propp", snippetType = "autosnippet" }, {
|
||||
t("proposition"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "deff", snippetType = "autosnippet" }, {
|
||||
t("definition"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "exaa", snippetType = "autosnippet" }, {
|
||||
t("example"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iee", snippetType = "autosnippet" }, {
|
||||
t("i.e."),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "stt", snippetType = "autosnippet" }, {
|
||||
t("such that"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iff", snippetType = "autosnippet" }, {
|
||||
t("if and only if"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iso" }, {
|
||||
t("isomorphic"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "iso" }, {
|
||||
t("isomorphism"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "homo" }, {
|
||||
t("homomorphism"),
|
||||
}, { condition = tex.in_text }),
|
||||
s({ trig = "homo" }, {
|
||||
t("homomorphic"),
|
||||
}, { condition = tex.in_text }),
|
||||
-- s({ trig = "psp", snippetType = "autosnippet" }, {
|
||||
-- t("\\(p\\)-subgroup"),
|
||||
-- }, { condition = tex.in_text }),
|
||||
-- s({ trig = "pgp", snippetType = "autosnippet" }, {
|
||||
-- t("\\(p\\)-subgroup"),
|
||||
-- }, { condition = tex.in_text }),
|
||||
-- s({ trig = "spsp", snippetType = "autosnippet" }, {
|
||||
-- t("Sylow \\(p\\)-subgroup"),
|
||||
-- }, { condition = tex.in_text }),
|
||||
s({ trig = "=>", snippetType = "autosnippet" }, {
|
||||
t("\\(\\implies\\)"),
|
||||
}, { condition = tex.in_text }),
|
||||
s(
|
||||
{ trig = "homework" },
|
||||
fmta(
|
||||
[[
|
||||
\documentclass{article}
|
||||
\newcommand{\Class}{<>}
|
||||
\newcommand{\Title}{Homework <>}
|
||||
\author{Hanyu Yan}
|
||||
\input{~/Documents/Latex/Package_elegantbook.tex}
|
||||
\input{~/Documents/Latex/Sample_Homework.tex}
|
||||
\begin{document}
|
||||
\maketitle \thispagestyle{empty}
|
||||
|
||||
<>
|
||||
|
||||
\end{document}
|
||||
]],
|
||||
{
|
||||
c(1, {
|
||||
t("Numerical Analysis"),
|
||||
t("Experimental Quantum Information Processing"),
|
||||
t("Quantum Communication and Cryptography"),
|
||||
}),
|
||||
i(2, "number"),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "note" },
|
||||
fmta(
|
||||
[[
|
||||
\documentclass[letterpaper, 12pt]{article}
|
||||
\input{~/Documents/Latex/note_template.tex}
|
||||
\begin{document}
|
||||
\title{<> \\[1em]
|
||||
\normalsize <>}
|
||||
\author{\normalsize Fireond}
|
||||
\date{\normalsize\vspace{-1ex} Last updated: \today}
|
||||
\maketitle
|
||||
\tableofcontents\label{sec:contents}
|
||||
|
||||
<>
|
||||
|
||||
\end{document}
|
||||
]],
|
||||
{
|
||||
i(1, "title"),
|
||||
i(2, "subtitle"),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "algo" },
|
||||
fmta(
|
||||
[[
|
||||
\documentclass[utf8]{article}
|
||||
\usepackage{amsmath,amssymb}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{fullpage}
|
||||
\usepackage{setspace}
|
||||
\usepackage{verbatim}
|
||||
\usepackage{algorithm}
|
||||
\usepackage{algpseudocodex}
|
||||
\algrenewcommand\algorithmicrequire{\textbf{Input:}}
|
||||
\algrenewcommand\algorithmicensure{\textbf{Output:}}
|
||||
\input{~/Documents/Latex/Package_elegantbook.tex}
|
||||
|
||||
\onehalfspacing
|
||||
|
||||
\title{\bf\huge Algorithm Design - Assignment <>}
|
||||
\author{Hanyu Yan\\2022010860\\Class 23}
|
||||
\date{\today}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
<>
|
||||
|
||||
\end{document}
|
||||
]],
|
||||
{ i(1), i(0) }
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "report" },
|
||||
fmta(
|
||||
[[
|
||||
%! TeX program = xelatex
|
||||
\documentclass{article}
|
||||
\newcommand{\Class}{<>}
|
||||
\newcommand{\Title}{<>}
|
||||
\author{严涵宇}
|
||||
\usepackage[UTF8]{ctex}
|
||||
\input{~/Documents/Latex/Package_elegantbook.tex}
|
||||
\input{~/Documents/Latex/Sample_Homework.tex}
|
||||
\begin{document}
|
||||
\maketitle \thispagestyle{empty}
|
||||
|
||||
<>
|
||||
|
||||
\end{document}
|
||||
]],
|
||||
{
|
||||
c(1, {
|
||||
t("量子信息实验报告"),
|
||||
}),
|
||||
i(2),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_text * line_begin }
|
||||
),
|
||||
}
|
||||
178
LuaSnip/tex/tikz.lua
Normal file
178
LuaSnip/tex/tikz.lua
Normal file
@@ -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 }
|
||||
),
|
||||
}
|
||||
4
README.md
Normal file
4
README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# 💤 LazyVim
|
||||
|
||||
A starter template for [LazyVim](https://github.com/LazyVim/LazyVim).
|
||||
Refer to the [documentation](https://lazyvim.github.io/installation) to get started.
|
||||
2
init.lua
Normal file
2
init.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
-- bootstrap lazy.nvim, LazyVim and your plugins
|
||||
require("config.lazy")
|
||||
70
lazy-lock.json
Normal file
70
lazy-lock.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"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" },
|
||||
"blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" },
|
||||
"blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" },
|
||||
"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" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
|
||||
"lean.nvim": { "branch": "main", "commit": "a9beb8c8d366362063088dad5c348f8848442f47" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
|
||||
"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" },
|
||||
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
|
||||
"nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" },
|
||||
"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-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" },
|
||||
"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" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
|
||||
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
|
||||
"ts-comments.nvim": { "branch": "main", "commit": "1bd9d0ba1d8b336c3db50692ffd0955fe1bb9f0c" },
|
||||
"vim-startuptime": { "branch": "master", "commit": "b6f0d93f6b8cf6eee0b4c94450198ba2d6a05ff6" },
|
||||
"vimtex": { "branch": "master", "commit": "7d16d56c765476f3101b2daa2a09f8ab82df9c5d" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" },
|
||||
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" },
|
||||
"yazi.nvim": { "branch": "main", "commit": "82873628a2b78dce48b5bcf8d1d8ed14f0ee985f" }
|
||||
}
|
||||
36
lazyvim.json
Normal file
36
lazyvim.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"extras": [
|
||||
"lazyvim.plugins.extras.ai.copilot",
|
||||
"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",
|
||||
"lazyvim.plugins.extras.editor.dial",
|
||||
"lazyvim.plugins.extras.editor.inc-rename",
|
||||
"lazyvim.plugins.extras.editor.overseer",
|
||||
"lazyvim.plugins.extras.editor.snacks_picker",
|
||||
"lazyvim.plugins.extras.formatting.black",
|
||||
"lazyvim.plugins.extras.lang.clangd",
|
||||
"lazyvim.plugins.extras.lang.json",
|
||||
"lazyvim.plugins.extras.lang.lean",
|
||||
"lazyvim.plugins.extras.lang.markdown",
|
||||
"lazyvim.plugins.extras.lang.python",
|
||||
"lazyvim.plugins.extras.lang.tex",
|
||||
"lazyvim.plugins.extras.lang.toml",
|
||||
"lazyvim.plugins.extras.lang.yaml",
|
||||
"lazyvim.plugins.extras.test.core",
|
||||
"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"
|
||||
},
|
||||
"version": 8
|
||||
}
|
||||
7
lua/config/autocmds.lua
Normal file
7
lua/config/autocmds.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
-- Add any additional autocmds here
|
||||
|
||||
if vim.g.neovide then
|
||||
vim.cmd([[ cd $HOME ]])
|
||||
end
|
||||
11
lua/config/keymaps.lua
Normal file
11
lua/config/keymaps.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
-- Add any additional keymaps here
|
||||
|
||||
local map = LazyVim.safe_keymap_set
|
||||
|
||||
map({ "i" }, "jk", "<Esc>")
|
||||
|
||||
-- movement
|
||||
map({ "n", "v", "o" }, "H", "^", { desc = "Use 'H' as '^'" })
|
||||
map({ "n", "v", "o" }, "L", "$", { desc = "Use 'L' as '$'" })
|
||||
52
lua/config/lazy.lua
Normal file
52
lua/config/lazy.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
-- bootstrap lazy.nvim
|
||||
-- stylua: ignore
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
|
||||
end
|
||||
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- import any extras modules here
|
||||
-- { import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
-- { import = "lazyvim.plugins.extras.lang.json" },
|
||||
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
|
||||
-- import/override with your plugins
|
||||
{ import = "plugins" },
|
||||
{ import = "plugins.ui" },
|
||||
{ import = "plugins.lang" },
|
||||
{ import = "plugins.default" },
|
||||
},
|
||||
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable for plugins that support semver
|
||||
},
|
||||
|
||||
install = { colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = { enabled = true }, -- automatically check for plugin updates
|
||||
performance = {
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
33
lua/config/options.lua
Normal file
33
lua/config/options.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
|
||||
vim.opt.timeoutlen = 150
|
||||
vim.opt.spell = true
|
||||
vim.opt.spelllang = { "en", "cjk" }
|
||||
vim.opt.spelloptions = "camel"
|
||||
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 <Tab> counts for while performing editing operations
|
||||
vim.opt.tabstop = indent -- Number of spaces tabs count for
|
||||
vim.opt.shiftwidth = indent -- Size of an indent
|
||||
|
||||
if vim.g.neovide then
|
||||
vim.o.guifont = "Maple Mono:h16"
|
||||
vim.g.neovide_scale_factor = 1.0
|
||||
vim.g.neovide_floating_corner_radius = 20.0
|
||||
vim.g.neovide_line_height = 1.5
|
||||
-- vim.g.transparency = 0.8
|
||||
-- vim.g.neovide_transparency = 0.9
|
||||
-- Allow clipboard copy paste in neovim
|
||||
vim.g.neovide_input_use_logo = 1
|
||||
vim.api.nvim_set_keymap("", "<D-v>", "+p<CR>", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap("!", "<D-v>", "<C-R>+", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap("t", "<D-v>", "<C-R>+", { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap("v", "<D-v>", "<C-R>+", { noremap = true, silent = true })
|
||||
end
|
||||
67
lua/plugins/coderunner.lua
Normal file
67
lua/plugins/coderunner.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
return {
|
||||
{
|
||||
"CRAG666/code_runner.nvim",
|
||||
ft = { "lua", "python", "c", "cpp" },
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
keys = {
|
||||
{ "<leader>rr", "<cmd>RunCode<cr>", desc = "Run Code" },
|
||||
-- { "<leader>rf", "<cmd>RunFile<cr>", desc = "Run File" },
|
||||
-- { "<leader>rp", "<cmd>RunProject<cr>", desc = "Run Project" },
|
||||
{ "<leader>rd", "<cmd>RunClose<cr>", desc = "Run Close" },
|
||||
},
|
||||
opts = {
|
||||
-- choose default mode (valid term, tab, float, toggle, buf)
|
||||
mode = "term",
|
||||
-- Focus on runner window(only works on toggle, term and tab mode)
|
||||
focus = false,
|
||||
-- startinsert (see ':h inserting-ex')
|
||||
startinsert = false,
|
||||
term = {
|
||||
-- Position to open the terminal, this option is ignored if mode is tab
|
||||
position = "bot",
|
||||
-- window size, this option is ignored if tab is true
|
||||
size = 8,
|
||||
},
|
||||
float = {
|
||||
-- Key that close the code_runner floating window
|
||||
close_key = "<ESC>",
|
||||
-- Window border (see ':h nvim_open_win')
|
||||
border = "none",
|
||||
|
||||
-- Num from `0 - 1` for measurements
|
||||
height = 0.8,
|
||||
width = 0.8,
|
||||
x = 0.5,
|
||||
y = 0.5,
|
||||
|
||||
-- Highlight group for floating window/border (see ':h winhl')
|
||||
border_hl = "FloatBorder",
|
||||
float_hl = "Normal",
|
||||
|
||||
-- Transparency (see ':h winblend')
|
||||
blend = 0,
|
||||
},
|
||||
filetype_path = "", -- No default path defined
|
||||
filetype = {
|
||||
javascript = "node",
|
||||
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
|
||||
c = "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
|
||||
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
|
||||
python = "python -u",
|
||||
sh = "bash",
|
||||
rust = "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
|
||||
},
|
||||
project_path = "", -- No default path defined
|
||||
project = {},
|
||||
},
|
||||
-- config = {
|
||||
-- filetype = {
|
||||
-- python = "python3 -u",
|
||||
-- },
|
||||
-- mode = "term",
|
||||
-- float = {
|
||||
-- close_key = "q",
|
||||
-- },
|
||||
-- },
|
||||
},
|
||||
}
|
||||
28
lua/plugins/competitest.lua
Normal file
28
lua/plugins/competitest.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
return {
|
||||
{
|
||||
"xeluxee/competitest.nvim",
|
||||
dependencies = "MunifTanjim/nui.nvim",
|
||||
lazy = false,
|
||||
keys = {
|
||||
{ "<localleader>rt", "<cmd>CompetiTest receive testcases<CR>", "Receive testcases" },
|
||||
{ "<localleader>rp", "<cmd>CompetiTest receive problem<CR>", "Receive problem" },
|
||||
{ "<localleader>rc", "<cmd>CompetiTest receive contest<CR>", "Receive contest" },
|
||||
{ "<localleader>c", "<cmd>CompetiTest run<CR>", "Run code" },
|
||||
},
|
||||
config = function()
|
||||
require("competitest").setup({
|
||||
received_problems_path = "$(HOME)/compcode/$(JUDGE)/$(CONTEST)/$(PROBLEM).$(FEXT)c",
|
||||
received_contests_directory = "$(HOME)/compcode/$(JUDGE)/$(CONTEST)",
|
||||
template_file = {
|
||||
cpp = "~/compcode/templates/template.cpp",
|
||||
},
|
||||
compile_command = {
|
||||
cpp = { exec = "clang++", args = { "$(FNAME)", "-o", "$(FNOEXT)", "-lm" } },
|
||||
},
|
||||
run_command = {
|
||||
cpp = { exec = "./$(FNOEXT)" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
20
lua/plugins/default/blink.lua
Normal file
20
lua/plugins/default/blink.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
return {
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
version = "*",
|
||||
opts = {
|
||||
-- sources = {
|
||||
-- compat = { "avante_commands", "avante_mentions", "avante_files" },
|
||||
-- },
|
||||
keymap = {
|
||||
["<C-j>"] = { "select_next", "fallback" },
|
||||
["<C-k>"] = { "select_prev", "fallback" },
|
||||
},
|
||||
completion = {
|
||||
menu = { border = "single" },
|
||||
documentation = { window = { border = "single" } },
|
||||
},
|
||||
signature = { window = { border = "single" } },
|
||||
},
|
||||
},
|
||||
}
|
||||
11
lua/plugins/default/conform.lua
Normal file
11
lua/plugins/default/conform.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
"stevearc/conform.nvim",
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
["json"] = { "jq" },
|
||||
["jsonc"] = { "jq" },
|
||||
["tex"] = { "latexindent" },
|
||||
["toml"] = { "taplo "},
|
||||
}
|
||||
}
|
||||
}
|
||||
15
lua/plugins/default/copilot.lua
Normal file
15
lua/plugins/default/copilot.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return {
|
||||
-- {
|
||||
-- "zbirenbaum/copilot.lua",
|
||||
-- opts = {
|
||||
-- copilot_model = "claude-3.7-sonnet",
|
||||
-- suggestion = {
|
||||
-- keymap = {
|
||||
-- accept = "<D-l>",
|
||||
-- next = "<D-]>",
|
||||
-- prev = "<D-[>",
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
24
lua/plugins/default/lspconfig.lua
Normal file
24
lua/plugins/default/lspconfig.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
optional = true,
|
||||
opts = {
|
||||
servers = {
|
||||
texlab = {
|
||||
keys = {
|
||||
{ "<Leader>K", "<plug>(vimtex-doc-package)", desc = "Vimtex Docs", silent = true },
|
||||
},
|
||||
settings = {
|
||||
texlab = {
|
||||
inlayHints = {
|
||||
labelDefinitions = false,
|
||||
labelReferences = false,
|
||||
},
|
||||
diagnostics = { ignoredPatterns = { "^Overfull", "^Underfull" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
70
lua/plugins/default/luasnip.lua
Normal file
70
lua/plugins/default/luasnip.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
return {
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
config = function()
|
||||
require("luasnip").config.set_config({
|
||||
enable_autosnippets = true,
|
||||
store_selection_keys = "`",
|
||||
})
|
||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/LuaSnip" })
|
||||
local auto_expand = require("luasnip").expand_auto
|
||||
require("luasnip").expand_auto = function(...)
|
||||
vim.o.undolevels = vim.o.undolevels
|
||||
auto_expand(...)
|
||||
end
|
||||
-- local types = require("luasnip.util.types")
|
||||
-- require("luasnip").config.setup({
|
||||
-- ext_opts = {
|
||||
-- [types.choiceNode] = {
|
||||
-- active = {
|
||||
-- virt_text = { { "●", "GruvboxOrange" } },
|
||||
-- },
|
||||
-- },
|
||||
-- [types.insertNode] = {
|
||||
-- active = {
|
||||
-- virt_text = { { "●", "GruvboxBlue" } },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- })
|
||||
end,
|
||||
keys = function()
|
||||
return {
|
||||
{
|
||||
"fj",
|
||||
function()
|
||||
return require("luasnip").expand_or_locally_jumpable() and "<Plug>luasnip-jump-next"
|
||||
-- or "<c-\\><c-n>:call searchpair('[([{<|]', '', '[)\\]}>|]', 'W')<cr>a"
|
||||
end,
|
||||
expr = true,
|
||||
silent = true,
|
||||
mode = "i",
|
||||
},
|
||||
{
|
||||
"fj",
|
||||
function()
|
||||
return require("luasnip").jump(1)
|
||||
end,
|
||||
mode = "s",
|
||||
},
|
||||
{
|
||||
"fk",
|
||||
function()
|
||||
require("luasnip").jump(-1)
|
||||
end,
|
||||
mode = { "i", "s" },
|
||||
},
|
||||
{
|
||||
"<c-h>",
|
||||
"<Plug>luasnip-next-choice",
|
||||
mode = { "i", "s" },
|
||||
},
|
||||
{
|
||||
"<c-p>",
|
||||
"<Plug>luasnip-prev-choice",
|
||||
mode = { "i", "s" },
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
22
lua/plugins/default/neotree.lua
Normal file
22
lua/plugins/default/neotree.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
return {
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
lazy = true,
|
||||
opts = {
|
||||
filesystem = {
|
||||
window = {
|
||||
mappings = {
|
||||
["o"] = "system_open",
|
||||
},
|
||||
},
|
||||
commands = {
|
||||
system_open = function(state)
|
||||
local node = state.tree:get_node()
|
||||
local path = node:get_id()
|
||||
vim.api.nvim_command("silent !open -g " .. path)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
59
lua/plugins/default/tree-sitter.lua
Normal file
59
lua/plugins/default/tree-sitter.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
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 = "<cr>",
|
||||
node_incremental = "<cr>",
|
||||
scope_incremental = "\\",
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
}
|
||||
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 {
|
||||
{ "<cr>", desc = "Increment selection" },
|
||||
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
61
lua/plugins/default/treesitter.lua
Normal file
61
lua/plugins/default/treesitter.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function()
|
||||
return {
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = { "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",
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<cr>",
|
||||
node_incremental = "<cr>",
|
||||
scope_incremental = "\\",
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
}
|
||||
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 {
|
||||
{ "<cr>", desc = "Increment selection" },
|
||||
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
6
lua/plugins/disabled.lua
Normal file
6
lua/plugins/disabled.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
return {
|
||||
{
|
||||
"rafamadriz/friendly-snippets",
|
||||
enabled = false,
|
||||
},
|
||||
}
|
||||
89
lua/plugins/lang/avante.lua
Normal file
89
lua/plugins/lang/avante.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
return {
|
||||
{
|
||||
"yetone/avante.nvim",
|
||||
event = "VeryLazy",
|
||||
enabled = false,
|
||||
version = false, -- Never set this value to "*"! Never!
|
||||
opts = {
|
||||
-- add any opts here
|
||||
-- for example
|
||||
-- provider = "copilot",
|
||||
-- copilot = { model = "claude-3.5-sonnet" },
|
||||
-- hints = { enabled = false },
|
||||
-- file_selector = {
|
||||
-- provider = "snack",
|
||||
-- provider_opts = {},
|
||||
-- },
|
||||
-- openai = {
|
||||
-- endpoint = "https://api.openai.com/v1",
|
||||
-- model = "gpt-4o", -- your desired model (or use gpt-4o, etc.)
|
||||
-- timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models
|
||||
-- temperature = 0,
|
||||
-- max_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models)
|
||||
-- --reasoning_effort = "medium", -- low|medium|high, only used for reasoning models
|
||||
-- },
|
||||
},
|
||||
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
|
||||
build = "make",
|
||||
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"stevearc/dressing.nvim",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"MunifTanjim/nui.nvim",
|
||||
--- The below dependencies are optional,
|
||||
-- "echasnovski/mini.pick", -- for file_selector provider mini.pick
|
||||
-- "nvim-telescope/telescope.nvim", -- for file_selector provider telescope
|
||||
-- "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
|
||||
-- "ibhagwan/fzf-lua", -- for file_selector provider fzf
|
||||
-- "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
|
||||
"zbirenbaum/copilot.lua", -- for providers='copilot'
|
||||
{
|
||||
-- support for image pasting
|
||||
"HakonHarnes/img-clip.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
-- recommended settings
|
||||
default = {
|
||||
embed_image_as_base64 = false,
|
||||
prompt_for_file_name = false,
|
||||
drag_and_drop = {
|
||||
insert_mode = true,
|
||||
},
|
||||
-- required for Windows users
|
||||
use_absolute_path = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
-- Make sure to set this up properly if you have lazy=true
|
||||
"MeanderingProgrammer/render-markdown.nvim",
|
||||
opts = {
|
||||
file_types = { "markdown", "Avante" },
|
||||
},
|
||||
ft = { "markdown", "Avante" },
|
||||
},
|
||||
{
|
||||
"saghen/blink.compat",
|
||||
lazy = true,
|
||||
opts = {},
|
||||
config = function()
|
||||
-- monkeypatch cmp.ConfirmBehavior for Avante
|
||||
require("cmp").ConfirmBehavior = {
|
||||
Insert = "insert",
|
||||
Replace = "replace",
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
lazy = true,
|
||||
opts = {
|
||||
sources = {
|
||||
compat = { "avante_commands", "avante_mentions", "avante_files" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
30
lua/plugins/lang/clangd.lua
Normal file
30
lua/plugins/lang/clangd.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
lazy = true,
|
||||
ft = { "c", "cpp" },
|
||||
opts = {
|
||||
servers = {
|
||||
clangd = {
|
||||
cmd = {
|
||||
"clangd",
|
||||
"--background-index",
|
||||
"--clang-tidy",
|
||||
"--cross-file-rename",
|
||||
"--clang-tidy-checks=performance-*,cppcoreguidelines-*,clang-analyzer-*,bugprone-*",
|
||||
"-j=12",
|
||||
"--all-scopes-completion",
|
||||
"--header-insertion=iwyu",
|
||||
"--query-driver=/usr/bin/clang,/usr/bin/clang++",
|
||||
"--fallback-style=llvm",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Civitasv/cmake-tools.nvim",
|
||||
lazy = true,
|
||||
ft = { "c", "cpp" },
|
||||
},
|
||||
}
|
||||
43
lua/plugins/lang/latex.lua
Normal file
43
lua/plugins/lang/latex.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
return {
|
||||
{
|
||||
"lervag/vimtex",
|
||||
lazy = false, -- lazy-loading will disable inverse search
|
||||
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_general_viewer = "open -a UPDF"
|
||||
vim.g.vimtex_view_skim_sync = 1
|
||||
vim.g.vimtex_compiler_silent = 1
|
||||
vim.g.vimtex_compiler_method = "latexmk"
|
||||
vim.g.vimtex_compiler_latexmk = {
|
||||
aux_dir = "./aux",
|
||||
out_dir = "",
|
||||
callback = 1,
|
||||
continuous = 1,
|
||||
executable = "latexmk",
|
||||
hooks = {},
|
||||
options = {
|
||||
-- "-c",
|
||||
"-verbose",
|
||||
"-file-line-error",
|
||||
"-synctex=1",
|
||||
"-interaction=nonstopmode",
|
||||
"--shell-escape",
|
||||
},
|
||||
}
|
||||
vim.g.vimtex_quickfix_ignore_filters = {
|
||||
"Underfull",
|
||||
"Overfull",
|
||||
"specifier changed to",
|
||||
"Token not allowed in a PDF string",
|
||||
"LaTeX Warning: Float too large for page",
|
||||
"contains only floats",
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"evesdropper/luasnip-latex-snippets.nvim",
|
||||
enabled = false,
|
||||
},
|
||||
}
|
||||
13
lua/plugins/lang/markdown.lua
Normal file
13
lua/plugins/lang/markdown.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
return {
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
opts = {
|
||||
linters = {
|
||||
markdownlint = {
|
||||
-- Disable line length check
|
||||
args = { "--disable", "MD013", "--" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
16
lua/plugins/lang/python.lua
Normal file
16
lua/plugins/lang/python.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
{
|
||||
"kmontocam/nvim-conda",
|
||||
ft = "python",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
keys = {
|
||||
{ "<leader>cv", "<cmd>CondaActivate<cr>", desc = "Conda environment" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
ft = "python",
|
||||
dependencies = { "nvim-neotest/neotest-python" },
|
||||
opts = { adapters = { "neotest-python" } },
|
||||
},
|
||||
}
|
||||
38
lua/plugins/leetcode.lua
Normal file
38
lua/plugins/leetcode.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
return {
|
||||
-- {
|
||||
-- "kawre/leetcode.nvim",
|
||||
-- build = ":TSUpdate html",
|
||||
-- dependencies = {
|
||||
-- "nvim-telescope/telescope.nvim",
|
||||
-- "nvim-lua/plenary.nvim", -- required by telescope
|
||||
-- "MunifTanjim/nui.nvim",
|
||||
--
|
||||
-- -- optional
|
||||
-- "nvim-treesitter/nvim-treesitter",
|
||||
-- "rcarriga/nvim-notify",
|
||||
-- "nvim-tree/nvim-web-devicons",
|
||||
-- },
|
||||
-- lazy = false,
|
||||
-- keys = {
|
||||
-- { "<localleader>kt", "<cmd>Leet test<CR>", desc = "Leet test" },
|
||||
-- { "<localleader>ks", "<cmd>Leet submit<CR>", desc = "Leet submit" },
|
||||
-- { "<localleader>kl", "<cmd>Leet lang<CR>", desc = "Leet lang" },
|
||||
-- { "<localleader>kp", "<cmd>Leet list<CR>", desc = "List problem" },
|
||||
-- },
|
||||
-- opts = {
|
||||
-- -- configuration goes here
|
||||
-- ---@type string
|
||||
-- arg = "leetcode.nvim",
|
||||
--
|
||||
-- ---@type lc.lang
|
||||
-- lang = "cpp",
|
||||
-- ---@type lc.storage
|
||||
-- storage = {
|
||||
-- home = vim.fn.stdpath("data") .. "/leetcode",
|
||||
-- cache = vim.fn.stdpath("cache") .. "/leetcode",
|
||||
-- },
|
||||
-- ---@type boolean
|
||||
-- logging = false,
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
4
lua/plugins/mason-workaround.lua
Normal file
4
lua/plugins/mason-workaround.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
return {
|
||||
{ "mason-org/mason.nvim", version = "^1.0.0" },
|
||||
{ "mason-org/mason-lspconfig.nvim", version = "^1.0.0" },
|
||||
}
|
||||
19
lua/plugins/ui/colorscheme.lua
Normal file
19
lua/plugins/ui/colorscheme.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
return {
|
||||
-- Lazy
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
priority = 1000,
|
||||
opts = {
|
||||
flavour = "mocha",
|
||||
-- transparent_background = true,
|
||||
},
|
||||
},
|
||||
-- somewhere in your config:
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "catppuccin",
|
||||
},
|
||||
},
|
||||
}
|
||||
21
lua/plugins/ui/transparent.lua
Normal file
21
lua/plugins/ui/transparent.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
return {
|
||||
-- {
|
||||
-- "xiyaowong/nvim-transparent",
|
||||
-- opts = {
|
||||
-- extra_groups = {
|
||||
-- "BufferLineTabClose",
|
||||
-- "BufferlineBufferSelected",
|
||||
-- "BufferLineFill",
|
||||
-- "BufferLineBackground",
|
||||
-- "BufferLineSeparator",
|
||||
-- "BufferLineIndicatorSelected",
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- {
|
||||
-- "rcarriga/nvim-notify",
|
||||
-- opts = {
|
||||
-- background_colour = "#000000",
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
31
lua/plugins/yazi.lua
Normal file
31
lua/plugins/yazi.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
---@type LazySpec
|
||||
return {
|
||||
{
|
||||
"mikavilpas/yazi.nvim",
|
||||
event = "VeryLazy",
|
||||
keys = {
|
||||
-- 👇 in this section, choose your own keymappings!
|
||||
{
|
||||
-- Open in the current working directory
|
||||
"<leader>fM",
|
||||
"<cmd>Yazi cwd<cr>",
|
||||
desc = "Open the file manager in nvim's working directory",
|
||||
},
|
||||
{
|
||||
-- NOTE: this requires a version of yazi that includes
|
||||
-- https://github.com/sxyazi/yazi/pull/1305 from 2024-07-18
|
||||
"<leader>fm",
|
||||
"<cmd>Yazi toggle<cr>",
|
||||
desc = "Resume the last yazi session",
|
||||
},
|
||||
},
|
||||
---@type YaziConfig
|
||||
opts = {
|
||||
-- if you want to open yazi instead of netrw, see below for more info
|
||||
open_for_directories = false,
|
||||
keymaps = {
|
||||
show_help = "<f1>",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
0
lua/util/empty_evilline.lua
Normal file
0
lua/util/empty_evilline.lua
Normal file
3
lua/util/init.lua
Normal file
3
lua/util/init.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
local M = {}
|
||||
|
||||
return M
|
||||
104
lua/util/latex.lua
Normal file
104
lua/util/latex.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
local M = {}
|
||||
|
||||
local MATH_NODES = {
|
||||
displayed_equation = true,
|
||||
inline_formula = true,
|
||||
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 bufnr = vim.api.nvim_get_current_buf()
|
||||
while node do
|
||||
if node:type() == "generic_environment" then
|
||||
local begin = node:child(0)
|
||||
local name = begin:field("name")
|
||||
if name[1] and vim.treesitter.get_node_text(name[1], bufnr, nil) == "{" .. env .. "}" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
node = node:parent()
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
M.in_env = function(env)
|
||||
local pos = vim.fn["vimtex#env#is_inside"](env)
|
||||
return pos[1] ~= 0 or pos[2] ~= 0
|
||||
end
|
||||
|
||||
M.in_mathzone = function()
|
||||
local ft = vim.bo.filetype
|
||||
if ft == "tex" then
|
||||
return vim.api.nvim_eval("vimtex#syntax#in_mathzone()") == 1
|
||||
elseif ft == "markdown" then
|
||||
return M.in_mathzone_md()
|
||||
end
|
||||
end
|
||||
|
||||
M.in_text = function()
|
||||
return not M.in_mathzone()
|
||||
end
|
||||
|
||||
M.in_item = function()
|
||||
return M.in_env("itemize") or M.in_env("enumerate")
|
||||
end
|
||||
M.in_bib = function()
|
||||
return M.in_env("thebibliography")
|
||||
end
|
||||
M.in_tikz = function()
|
||||
return M.in_env("tikzpicture")
|
||||
end
|
||||
M.in_quantikz = function()
|
||||
return M.in_env("quantikz")
|
||||
end
|
||||
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" }
|
||||
-- for _, file_type in ipairs(file_types) do
|
||||
-- local command = "rm " .. current_dir .. "/*." .. file_type
|
||||
-- vim.api.nvim_call_function("system", { command })
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- M.format = function()
|
||||
-- local current_file = vim.fn.expand("%:p")
|
||||
-- local latexindent = "latexindent -g /dev/null " .. current_file .. " -wd -l ~/Documents/Latex/latexindent.yaml"
|
||||
-- local build = "pdflatex " .. current_file
|
||||
-- vim.api.nvim_call_function("system", { build })
|
||||
-- vim.cmd("w")
|
||||
-- M.clean()
|
||||
-- vim.api.nvim_call_function("system", { latexindent })
|
||||
-- vim.cmd("e")
|
||||
-- vim.cmd("normal! zz")
|
||||
-- -- vim.cmd("TexlabForward")
|
||||
-- end
|
||||
--
|
||||
-- M.sympy_calc = function()
|
||||
-- local selected_text = vim.fn.getreg("v")
|
||||
-- print(selected_text)
|
||||
-- vim.api.nvim_out_write(selected_text)
|
||||
-- end
|
||||
|
||||
return M
|
||||
3
stylua.toml
Normal file
3
stylua.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 120
|
||||
Reference in New Issue
Block a user