Add some python snippets

This commit is contained in:
ashalimov 2025-02-01 23:26:39 +03:00
parent d2239e1e96
commit 02246c2385

View file

@ -1,9 +1,58 @@
-- Clear snippets collection when souring lua file -- 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" local ls = require "luasnip"
ls.add_snippets("lua", { local s = ls.snippet
ls.parser.parse_snippet("expand", "-- this is what was expanded kek"), local t = ls.text_node
ls.parser.parse_snippet("pipa", "Pipasik"), 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) }
)
),
}) })