yes there's a bit of java in my nvim config why do you ask?
This commit is contained in:
48
lua/snippets/c.lua
Normal file
48
lua/snippets/c.lua
Normal file
@ -0,0 +1,48 @@
|
||||
require('core.snippets.shorthands')
|
||||
|
||||
return {
|
||||
-- method snippet
|
||||
s("main", {
|
||||
c(1, {
|
||||
t(""),
|
||||
t("static "),
|
||||
}),
|
||||
t("int "),
|
||||
t("main"),
|
||||
t("("),
|
||||
c(2, {
|
||||
t("int argc, char *argv[]"),
|
||||
i(1, "void"),
|
||||
}),
|
||||
t(")"),
|
||||
t({ " {", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- function snippet
|
||||
s("fn", {
|
||||
c(1, {
|
||||
t("void"),
|
||||
t("char"),
|
||||
t("int"),
|
||||
t("short"),
|
||||
t("long"),
|
||||
t("double"),
|
||||
t("float"),
|
||||
i(nil, "myType"),
|
||||
}),
|
||||
t({ "", "" }),
|
||||
c(2, {
|
||||
t(""),
|
||||
t("*")
|
||||
}),
|
||||
i(3, "myFunc");
|
||||
t("("),
|
||||
i(4),
|
||||
t(")"),
|
||||
t({ "", "{", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
})
|
||||
}
|
110
lua/snippets/java.lua
Normal file
110
lua/snippets/java.lua
Normal file
@ -0,0 +1,110 @@
|
||||
require('core.snippets.shorthands')
|
||||
|
||||
local function file_name(args, parent, user_args)
|
||||
return vim.fn.expand("%:t:r")
|
||||
end
|
||||
|
||||
return {
|
||||
-- method snippet
|
||||
s("fn", {
|
||||
c(1, {
|
||||
t("public "),
|
||||
t("private "),
|
||||
}),
|
||||
c(2, {
|
||||
t("void"),
|
||||
t("String"),
|
||||
t("char"),
|
||||
t("int"),
|
||||
t("double"),
|
||||
t("boolean"),
|
||||
i(nil, "myType"),
|
||||
}),
|
||||
t(" "),
|
||||
i(3, "myFunc"),
|
||||
t("("),
|
||||
i(4),
|
||||
t(")"),
|
||||
c(5, {
|
||||
t(""),
|
||||
sn(nil, {t({ "", " throws " }), i(1)}),
|
||||
}),
|
||||
t({ " {", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- constructor snippet
|
||||
s("constr", {
|
||||
c(1, {
|
||||
t("public "),
|
||||
t("private "),
|
||||
t("protected ")
|
||||
}),
|
||||
f(file_name, {}),
|
||||
t("("),
|
||||
i(2),
|
||||
t(")"),
|
||||
c(3, {
|
||||
t(""),
|
||||
sn(nil, {t({ "", " throws " }), i(1)}),
|
||||
}),
|
||||
t({ " {", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- class snippet
|
||||
s("class", {
|
||||
c(1, {
|
||||
t("public "),
|
||||
t("private "),
|
||||
t("protected ")
|
||||
}),
|
||||
c(2, {
|
||||
t("class "),
|
||||
t("interface ")
|
||||
}),
|
||||
f(file_name, {}),
|
||||
c(3, {
|
||||
t(" "),
|
||||
sn(nil, { t({" implements "}), i(1), t(" ") }),
|
||||
sn(nil, { t({" extends "}), i(1), t(" ") }),
|
||||
}),
|
||||
t({ "{", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- pacakge snippet
|
||||
s("package", {
|
||||
t("package "),
|
||||
f(function(args, parent, user_args)
|
||||
-- get path
|
||||
local dir = vim.fn.expand("%:h")
|
||||
-- remove prefix
|
||||
dir = dir:gsub("src/main/java/", "")
|
||||
-- convert to package path
|
||||
dir = dir:gsub("/", ".")
|
||||
|
||||
return dir
|
||||
end, {}),
|
||||
t(";"),
|
||||
t({ "", "", "" })
|
||||
}),
|
||||
|
||||
-- try, catch, finally snippet
|
||||
s("try", {
|
||||
t({"try {", "\t"}),
|
||||
i(1),
|
||||
t({"", "} catch ("}),
|
||||
i(2, "Error e"),
|
||||
t({") {", "\t"}),
|
||||
i(3),
|
||||
t({"", "}"}),
|
||||
c(4, {
|
||||
t(""),
|
||||
sn(nil, { t({" finally {", "\t"}), i(1), t({"", "}"}) })
|
||||
})
|
||||
})
|
||||
}
|
47
lua/snippets/make.lua
Normal file
47
lua/snippets/make.lua
Normal file
@ -0,0 +1,47 @@
|
||||
require('core.snippets.shorthands')
|
||||
|
||||
return {
|
||||
-- basic make template snippet
|
||||
s("make", {
|
||||
t({ "PKG_CONFIG = pkg-config", "CC = cc", "VERSION = " }),
|
||||
i(1, "0.1"),
|
||||
t({ "", "", "# flags and incs", "PKGS = " }),
|
||||
i(2),
|
||||
t({ "", "CFLAGS = -DVERSION=\\\"$(VERSION)\\\" -Wall" }),
|
||||
i(3),
|
||||
t({ "", "LIBS = `$(PKG_CONFIG) --libs --cflags $(PKGS)`" }),
|
||||
i(4),
|
||||
t({ "", "", "PREFIX = " }),
|
||||
i(5, "/usr/local"),
|
||||
t({ "", "MANDIR = $(PREFIX)/share/man" }),
|
||||
t({ "", "", "all: " }),
|
||||
i(6, "main"),
|
||||
t({ "", "" }),
|
||||
rep(6),
|
||||
t(": "),
|
||||
rep(6),
|
||||
t({ ".o", "\t$(CC) *.o $(CFLAGS) $(LIBS) -o $@", "" }),
|
||||
rep(6),
|
||||
t(".o: "),
|
||||
rep(6),
|
||||
t({ ".c", "", "clean:", "\trm -f " }),
|
||||
rep(6),
|
||||
t({ " *.o", "", "install: " }),
|
||||
rep(6),
|
||||
t({ "", "\tmkdir -p $(PREFIX)/bin", "\tcp -f " }),
|
||||
rep(6),
|
||||
t({ " $(PREFIX)/bin", "\tchmod 755 $(PREFIX)/bin/" }),
|
||||
rep(6),
|
||||
t({ "", "\tmkdir -p $(MANDIR)/man1", "\tcp -f " }),
|
||||
rep(6),
|
||||
t({ ".1 $(MANDIR)/man1", "\tchmod 644 $(MANDIR)/man1/" }),
|
||||
rep(6),
|
||||
t({ ".1", "", "uninstall: " }),
|
||||
rep(6),
|
||||
t({ "", "\trm -f $(PREFIX)/bin/" }),
|
||||
rep(6),
|
||||
t(" $(MANDIR)/man1/"),
|
||||
rep(6),
|
||||
t(".1")
|
||||
})
|
||||
}
|
28
lua/snippets/norg.lua
Normal file
28
lua/snippets/norg.lua
Normal file
@ -0,0 +1,28 @@
|
||||
require('core.snippets.shorthands')
|
||||
|
||||
local function file_name(args, parent, user_args)
|
||||
return vim.fn.expand("%:t:r")
|
||||
end
|
||||
|
||||
return {
|
||||
-- header level 1, usually this has the same name as the file
|
||||
s("h1", {
|
||||
t("* "),
|
||||
c(1, {
|
||||
f(file_name, {}),
|
||||
i(1, "header")
|
||||
})
|
||||
}),
|
||||
|
||||
-- link snippet
|
||||
s("link", {
|
||||
t("{"),
|
||||
c(1, {
|
||||
sn(nil, { t({":$/"}), i(1, "path to file"), t(":") }),
|
||||
i(1, "https://example.com")
|
||||
}),
|
||||
t("}["),
|
||||
i(2, "description"),
|
||||
t("]")
|
||||
})
|
||||
}
|
40
lua/snippets/openscad.lua
Normal file
40
lua/snippets/openscad.lua
Normal file
@ -0,0 +1,40 @@
|
||||
require('core.snippets.shorthands')
|
||||
|
||||
return {
|
||||
-- translate snippet
|
||||
s("t", {
|
||||
t("translate([ "),
|
||||
i(1, "0"),
|
||||
t(", "),
|
||||
i(2, "0"),
|
||||
t(", "),
|
||||
i(3, "0"),
|
||||
t({ " ]) {", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- rotate snippet
|
||||
s("r", {
|
||||
t("rotate([ "),
|
||||
i(1, "0"),
|
||||
t(", "),
|
||||
i(2, "0"),
|
||||
t(", "),
|
||||
i(3, "0"),
|
||||
t({ " ]) {", "\t" }),
|
||||
i(0),
|
||||
t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- cube snippet
|
||||
s("c", {
|
||||
t("cube([ "),
|
||||
i(1, "0"),
|
||||
t(", "),
|
||||
i(2, "0"),
|
||||
t(", "),
|
||||
i(3, "0"),
|
||||
t(" ]);")
|
||||
}),
|
||||
}
|
9
lua/snippets/php.lua
Normal file
9
lua/snippets/php.lua
Normal file
@ -0,0 +1,9 @@
|
||||
require('core.snippets.shorthands')
|
||||
|
||||
return {
|
||||
s("php", {
|
||||
t({ "<?php", "\t" }),
|
||||
i(1),
|
||||
t({ "", "?>" })
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user