diff --git a/lua/custom/snippets/python.lua b/lua/custom/snippets/python.lua index eaefb80..e1a25ec 100644 --- a/lua/custom/snippets/python.lua +++ b/lua/custom/snippets/python.lua @@ -1,9 +1,58 @@ -- Clear snippets collection when souring lua file -require("luasnip.session.snippet_collection").clear_snippets "lua" +require("luasnip.session.snippet_collection").clear_snippets "python" local ls = require "luasnip" -ls.add_snippets("lua", { - ls.parser.parse_snippet("expand", "-- this is what was expanded kek"), - ls.parser.parse_snippet("pipa", "Pipasik"), +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +ls.add_snippets("python", { + s({ trig = "implog", dscr = "Import necessary logging utils" }, { + t({ + "import logging", + "_log = logging.getLogger(__name__)" + } + ) + }), + s({ trig = "logevent", dscr = "Import necessary logging utils" }, + fmt( + [[ + _log.error('{}' * 60)) + _log.error({}) + _log.error('{}' * 60)) + ]], + { i(1), i(2), rep(1) } + ) + ), + s({ trig = "pybasetest", dscr = "Create test suite boilerplate" }, + fmt( + [[ + class Test{}: + """Test suite for checking correct work of {} feature""" + + @pytest.fixture(autouse=True) + def setup_test(self): + """Fixture for initializing test cases base data""" + {} + + {} + ]], + { i(1), rep(1), i(2), i(0) } + ) + ), + s({ trig = "pysection", dscr = "Secion snippet" }, + fmt( + [[ + ##################### Section ############################## + # Section topic: {} + ############################################################ + {} + ]], + { i(1), i(0) } + ) + ), })