Skip to content

Commit 12401bd

Browse files
committed
Add LaTeX snippets and auto-session plugin configuration
1 parent 950ddeb commit 12401bd

File tree

12 files changed

+5083
-45
lines changed

12 files changed

+5083
-45
lines changed

lazy-lock.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{
2-
"LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" },
2+
"LuaSnip": { "branch": "master", "commit": "0f7bbce41ea152a94d12aea286f2ce98e63c0f58" },
3+
"auto-session": { "branch": "main", "commit": "8d2eddb14ef66ed1019c92251e2d31bb7a2a2f87" },
34
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
45
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
56
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
6-
"conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" },
7+
"conform.nvim": { "branch": "master", "commit": "f1125f8eace158255cf55772ce039aaf178a6b42" },
78
"fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" },
89
"friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" },
9-
"gitsigns.nvim": { "branch": "main", "commit": "9521fe8be39255b9abc6ec54e352bf04c410f5cf" },
10-
"lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" },
10+
"gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" },
11+
"lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" },
1112
"lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" },
12-
"luasnip-latex-snippets.nvim": { "branch": "main", "commit": "4b91f28d91979f61a3e8aef1cee5b7c7f2c7beb8" },
13-
"luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
14-
"mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" },
13+
"luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" },
14+
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
15+
"mason-lspconfig.nvim": { "branch": "main", "commit": "43894adcf10bb1190c2184bd7c1750e8ea2b3dce" },
1516
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
1617
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
17-
"mini.nvim": { "branch": "main", "commit": "7b4d5d48b6b5a75009d63f8f3e4ef4819b7e8139" },
18-
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
19-
"nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" },
20-
"nvim-treesitter": { "branch": "master", "commit": "e1e3108cd23d7f967842261bd66126b6734d8907" },
18+
"mini.nvim": { "branch": "main", "commit": "6714e738555b1cfbef646a23af29aa113f91f4fe" },
19+
"nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
20+
"nvim-cmp": { "branch": "main", "commit": "40a03dc225383c4f6256596c2cdf27e03b8119b5" },
21+
"nvim-lspconfig": { "branch": "master", "commit": "f012c1b176f0e3c71f40eb309bdec0316689462e" },
22+
"nvim-treesitter": { "branch": "master", "commit": "a3a732107f8b529f97bf4921b3e1af5dcc756bb6" },
2123
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
2224
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
2325
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
2426
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
2527
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
26-
"tokyonight.nvim": { "branch": "main", "commit": "9758827c3b380ba89da4a2212b6255d01afbcf08" },
28+
"tokyonight.nvim": { "branch": "main", "commit": "c2725eb6d086c8c9624456d734bd365194660017" },
2729
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
2830
"vimtex": { "branch": "master", "commit": "6ee92c7ed2cdc876f499bd5561a65d04dee10d1f" },
2931
"which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" }

lua/custom/plugins/Luasnip/tex/delimiters.lua.bak renamed to lua/custom/plugins/Luasnip/tex/delimiters.lua

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,31 @@ local f = ls.function_node
66
local fmt = require("luasnip.extras.fmt").fmt
77

