updates
This commit is contained in:
parent
63bbeaca3b
commit
ce01469113
37 changed files with 1621 additions and 384 deletions
92
home-manager/modules/neovim/snippets/tex/delimiter.lua
Normal file
92
home-manager/modules/neovim/snippets/tex/delimiter.lua
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
-- Math context detection
|
||||
local tex = {}
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
tex.in_text = function()
|
||||
return not tex.in_mathzone()
|
||||
end
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
-- LEFT/RIGHT PARENTHESES
|
||||
s(
|
||||
{ trig = "([^%a])l%(", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\left(<>\\right)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- LEFT/RIGHT SQUARE BRACES
|
||||
s(
|
||||
{ trig = "([^%a])l%[", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\left[<>\\right]", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- LEFT/RIGHT CURLY BRACES
|
||||
s(
|
||||
{ trig = "([^%a])l%{", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\left\\{<>\\right\\}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- BIG PARENTHESES
|
||||
s(
|
||||
{ trig = "([^%a])b%(", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\big(<>\\big)", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- BIG SQUARE BRACES
|
||||
s(
|
||||
{ trig = "([^%a])b%[", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\big[<>\\big]", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- BIG CURLY BRACES
|
||||
s(
|
||||
{ trig = "([^%a])b%{", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\big\\{<>\\big\\}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- ESCAPED CURLY BRACES
|
||||
s(
|
||||
{ trig = "([^%a])\\%{", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("<>\\{<>\\}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- LATEX QUOTATION MARK
|
||||
s(
|
||||
{ trig = "``", snippetType = "autosnippet" },
|
||||
fmta("``<>''", {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
}
|
||||
221
home-manager/modules/neovim/snippets/tex/environments.lua
Normal file
221
home-manager/modules/neovim/snippets/tex/environments.lua
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
-- Math context detection
|
||||
local tex = {}
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
tex.in_text = function()
|
||||
return not tex.in_mathzone()
|
||||
end
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
-- GENERIC ENVIRONMENT
|
||||
s(
|
||||
{ trig = "new", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
d(2, get_visual),
|
||||
rep(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "def", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{definition}[<>]
|
||||
<>
|
||||
\end{definition}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
d(2, get_visual),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- ENVIRONMENT WITH ONE EXTRA ARGUMENT
|
||||
s(
|
||||
{ trig = "n2", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
d(3, get_visual),
|
||||
rep(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- ENVIRONMENT WITH TWO EXTRA ARGUMENTS
|
||||
s(
|
||||
{ trig = "n3", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}{<>}{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
i(3),
|
||||
d(4, get_visual),
|
||||
rep(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- TOPIC ENVIRONMENT (my custom tcbtheorem environment)
|
||||
s(
|
||||
{ trig = "nt", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{topic}{<>}{<>}
|
||||
<>
|
||||
\end{topic}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
d(3, get_visual),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- EQUATION
|
||||
s(
|
||||
{ trig = "nn", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{equation*}
|
||||
<>
|
||||
\end{equation*}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- SPLIT EQUATION
|
||||
s(
|
||||
{ trig = "ss", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{equation*}
|
||||
\begin{split}
|
||||
<>
|
||||
\end{split}
|
||||
\end{equation*}
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- ALIGN
|
||||
s(
|
||||
{ trig = "all", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{align*}
|
||||
<>
|
||||
\end{align*}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- ITEMIZE
|
||||
s(
|
||||
{ trig = "itt", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{itemize}
|
||||
|
||||
\item <>
|
||||
|
||||
\end{itemize}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- ENUMERATE
|
||||
s(
|
||||
{ trig = "enn", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{enumerate}
|
||||
|
||||
\item <>
|
||||
|
||||
\end{enumerate}
|
||||
]],
|
||||
{
|
||||
i(0),
|
||||
}
|
||||
)
|
||||
),
|
||||
-- INLINE MATH
|
||||
s(
|
||||
{ trig = "([^%l])mm", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>$<>$", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- INLINE MATH ON NEW LINE
|
||||
s(
|
||||
{ trig = "^mm", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("$<>$", {
|
||||
i(1),
|
||||
})
|
||||
),
|
||||
-- FIGURE
|
||||
s(
|
||||
{ trig = "fig" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{figure}[htb!]
|
||||
\centering
|
||||
\includegraphics[width=<>\linewidth]{<>}
|
||||
\caption{<>}
|
||||
\label{fig:<>}
|
||||
\end{figure}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
i(3),
|
||||
i(4),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
}
|
||||
106
home-manager/modules/neovim/snippets/tex/fonts.lua
Normal file
106
home-manager/modules/neovim/snippets/tex/fonts.lua
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
-- A logical OR of `line_begin` and the regTrig '[^%a]trig'
|
||||
function line_begin_or_non_letter(line_to_cursor, matched_trigger)
|
||||
local line_begin = line_to_cursor:sub(1, -(#matched_trigger + 1)):match("^%s*$")
|
||||
local non_letter = line_to_cursor:sub(-(#matched_trigger + 1), -(#matched_trigger + 1)):match("[^%a]")
|
||||
return line_begin or non_letter
|
||||
end
|
||||
|
||||
-- Math context detection
|
||||
local tex = {}
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
tex.in_text = function()
|
||||
return not tex.in_mathzone()
|
||||
end
|
||||
|
||||
local line_begin = function(line_to_cursor, matched_trigger)
|
||||
-- +1 because `string.sub("abcd", 1, -2)` -> abc
|
||||
return line_to_cursor:sub(1, -(#matched_trigger + 1)):match("^%s*$")
|
||||
end
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
-- TYPEWRITER i.e. \texttt
|
||||
s(
|
||||
{ trig = "([^%a])tt", regTrig = true, wordTrig = false, snippetType = "autosnippet", priority = 2000 },
|
||||
fmta("<>\\texttt{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_text }
|
||||
),
|
||||
-- ITALIC i.e. \textit
|
||||
s(
|
||||
{ trig = "([^%a])tii", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\textit{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- BOLD i.e. \textbf
|
||||
s(
|
||||
{ trig = "tbb", snippetType = "autosnippet" },
|
||||
fmta("\\textbf{<>}", {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- MATH ROMAN i.e. \mathrm
|
||||
s(
|
||||
{ trig = "([^%a])rmm", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\mathrm{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- MATH CALIGRAPHY i.e. \mathcal
|
||||
s(
|
||||
{ trig = "([^%a])mcc", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\mathcal{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- MATH BOLDFACE i.e. \mathbf
|
||||
s(
|
||||
{ trig = "([^%a])mbf", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\mathbf{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- MATH BLACKBOARD i.e. \mathbb
|
||||
s(
|
||||
{ trig = "([^%a])mbb", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\mathbb{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- REGULAR TEXT i.e. \text (in math environments)
|
||||
s(
|
||||
{ trig = "([^%a])tee", regTrig = true, wordTrig = false, snippetType = "autosnippet" },
|
||||
fmta("<>\\text{<>}", {
|
||||
f(function(_, snip)
|
||||
return snip.captures[1]
|
||||
end),
|
||||
d(1, get_visual),
|
||||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
}
|
||||
19
home-manager/modules/neovim/snippets/tex/luatex.lua
Normal file
19
home-manager/modules/neovim/snippets/tex/luatex.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
-- tex.sprint
|
||||
s(
|
||||
{ trig = "tpp", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
tex.sprint(<>)
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
}
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
local ls = require("luasnip")
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local r = ls.restore_node
|
||||
-- Math context detection
|
||||
local tex = {}
|
||||
-- local function in_mathzone() return vim.api.nvim_eval('vimtex#syntax#in_mathzone()') == 1 end
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
|
|
@ -10,8 +14,31 @@ tex.in_text = function()
|
|||
return not tex.in_mathzone()
|
||||
end
|
||||
|
||||
tex.generate_matrix = function(args, snip)
|
||||
local rows = tonumber(snip.captures[2])
|
||||
local cols = tonumber(snip.captures[3])
|
||||
local nodes = {}
|
||||
local ins_indx = 1
|
||||
for j = 1, rows do
|
||||
table.insert(nodes, r(ins_indx, tostring(j) .. "x1", i(1)))
|
||||
ins_indx = ins_indx + 1
|
||||
for k = 2, cols do
|
||||
table.insert(nodes, t(" & "))
|
||||
table.insert(nodes, r(ins_indx, tostring(j) .. "x" .. tostring(k), i(1)))
|
||||
ins_indx = ins_indx + 1
|
||||
end
|
||||
table.insert(nodes, t({ "\\\\", "" }))
|
||||
end
|
||||
-- fix last node.
|
||||
nodes[#nodes] = t("\\\\")
|
||||
return sn(nil, nodes)
|
||||
end
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
s({ trig = "vton", snippetType = "autosnippet" }, {
|
||||
t("\\vec{v}_1, \\cdots, \\vec{v}_n"),
|
||||
}),
|
||||
-- SUPERSCRIPT
|
||||
s(
|
||||
{ trig = "([%w%)%]%}])'", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
|
||||
|
|
@ -397,6 +424,15 @@ return {
|
|||
}),
|
||||
{ condition = tex.in_mathzone }
|
||||
),
|
||||
|
||||
-- { trig = "([^%a])lim", wordTrig = false, regTrig = true, snippetType = "autosnippet" },
|
||||
-- fmta("<>\\lim_{<>}", {
|
||||
-- f(function(_, snip)
|
||||
-- return snip.captures[1]
|
||||
-- end),
|
||||
-- }),
|
||||
-- { condition = tex.in_mathzone }
|
||||
-- ),
|
||||
--
|
||||
-- BEGIN STATIC SNIPPETS
|
||||
--
|
||||
|
|
@ -489,4 +525,36 @@ return {
|
|||
s({ trig = "xx", snippetType = "autosnippet" }, {
|
||||
t("\\times "),
|
||||
}),
|
||||
s(
|
||||
{
|
||||
trig = "([bBpvV])mat(%d+)x(%d+)([ar])",
|
||||
name = "[bBpvV]matrix",
|
||||
dscr = "matrices",
|
||||
regTrig = true,
|
||||
hidden = true,
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}<>
|
||||
<>
|
||||
\end{<>}]],
|
||||
{
|
||||
f(function(_, snip)
|
||||
return snip.captures[1] .. "matrix"
|
||||
end),
|
||||
f(function(_, snip)
|
||||
if snip.captures[4] == "a" then
|
||||
out = string.rep("c", tonumber(snip.captures[3]) - 1)
|
||||
return "[" .. out .. "|c]"
|
||||
end
|
||||
return ""
|
||||
end),
|
||||
d(1, tex.generate_matrix),
|
||||
f(function(_, snip)
|
||||
return snip.captures[1] .. "matrix"
|
||||
end),
|
||||
}
|
||||
),
|
||||
{ condition = tex.in_math, show_condition = tex.in_math }
|
||||
),
|
||||
}
|
||||
|
|
|
|||
58
home-manager/modules/neovim/snippets/tex/static.lua
Normal file
58
home-manager/modules/neovim/snippets/tex/static.lua
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
-- Environment/syntax context detection
|
||||
local tex = {}
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
tex.in_text = function()
|
||||
return not tex.in_mathzone()
|
||||
end
|
||||
tex.in_tikz = function()
|
||||
local is_inside = vim.fn["vimtex#env#is_inside"]("tikzpicture")
|
||||
return (is_inside[1] > 0 and is_inside[2] > 0)
|
||||
end
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
s({ trig = "q" }, {
|
||||
t("\\quad "),
|
||||
}),
|
||||
s({ trig = "qq", snippetType = "autosnippet" }, {
|
||||
t("\\qquad "),
|
||||
}),
|
||||
s({ trig = "npp", snippetType = "autosnippet" }, {
|
||||
t({ "\\newpage", "" }),
|
||||
}, { condition = line_begin }),
|
||||
s({ trig = "which", snippetType = "autosnippet" }, {
|
||||
t("\\text{ for which } "),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "all", snippetType = "autosnippet" }, {
|
||||
t("\\text{ for all } "),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "and", snippetType = "autosnippet" }, {
|
||||
t("\\quad \\text{and} \\quad"),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "forall", snippetType = "autosnippet" }, {
|
||||
t("\\text{ for all } "),
|
||||
}, { condition = tex.in_mathzone }),
|
||||
s({ trig = "toc", snippetType = "autosnippet" }, {
|
||||
t("\\tableofcontents"),
|
||||
}, { condition = line_begin }),
|
||||
s({ trig = "inff", snippetType = "autosnippet" }, {
|
||||
t("\\infty"),
|
||||
}),
|
||||
s({ trig = "ii", snippetType = "autosnippet" }, {
|
||||
t("\\item "),
|
||||
}, { condition = line_begin }),
|
||||
s(
|
||||
{ trig = "--", snippetType = "autosnippet" },
|
||||
{ t("% --------------------------------------------- %") },
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- HLINE WITH EXTRA VERTICAL SPACE
|
||||
s({ trig = "hl" }, { t("\\hline {\\rule{0pt}{2.5ex}} \\hspace{-7pt}") }, { condition = line_begin }),
|
||||
}
|
||||
192
home-manager/modules/neovim/snippets/tex/system.lua
Normal file
192
home-manager/modules/neovim/snippets/tex/system.lua
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
-- Math context detection
|
||||
local tex = {}
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
tex.in_text = function()
|
||||
return not tex.in_mathzone()
|
||||
end
|
||||
|
||||
-- Return snippet tables
|
||||
return {
|
||||
-- ANNOTATE (custom command for annotating equation derivations)
|
||||
s(
|
||||
{ trig = "ann", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\annotate{<>}{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
d(2, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
-- REFERENCE
|
||||
s(
|
||||
{ trig = " RR", snippetType = "autosnippet", wordTrig = false },
|
||||
fmta(
|
||||
[[
|
||||
~\ref{<>}
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
-- DOCUMENTCLASS
|
||||
s(
|
||||
{ trig = "dcc", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[=[
|
||||
\documentclass[<>]{<>}
|
||||
]=],
|
||||
{
|
||||
i(1, "a4paper"),
|
||||
i(2, "article"),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- USE A LATEX PACKAGE
|
||||
s(
|
||||
{ trig = "pack", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\usepackage{<>}
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- INPUT a LaTeX file
|
||||
s(
|
||||
{ trig = "inn", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\input{<><>}
|
||||
]],
|
||||
{
|
||||
i(1, "~/dotfiles/config/latex/templates/"),
|
||||
i(2),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
-- LABEL
|
||||
s(
|
||||
{ trig = "lbl", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\label{<>}
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
-- HPHANTOM
|
||||
s(
|
||||
{ trig = "hpp", snippetType = "autosnippet" },
|
||||
fmta(
|
||||
[[
|
||||
\hphantom{<>}
|
||||
]],
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "TODOO", snippetType = "autosnippet" },
|
||||
fmta([[\TODO{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "nc" },
|
||||
fmta([[\newcommand{<>}{<>}]], {
|
||||
i(1),
|
||||
i(2),
|
||||
}),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
s(
|
||||
{ trig = "sii", snippetType = "autosnippet" },
|
||||
fmta([[\si{<>}]], {
|
||||
i(1),
|
||||
})
|
||||
),
|
||||
s(
|
||||
{ trig = "qtt" },
|
||||
fmta([[\qty{<>}{<>}]], {
|
||||
i(1),
|
||||
i(2),
|
||||
})
|
||||
),
|
||||
-- URL
|
||||
s(
|
||||
{ trig = "url" },
|
||||
fmta([[\url{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- href command with URL in visual selection
|
||||
s(
|
||||
{ trig = "LU", snippetType = "autosnippet" },
|
||||
fmta([[\href{<>}{<>}]], {
|
||||
d(1, get_visual),
|
||||
i(2),
|
||||
})
|
||||
),
|
||||
-- href command with text in visual selection
|
||||
s(
|
||||
{ trig = "LL", snippetType = "autosnippet" },
|
||||
fmta([[\href{<>}{<>}]], {
|
||||
i(1),
|
||||
d(2, get_visual),
|
||||
})
|
||||
),
|
||||
-- HSPACE
|
||||
s(
|
||||
{ trig = "hss", snippetType = "autosnippet" },
|
||||
fmta([[\hspace{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- VSPACE
|
||||
s(
|
||||
{ trig = "vss", snippetType = "autosnippet" },
|
||||
fmta([[\vspace{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- SECTION
|
||||
s(
|
||||
{ trig = "h1", snippetType = "autosnippet" },
|
||||
fmta([[\section{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- SUBSECTION
|
||||
s(
|
||||
{ trig = "h2", snippetType = "autosnippet" },
|
||||
fmta([[\subsection{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
-- SUBSUBSECTION
|
||||
s(
|
||||
{ trig = "h3", snippetType = "autosnippet" },
|
||||
fmta([[\subsubsection{<>}]], {
|
||||
d(1, get_visual),
|
||||
})
|
||||
),
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
|
||||
|
||||
\begin{align*}
|
||||
|
||||
\end{align*}
|
||||
84
home-manager/modules/neovim/snippets/tex/tmp.lua
Normal file
84
home-manager/modules/neovim/snippets/tex/tmp.lua
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
local helpers = require("personal.luasnip-helper-funcs")
|
||||
local get_visual = helpers.get_visual
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
-- Math context detection
|
||||
local tex = {}
|
||||
tex.in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
tex.in_text = function()
|
||||
return not tex.in_mathzone()
|
||||
end
|
||||
|
||||
return {
|
||||
|
||||
-- Equation, choice for labels
|
||||
s(
|
||||
{
|
||||
trig = "beq",
|
||||
dscr = "Expands 'beq' into an equation environment, with a choice for labels",
|
||||
snippetType = "autosnippet",
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{equation}<>
|
||||
<>
|
||||
\end{equation}
|
||||
]],
|
||||
{
|
||||
c(1, {
|
||||
sn(
|
||||
2, -- Choose to specify an equation label
|
||||
{
|
||||
t("\\label{eq:"),
|
||||
i(1),
|
||||
t("}"),
|
||||
}
|
||||
),
|
||||
t([[]]), -- Choose no label
|
||||
}, {}),
|
||||
i(2),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
-- Figure environment
|
||||
s(
|
||||
{ trig = "foofig", dscr = "Use 'fig' for figure environmennt, with options" },
|
||||
fmta(
|
||||
[[
|
||||
\begin{figure}<>
|
||||
\centering
|
||||
\includegraphics<>{<>}
|
||||
\caption{<>}
|
||||
\label{fig:<>}
|
||||
\end{figure}
|
||||
]],
|
||||
{
|
||||
-- Optional [htbp] field
|
||||
c(1, {
|
||||
t([[]]), -- Choice 1, empty
|
||||
t("[htbp]"), -- Choice 2, this may be turned into a snippet
|
||||
}, {}),
|
||||
-- Options for includegraphics
|
||||
c(2, {
|
||||
t([[]]), -- Choice 1, empty
|
||||
sn(
|
||||
3, -- Choice 2, this may be turned into a snippet
|
||||
{
|
||||
t("[width="),
|
||||
i(1),
|
||||
t("\\textwidth]"),
|
||||
}
|
||||
),
|
||||
}, {}),
|
||||
i(3, "filename"),
|
||||
i(4, "text"),
|
||||
i(5, "label"),
|
||||
}
|
||||
),
|
||||
{ condition = line_begin }
|
||||
),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue