[nvim] fix: snippets config

This commit is contained in:
David JULIEN 2022-04-29 00:20:18 +02:00
parent 6581d9af42
commit 6fd5067bc4
3 changed files with 367 additions and 368 deletions

View File

@ -20,8 +20,7 @@ local f = ls.function_node
local copy = utils.copy local copy = utils.copy
ls.snippets = { ls.add_snippets( "c", {
c = {
s("main", { s("main", {
t({ "int main(int argc, char* argv[])" }), t({ "int main(int argc, char* argv[])" }),
t({ "", "{", "\t" }), t({ "", "{", "\t" }),
@ -47,5 +46,6 @@ ls.snippets = {
t({ "", "\treturn 0;"}), t({ "", "\treturn 0;"}),
t({ "", "}"}), t({ "", "}"}),
}), }),
}, }, {
} key = "c"
})

View File

@ -44,8 +44,7 @@ local function rec_ls()
) )
end end
ls.snippets = { ls.add_snippets("tex", {
tex = {
-- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many -- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many
-- \item as necessary by utilizing a choiceNode. -- \item as necessary by utilizing a choiceNode.
s("ls", { s("ls", {
@ -125,5 +124,6 @@ ls.snippets = {
i(1), i(1),
t({ "}"}), t({ "}"}),
}), }),
}, }, {
} key = "tex"
})

View File

@ -59,15 +59,13 @@ local function date_input(fmt)
return sn(nil, i(1, os.date(fmt))) return sn(nil, i(1, os.date(fmt)))
end end
ls.snippets = { -- snippets are added via ls.add_snippets(filetype, snippets[, opts]), where
-- When trying to expand a snippet, luasnip first searches the tables for -- opts may specify the `type` of the snippets ("snippets" or "autosnippets",
-- each filetype specified in 'filetype' followed by 'all'. -- for snippets that should expand directly after the trigger is typed).
-- If ie. the filetype is 'lua.c' --
-- - luasnip.lua -- opts can also specify a key. By passing an unique key to each add_snippets, it's possible to reload snippets by
-- - luasnip.c -- re-`:luafile`ing the file in which they are defined (eg. this one).
-- - luasnip.all ls.add_snippets( "all", {
-- are searched in that order.
all = {
-- trigger is fn. -- trigger is fn.
s("fn", { s("fn", {
-- Simple static text. -- Simple static text.
@ -321,8 +319,9 @@ ls.snippets = {
"fmt6", "fmt6",
fmt("use {} only", { t("this"), t("not this") }, { strict = false }) fmt("use {} only", { t("this"), t("not this") }, { strict = false })
), ),
}, }, {
} key = "all",
})
-- autotriggered snippets have to be defined in a separate table, luasnip.autosnippets. -- autotriggered snippets have to be defined in a separate table, luasnip.autosnippets.
ls.autosnippets = { ls.autosnippets = {