92 lines
2.1 KiB
Lua
92 lines
2.1 KiB
Lua
-- Clear snippets collection when souring lua file
|
|
require("luasnip.session.snippet_collection").clear_snippets "python"
|
|
|
|
local ls = require "luasnip"
|
|
|
|
local s = ls.snippet
|
|
local t = ls.text_node
|
|
local i = ls.insert_node
|
|
local c = ls.choice_node
|
|
local f = ls.function_node
|
|
|
|
local fmt = require("luasnip.extras.fmt").fmt
|
|
local fmta = require("luasnip.extras.fmt").fmta
|
|
local rep = require("luasnip.extras").rep
|
|
|
|
ls.add_snippets("python", {
|
|
s({ trig = "cmethod", dscr = "Create method or function with test stub" },
|
|
fmta(
|
|
[[
|
|
def <>():
|
|
"""<> for performing <>"""
|
|
pass
|
|
|
|
def test_<>_<>():
|
|
"""Test for checking correct work of <> <>"""
|
|
assert 1 == 2
|
|
<>
|
|
]],
|
|
{
|
|
i(1),
|
|
c(2, { t "Function", t "Method" }),
|
|
i(3),
|
|
rep(1),
|
|
f(function(args) return string.lower(args[1][1]) end, { 2 }),
|
|
rep(1),
|
|
f(function(args) return string.lower(args[1][1]) end, { 2 }),
|
|
i(0)
|
|
}
|
|
)
|
|
),
|
|
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.{}('{}' * 60))
|
|
_log.{}({})
|
|
_log.{}('{}' * 60))
|
|
]],
|
|
{
|
|
c(1, { t "error", t "warning", t "info" }),
|
|
i(2),
|
|
rep(1),
|
|
i(3),
|
|
rep(1),
|
|
rep(2)
|
|
}
|
|
)
|
|
),
|
|
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) }
|
|
)
|
|
),
|
|
})
|