put common luasnip functions in a seperate file and modify some
java snippets
This commit is contained in:
3
lua/core/snippets/functions.lua
Normal file
3
lua/core/snippets/functions.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function file_name(args, parent, user_args)
|
||||||
|
return vim.fn.expand("%:t:r")
|
||||||
|
end
|
@ -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(" ") }),
|
||||||
|
Reference in New Issue
Block a user