put common luasnip functions in a seperate file and modify some

java snippets
This commit is contained in:
2024-11-19 13:42:05 -06:00
parent 4d2163e9e6
commit f29241021d
2 changed files with 16 additions and 6 deletions

View File

@ -0,0 +1,3 @@
function file_name(args, parent, user_args)
return vim.fn.expand("%:t:r")
end

View File

@ -1,8 +1,5 @@
require('core.snippets.shorthands') require('core.snippets.shorthands')
require('core.snippets.functions')
local function file_name(args, parent, user_args)
return vim.fn.expand("%:t:r")
end
return { return {
-- method snippet -- method snippet
@ -34,6 +31,12 @@ return {
t({ "", "}" }), t({ "", "}" }),
}), }),
s("main", {
t({ "public static void main(String[] args) {", "\t" }),
i(0),
t({ "", "}" }),
}),
-- constructor snippet -- constructor snippet
s("constr", { s("constr", {
c(1, { c(1, {
@ -59,14 +62,18 @@ return {
c(1, { c(1, {
t("public "), t("public "),
t("private "), t("private "),
t("protected ") t("protected "),
t("")
}), }),
c(2, { c(2, {
t("class "), t("class "),
t("interface ") t("interface ")
}), }),
f(file_name, {}),
c(3, { c(3, {
i(0, "MyClass"),
f(file_name, {})
}),
c(4, {
t(" "), t(" "),
sn(nil, { t({" implements "}), i(1), t(" ") }), sn(nil, { t({" implements "}), i(1), t(" ") }),
sn(nil, { t({" extends "}), i(1), t(" ") }), sn(nil, { t({" extends "}), i(1), t(" ") }),