combine function and main snippet into one (c)

This commit is contained in:
2024-11-28 22:30:02 -05:00
parent c4a86fb727
commit 3bf7dd1be4

View File

@ -19,8 +19,19 @@ return {
}),
-- function snippet
s("fn", {
s({ trig = [[fn\|main]], trigEngine = "vim" }, {
d(1, function(_, snip)
if snip.trigger == "main" then
return sn(nil, {
t({ "int", "main(int argc, char *argv[])" })
})
else
return sn(nil, {
c(1, {
t(""),
t("static "),
}),
c(2, {
t("void"),
t("char"),
t("int"),
@ -31,16 +42,20 @@ return {
i(nil, "myType"),
}),
t({ "", "" }),
c(2, {
c(3, {
t(""),
t("*")
}),
i(3, "myFunc");
i(4, "myFunc");
t("("),
i(4),
i(5),
t(")"),
})
end
end, {}),
t({ "", "{", "\t" }),
i(0),
t({ "", "}" }),
t({ "", "}" })
}),
})
}