[nvim] feat: c snippets

This commit is contained in:
David JULIEN 2021-12-09 16:47:22 +01:00
parent 9f940e19da
commit f35c6599c0

View File

@ -3,7 +3,49 @@
-- License : GPLv3 -- License : GPLv3
-- Description : c settings file -- Description : c settings file
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
opt.formatoptions = "trq1jp" opt.formatoptions = "trq1jp"
-- Snippets
local ls = require("luasnip")
-- some shorthands...
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local copy = utils.copy
ls.snippets = {
c = {
s("main", {
t({ "int main(int argc, char* argv[])" }),
t({ "", "{", "\t" }),
i(0),
t({ "", "\treturn 0;"}),
t({ "", "}"}),
}),
s("fn", {
-- Simple static text.
t("//Parameters: "),
-- function, first parameter is the function, second the Placeholders
-- whose text it gets as input.
f(copy, 2),
t({ "", "" }),
-- Placeholder/Insert.
i(1),
t("("),
-- Placeholder with initial text.
i(2, "int foo"),
-- Linebreak
t({ ")", "{", "\t" }),
i(0),
t({ "", "\treturn 0;"}),
t({ "", "}"}),
}),
},
}