mirror of
https://github.com/kristoferssolo/SoloVim.git
synced 2026-02-04 06:42:05 +00:00
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
This commit is contained in:
54
snippets/lua.lua
Normal file
54
snippets/lua.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
---@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),
|
||||
})
|
||||
),
|
||||
}
|
||||
Reference in New Issue
Block a user