51 lines
1.3 KiB
Lua
51 lines
1.3 KiB
Lua
-- Python snippets
|
|
-- See docs/guides/snippets.md for how to create snippets
|
|
--
|
|
-- Quick reference:
|
|
-- s(trigger, nodes, opts) - Create a snippet
|
|
-- t(text) - Text node
|
|
-- i(index, default) - Insert node (tab stop)
|
|
-- c(index, choices) - Choice node
|
|
-- f(func, args) - Function node
|
|
-- d(index, func, args) - Dynamic node
|
|
-- rep(index) - Repeat node
|
|
--
|
|
-- Example:
|
|
-- s("def", fmt("def {}({}):\n {}", { i(1, "name"), i(2), i(0) }))
|
|
-- Typing "def" + expand will give a function template
|
|
|
|
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 d = ls.dynamic_node
|
|
local sn = ls.snippet_node
|
|
local rep = require("luasnip.extras").rep
|
|
local fmt = require("luasnip.extras.fmt").fmt
|
|
|
|
-- Add your Python snippets here
|
|
return {
|
|
-- Example: Uncomment and modify as needed
|
|
--
|
|
-- Main block
|
|
-- s("main", fmt([[
|
|
-- if __name__ == "__main__":
|
|
-- {}
|
|
-- ]], { i(0) })),
|
|
--
|
|
-- Class with init
|
|
-- s("class", fmt([[
|
|
-- class {}:
|
|
-- def __init__(self, {}):
|
|
-- {}
|
|
-- ]], { i(1, "ClassName"), i(2), i(0) })),
|
|
--
|
|
-- Async function
|
|
-- s("adef", fmt([[
|
|
-- async def {}({}):
|
|
-- {}
|
|
-- ]], { i(1, "name"), i(2), i(0) })),
|
|
}
|