88
-- Add LaTeX snippets
9-
ls.add_snippets("tex", {
10-
-- LaTeX Template
11-
s("latex-template", fmt([[
12-
\documentclass[a4paper]{article}
13-
14-
\usepackage{amsmath}
15-
16-
\begin{document}
17-
{}
18-
\end{document}
19-
]], { i(0) })),
20-
9+
return { -- [[
2110
-- Implies
22-
s("=>", t("\\implies")),
11+
s({trig="=>", snippetType="autosnippet"},
12+
{
13+
t("\\implies")
14+
}),
2315

2416
-- Inline Math
25-
s("mk", fmt("${}$", { i(1) })),
17+
s({trig="mk", snippetType="autosnippet"}, fmt("${}$", { i(1) })),
2618

27-
-- Fraction with auto-expansion for a/b pattern
28-
s("////", fmt("\\frac{{{}}}{{{}}}", { i(1), i(2) })),
29-
s({ trig = "(%w+)/(%w+)", regTrig = true, wordTrig = false }, {
30-
f(function(_, snip) return "\\frac{" .. snip.captures[1] .. "}{" .. snip.captures[2] .. "}" end)
31-
}),
3219

3320
-- Not Equals
34-
s("!=", t("\\neq")),
21+
s({trig="!=",snippetType="autosnippet"}, t("\\neq")),
3522

3623
-- Sum
37-
s("sum", fmt("\\sum_{{n={}}}^{{{}}} {}", { i(1, "1"), i(2, "\\infty"), i(3, "a_n z^n") })),
24+
s({trig="sum",snippetType="autosnippet"}, fmt("\\sum_{{n={}}}^{{{}}} {}", { i(1, "1"), i(2, "\\infty"), i(3, "a_n z^n") })),
3825

3926
-- Taylor Series
40-
s("taylor", fmt("\\sum_{{{}={}}}^{{{}}} {} (x-a)^{}", { i(1, "k"), i(2, "0"), i(3, "\\infty"), i(4, "c_"), i(1) })),
27+
s({trig="taylor",snippetType="autosnippet"}, fmt("\\sum_{{{}={}}}^{{{}}} {} (x-a)^{}", { i(1, "k"), i(2, "0"), i(3, "\\infty"), i(4, "c_"), i(1) })),
4128

4229
-- Limit
43-
s("lim", fmt("\\lim_{{{} \\to {}}}", { i(1, "n"), i(2, "\\infty") })),
30+
s({trig="lim",snippetType="autosnippet"}, fmt("\\lim_{{{} \\to {}}}", { i(1, "n"), i(2, "\\infty") })),
4431

32+
s({trig="xx",snippetType="autosnippet"}, t("\\times")),
33+
--[[
4534
-- Greek Letters
4635
s("alpha", t("\\alpha")),
4736
s("beta", t("\\beta")),
@@ -133,10 +122,10 @@ ls.add_snippets("tex", {
133122
134123
-- Miscellaneous Symbols
135124
s("del", t("\\nabla")),
136-
s("xx", t("\\times")),
137125
s("avg", fmt("\\langle {} \\rangle", { i(1) })),
138126
s("norm", fmt("\\lvert {} \\rvert", { i(1) })),
139127
s("ceil", fmt("\\lceil {} \\rceil", { i(1) })),
140128
s("floor", fmt("\\lfloor {} \\rfloor", { i(1) }))
141-
})
129+
]]--
130+
}
142131

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
local ls = require("luasnip")
2+
local s = ls.snippet
3+
local t = ls.text_node
4+
local i = ls.insert_node
5+
local f = ls.function_node
6+
local fmt = require("luasnip.extras.fmt").fmt
7+
8+
return {
9+
10+
11+
-- Tabular material
12+
13+
s({trig = "tab", name = "Table environment"},
14+
{
15+
t("\\begin{table}["), i(1,"opt"), t("]"),
16+
t({"",""}), t("\\begin{tabular}{"), i(2,"cols"), t("}"),
17+
t({"",""}), t(" "), i(3),
18+
t({"",""}), t("\\end{tabular}"),
19+
t({"",""}), t("\\end{table}")
20+
}
21+
),
22+
23+
s({trig = "rr", name = "Array environment"},
24+
{
25+
t("\\begin{array}{"), i(1,"cols"), t("}"),
26+
t({"",""}), t(" "), i(2),
27+
t({"",""}), t("\\end{array}")
28+
}
29+
),
30+
31+
s({trig = "he", name = "Break line height"},
32+
{
33+
t("\\\\["), i(1), t("]"),
34+
t({"",""})
35+
}
36+
),
37+
38+
s({trig = "hyp", name = "Hyphenate text correctly"},
39+
{
40+
t("\\hspace{0pt}")
41+
}
42+
),
43+
44+
s({trig = "bck", name = "Redefine \\\\ last column"},
45+
{
46+
t("\\arraybackslash")
47+
}
48+
),
49+
50+
s({trig = "lt", name = "Align text to left"},
51+
{
52+
t("\\raggedleft")
53+
}
54+
),
55+
56+
s({trig = "cr", name = "Align text to center"},
57+
{
58+
t("\\centering")
59+
}
60+
),
61+
62+
s({trig = "rt", name = "Align text to right"},
63+
{
64+
t("\\raggedright")
65+
}
66+
),
67+
68+
s({trig = "hn", name = "Horizontal line"},
69+
{
70+
t("\\hline"),
71+
t({"",""})
72+
}
73+
),
74+
75+
s({trig = "br", name = "Tabular row break"},
76+
{
77+
t("\\\\"),
78+
t({"",""}), i(1)
79+
}
80+
),
81+
82+
-- Tabular environment preamble options
83+
84+
s({trig = "pc", name = "Top column"},
85+
{
86+
t("p{"), i(1,"width"), t("}")
87+
}
88+
),
89+
90+
s({trig = "cop", name = "num copies of opts"},
91+
{
92+
t("*{"), i(1,"num"), t("}{"), i(2,"opts"), t("}")
93+
}
94+
),
95+
96+
s({trig = "mc", name = "Vertically centered column"},
97+
{
98+
t("m{"), i(1,"width"), t("}")
99+
}
100+
),
101+
102+
s({trig = "bc", name = "Bottom column"},
103+
{
104+
t("b{"), i(1,"width"), t("}")
105+
}
106+
),
107+
108+
s({trig = "bl", name = "Before column options"},
109+
{
110+
t(">{"), i(1,"decl"), t("}")
111+
}
112+
),
113+
114+
s({trig = "af", name = "After column options"},
115+
{
116+
t("<{"), i(1,"decl"), t("}")
117+
}
118+
),
119+
120+
-- Floats
121+
122+
s({trig = "cpt", name = "Caption"},
123+
{
124+
c(1,
125+
{
126+
{
127+
t("\\caption{"), i(1,"text"), t("}")
128+
},
129+
{
130+
t("\\caption["), i(1,"list-entry"), t("]{"), i(2,"text"), t("}")
131+
}
132+
}
133+
)
134+
}
135+
),
136+
137+
s({trig = "cof", name = "Caption of"},
138+
{
139+
c(1,
140+
{
141+
{
142+
t("\\captionof{"), i(1,"type"), t("}{"), i(2,"text"), t("}")
143+
},
144+
{
145+
t("\\captionof{"), i(1,"type"), t("}["), i(2,"list-entry"), t("]{"), i(3,"text"), t("}")
146+
},
147+
{
148+
t("\\captionof*{"), i(1,"type"), t("}{"), i(2,"text"), t("}")
149+
}
150+
}
151+
)
152+
}
153+
),
154+
155+
s({trig = "sbf", name = "Subfloat"},
156+
{
157+
c(1,
158+
{
159+
{
160+
t("\\subfloat{"), i(1,"object"), t("}")
161+
},
162+
{
163+
t("\\subfloat["), i(1,"caption"), t("]{"), i(2,"object"), t("}")
164+
},
165+
{
166+
t("\\subfloat["), i(1,"list-entry"), t("]["), i(2,"caption"), t("]{"), i(3,"object"), t("}")
167+
}
168+
}
169+
)
170+
}
171+
),
172+
173+
s({trig = "snt", name = "Sub-numbers for tables"},
174+
{
175+
t("\\begin{subtables}"),
176+
t({"",""}), t(" "), i(1),
177+
t({"",""}), t("\\end{subtables}")
178+
}
179+
),
180+
181+
s({trig = "snf", name = "Sub-numbers for figures"},
182+
{
183+
t("\\begin{subfigures}"),
184+
t({"",""}), t(" "), i(1),
185+
t({"",""}), t("\\end{subfigures}")
186+
}
187+
),
188+
189+
}

0 commit comments

Comments
 (0)