diff options
| author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-03-11 14:13:33 +0100 | 
|---|---|---|
| committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-03-11 14:13:33 +0100 | 
| commit | 775ef96ee5f4bad6db681064924d7d047f1d438b (patch) | |
| tree | 2d182e5feda2dfcb89082e288d50221027234787 /config/essentials | |
| parent | afd843b48cceca0f879bf026b5523c481ccebcdc (diff) | |
added more java snippets
Diffstat (limited to 'config/essentials')
| -rw-r--r-- | config/essentials/nvim/after/plugin/luasnip.lua | 71 | 
1 files changed, 51 insertions, 20 deletions
diff --git a/config/essentials/nvim/after/plugin/luasnip.lua b/config/essentials/nvim/after/plugin/luasnip.lua index 276854c..1a00e80 100644 --- a/config/essentials/nvim/after/plugin/luasnip.lua +++ b/config/essentials/nvim/after/plugin/luasnip.lua @@ -27,7 +27,7 @@ local parse = require("luasnip.util.parser").parse_snippet  -- keymaps  vim.keymap.set({"i", "s"}, "<C-k>", "<Plug>luasnip-expand-or-jump", { noremap = true })  vim.keymap.set({"i", "s"}, "<C-j>", "<Plug>luasnip-jump-prev", { noremap = true }) -vim.keymap.set({"i", "s"}, "<C-l>", "<Plug>luasnip-next-choice", { noremap = true }) +vim.keymap.set({"i", "s"}, "<C-h>", "<Plug>luasnip-next-choice", { noremap = true })  vim.keymap.set("n", "<leader><leader>s", function()  	ls.cleanup()  	vim.cmd("source ~/.config/nvim/after/plugin/luasnip.lua") @@ -49,10 +49,10 @@ ls.add_snippets("lua", {  		[[  		function {}({})  			{} -		end +		end{}  		]], -    { i(1), i(2), i(3) } -	), i(0)), +    { i(1), i(2), i(3), i(0) })), +	parse("sn", "s(\"$1\", fmt(\n[[\n$2\n]],\n{ $3 })),$0", {}),  })  ls.add_snippets("html", { @@ -71,49 +71,80 @@ ls.add_snippets("java", {  	-- function  	s("fn", fmt(  	[[ -	{}static {} {} ({}) {{ +	{}{} {} ({}) {{  		{}  	}}  	]],  	{ -		c(1, {t "", t "public ", t "private "}), +		c(1, {t "public ", t "private ", t ""}),  		i(2, "type"),  		i(3, "f"),  		i(4), i(0)  	})), +	-- constructor +	s("cst", fmt( +	[[ +	public {} ({}) {{ +		{} +	}}{} +	]], +	{ i(1), i(2), i(3), i(0) })),  	-- setter function  	s("sfn", fmt(  	[[ -	{}void set_{} ({}) {{ +	{}void set_{} ({} {}) {{  		this.{} = {}; -	}} +	}}{}  	]], -	{ c(1, {t "", t "public ", t "private "}), -	i(2), rep(2), rep(2), rep(2) })), +	{ c(1, {t "public ", t "private ", t ""}), +	i(2), i(3), rep(2), rep(2), rep(2), i(0) })),  	-- getter function  	s("gfn", fmt(  	[[ -	{}void get_{} () {{ +	{}{} get_{} () {{  		return this.{}; -	}} +	}}{}  	]], -	{ c(1, {t "", t "public ", t "private "}), i(2), rep(2) })), +	{ c(1, {t "public ", t "private ", t ""}), i(2, "type"), i(3), rep(3), i(0)})),  	s("psv", fmt(  	[[ -	public class Main -	{{ -		public static void main (String[] args) -		{{ +	public class Main {{ +		public static void main (String[] args) {{  			{}  		}}  	}}  	]],  	{ i(0) })), -	s("pt", fmt( +	-- System.out.print +	s("sout", fmt( +	[[ +	System.out.{}({});{} +	]], +	{ c(1, {t "println", t "print", t "printf"}), i(2), i(0)})), +	-- constructor +	s("class", fmt(  	[[ -	System.out.{}("{}"); +	{}class {} {{ +		{} +	}} +	]], +	{ c(1, {t "public ", t "private ", t ""}), i(2), i(0)})), +	-- print variable +	s("pti", fmt( +	[[ +	System.out.println("{} :" + {});{} +	]], +	{ i(1), rep(1), i(0) })), +	-- quick +	s("pr", t "private "), +	s("ob", fmt( +	[[ +	{} {} = new {}({});  	{}  	]], -	{ c(1, {t "print", t "println", t "printf"}), i(2), i(0) })), +	{ i(1), i(2), rep(1), i(3), i(0) })),  }) +ls.add_snippets("sh", { +	parse("fn", "function $1 {\n\t$2\n}$0", {}) +})  | 
