1
0

FEAT: Adding java snippets

This commit is contained in:
Nigel Barink 2024-03-30 22:44:58 +01:00
parent 3b39bbec40
commit c367bc0150
Signed by: Nigel
GPG Key ID: 6893A31C2D84A9D2

23
lua/snippets/java.lua Normal file
View File

@ -0,0 +1,23 @@
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt
-- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md
return {
s(
"main",
fmt([[
static void main (){{
{a}
}}
]],
{a = i(1)}
)),
s("sout", fmt("System.out.println(\"{}\");", { i(1, "My message")})),
s("soutm", t("System.out.println(\"$CLASS_NAME$.$METHOD_NAME$\");")),
s("soutp", t("System.out.println(\"$FORMAT$\");")),
s("soutv", t("System.out.println(\"$EXPR_COPY$ = \" + $EXPR$);")),
}