SoloVim/snippets/lua.lua
Kristofers Solo f5c52bcc9d
Update 2025-10-31
update 2025-10-08

chore: update readme

Update 2025-10-09

Update 2025-10-15

Update 2025-10-22

Update 2025-10-31
2025-10-31 11:59:53 +02:00

55 lines
685 B
Lua

---@diagnostic disable: undefined-global
local require_var = function(args, _)
local text = args[1][1] or ""
local split = vim.split(text, ".", { plain = true })
local options = {}
for len = 0, #split - 1 do
table.insert(options, t(table.concat(vim.list_slice(split, #split - len, #split), "_")))
end
return sn(nil, {
c(1, options),
})
end
return {
s(
"lf",
fmt(
[[
local function {}({})
{}
end
]],
{
i(1),
i(2),
i(0),
}
)
),
s(
"fn",
fmt(
[[
function({})
{}
end
]],
{
i(1),
i(0),
}
)
),
s(
"req",
fmt([[ local {} = require("{}") ]], {
d(2, require_var, { 1 }),
i(1),
})
),
}