feat: re-add snippets
This commit is contained in:
parent
b3102f091f
commit
a373856ad5
4 changed files with 337 additions and 14 deletions
|
|
@ -37,12 +37,12 @@
|
|||
"null-ls.nvim": { "branch": "main", "commit": "689cdd78f70af20a37b5309ebc287ac645ae4f76" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "7cd39409e7378fa711624687d3b430b8a56c3af9" },
|
||||
"nvim-dap": { "branch": "master", "commit": "fd291e970aa7c46ba2c49448f7d2c94cc7828f4e" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "bf9f0c4768ce8cb99ac0b99cf06ae6f91c906a1a" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "bdb94e3853d11b5ce98ec182e5a3719d5c0ef6fd" },
|
||||
"nvim-dap-virtual-text": { "branch": "master", "commit": "8db23ea51203b5f00ad107a0cef7e0b2d7a0476c" },
|
||||
"nvim-highlight-colors": { "branch": "main", "commit": "af051bfe2971fc888d21cdfc59f5444904353b43" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "91998cef4b1ae3a624901d0f9c894409db24e760" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "69e2fe3d638566a812c39bc4ea1980f7b833e2fc" },
|
||||
"nvim-navic": { "branch": "master", "commit": "7e9d2b2b601149fecdccd11b516acb721e571fe6" },
|
||||
"nvim-notify": { "branch": "master", "commit": "bdd647f61a05c9b8a57c83b78341a0690e9c29d7" },
|
||||
"nvim-notify": { "branch": "master", "commit": "9c987081390753b625e2d94e749e80e9b4a3e082" },
|
||||
"nvim-spectre": { "branch": "master", "commit": "ce73d505fdc45f16c1a04f6a98c1c1e114841708" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "454876fc6d25a699178cb66aeda4014dedb765f3" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "2f3583001e2bf793480f38cf0d055571787b0259" },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,60 @@
|
|||
return {
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
version = false, -- last release is way too old
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
||||
},
|
||||
opts = function()
|
||||
local cmp = require("cmp")
|
||||
return {
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert",
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<Tab>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<S-Tab>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(_, item)
|
||||
local icons = require("lazyvim.config").icons.kinds
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
return item
|
||||
end,
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = {
|
||||
hl_group = "LspCodeLens",
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
lazy = true,
|
||||
dependencies = {
|
||||
|
|
@ -10,5 +66,7 @@ return {
|
|||
format_kinds(entry, item)
|
||||
return require("tailwindcss-colorizer-cmp").formatter(entry, item)
|
||||
end
|
||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
55
nvim/snippets/.texsnippetsold
Normal file
55
nvim/snippets/.texsnippetsold
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
snippet mini \minipg{}{}[]
|
||||
\\minipg{
|
||||
$1
|
||||
}
|
||||
{${2}}[${3}]
|
||||
|
||||
snippet graphics \includegraphics[]{}
|
||||
\\includegraphics[scale=$1]{${2}}
|
||||
|
||||
snippet code "code"
|
||||
\\begin{lstlisting}
|
||||
$1
|
||||
\\end{lstlisting}
|
||||
|
||||
snippet list "list"
|
||||
\\begin{itemize}
|
||||
\\item \\textcolor{${1}}{${2}}
|
||||
\\item \\textcolor{${1}}{${3}}
|
||||
\\item \\textcolor{${1}}{${4}}
|
||||
\\item \\textcolor{${1}}{${5}}
|
||||
\\vspace{-3mm}
|
||||
\\end{itemize}
|
||||
|
||||
snippet enum "enumerate"
|
||||
\\begin{enumerate}
|
||||
\\item \textcolor{${1}}{${2}}
|
||||
\\item \textcolor{${1}}{${3}}
|
||||
\\item \textcolor{${1}}{${4}}
|
||||
\\item \textcolor{${1}}{${5}}
|
||||
\\vspace{-3mm}
|
||||
\\end{enumerate}
|
||||
|
||||
snippet table "table"
|
||||
\\begin{table}[ht!]
|
||||
\\section{${1}}
|
||||
\\begin{tabular}{|m{0.2\linewidth}|m{0.755\linewidth}|}
|
||||
\hline
|
||||
$2
|
||||
\hline
|
||||
\\end{tabular}
|
||||
\\end{table}
|
||||
|
||||
snippet tabular "tabular"
|
||||
\\begin{tabular}{|m{0.2\linewidth}|m{0.755\linewidth}|}
|
||||
\hline
|
||||
$1
|
||||
\hline
|
||||
\\end{tabular}
|
||||
|
||||
snippet tx "textcolor"
|
||||
\\textcolor{${1}}{${2}}
|
||||
|
||||
snippet bm "vectormatrix"
|
||||
\\begin{bmatrix} $1 \\ $2 \\ $3 \end{bmatrix}
|
||||
210
nvim/snippets/tex.lua
Normal file
210
nvim/snippets/tex.lua
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
local ls = require("luasnip")
|
||||
-- some shorthands...
|
||||
local s = ls.s
|
||||
local i = ls.i
|
||||
local t = ls.t
|
||||
local d = ls.dynamic_node
|
||||
local c = ls.choice_node
|
||||
local f = ls.function_node
|
||||
local sn = ls.snippet_node
|
||||
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local rep = require("luasnip.extras").rep
|
||||
|
||||
local snippets, autosnippets = {}, {}
|
||||
local group = vim.api.nvim_create_augroup("Tex Snippets", { clear = true })
|
||||
local file_pattern = "*.tex"
|
||||
------------------------------------------------- boilerplate end
|
||||
-- snippers go here:
|
||||
|
||||
local formSnippet = s(
|
||||
"form-",
|
||||
fmt(
|
||||
[[
|
||||
\, \newline
|
||||
\large \textcolor{{purple}}{{\( {1} \)}}\newline
|
||||
\, \newline
|
||||
\normalsize Legend: \newline
|
||||
\begin{{itemize}}
|
||||
\item {2}
|
||||
\item {3}
|
||||
\item {4}
|
||||
\item {5}
|
||||
\end{{itemize}}
|
||||
]],
|
||||
{
|
||||
i(1, "formula"),
|
||||
i(2, "item 1"),
|
||||
i(3, "item 2"),
|
||||
i(4, "item 3"),
|
||||
i(5, "item 4"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, formSnippet)
|
||||
|
||||
local listSnippet = s(
|
||||
"list-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{itemize}}
|
||||
\item \textcolor{{{1}}}{{{5}}}
|
||||
\item \textcolor{{{2}}}{{{6}}}
|
||||
\item \textcolor{{{3}}}{{{7}}}
|
||||
\item \textcolor{{{4}}}{{{8}}}
|
||||
\end{{itemize}}
|
||||
]],
|
||||
{
|
||||
i(1, "color"),
|
||||
rep(1),
|
||||
rep(1),
|
||||
rep(1),
|
||||
i(2, "item 1"),
|
||||
i(3, "item 2"),
|
||||
i(4, "item 3"),
|
||||
i(5, "item 4"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, listSnippet)
|
||||
|
||||
local enumerateSnippet = s(
|
||||
"enum-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{enumerate}}
|
||||
\item \textcolor{{{1}}}{{{5}}}
|
||||
\item \textcolor{{{2}}}{{{6}}}
|
||||
\item \textcolor{{{3}}}{{{7}}}
|
||||
\item \textcolor{{{4}}}{{{8}}}
|
||||
\end{{enumerate}}
|
||||
]],
|
||||
{
|
||||
i(1, "color"),
|
||||
rep(1),
|
||||
rep(1),
|
||||
rep(1),
|
||||
i(2, "item 1"),
|
||||
i(3, "item 2"),
|
||||
i(4, "item 3"),
|
||||
i(5, "item 4"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, enumerateSnippet)
|
||||
|
||||
local tableSnippet = s(
|
||||
"table-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{table}}[ht!]
|
||||
\section{{{}}}
|
||||
\begin{{tabular}}{{|m{{0.2\linewidth}}|m{{0.755\linewidth}}|}}
|
||||
\hline
|
||||
{}
|
||||
\hline
|
||||
\end{{tabular}}
|
||||
\end{{table}}
|
||||
]],
|
||||
{
|
||||
i(1, "Section Name"),
|
||||
i(2, "data....."),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, tableSnippet)
|
||||
|
||||
local tabularSnippet = s(
|
||||
"tabular-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{tabular}}{{|m{{0.2\linewidth}}|m{{0.755\linewidth}}|}}
|
||||
\hline
|
||||
{}
|
||||
\hline
|
||||
\end{{tabular}}
|
||||
]],
|
||||
{
|
||||
i(1, "data....."),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, tabularSnippet)
|
||||
|
||||
local textcolorSnippet = s(
|
||||
"tx-",
|
||||
fmt(
|
||||
[[
|
||||
\textcolor{{{1}}}{{{2}}}
|
||||
]],
|
||||
{
|
||||
i(1, "color"),
|
||||
i(2, "text..."),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, textcolorSnippet)
|
||||
|
||||
local boldSnippet = s(
|
||||
"bold-",
|
||||
fmt(
|
||||
[[
|
||||
\textbf{{{1}}}
|
||||
]],
|
||||
{
|
||||
i(1, "text..."),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, boldSnippet)
|
||||
|
||||
local minipgSnippet = s(
|
||||
"mini-",
|
||||
fmt(
|
||||
[[
|
||||
\minipg{{
|
||||
{1}
|
||||
}}{{
|
||||
{2}
|
||||
}}[{3}]
|
||||
]],
|
||||
{
|
||||
i(1, "data..."),
|
||||
i(2, "data..."),
|
||||
i(3, "0.25,0.25"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, minipgSnippet)
|
||||
|
||||
local graphicSnippet = s(
|
||||
"graph-",
|
||||
fmt(
|
||||
[[
|
||||
\includegraphics[scale={1}]{{{2}}}
|
||||
]],
|
||||
{
|
||||
i(1, "0.4"),
|
||||
i(2, "something.png"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, graphicSnippet)
|
||||
|
||||
local lstSnippet = s(
|
||||
"code-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{lstlisting}}
|
||||
{}
|
||||
\end{{lstlisting}}
|
||||
]],
|
||||
{
|
||||
i(1, "data"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, lstSnippet)
|
||||
|
||||
------------------------------------------------- snippets end
|
||||
return snippets, autosnippets
|
||||
Loading…
Add table
Add a link
Reference in a new issue