t0vim/lua/custom/snippets/python.lua
2025-02-01 23:26:39 +03:00

58 lines
1.4 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 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) }
)
),
})