dotfiles/nvim/.config/nvim/snippets/markdown/mothership.lua

132 lines
2.4 KiB
Lua

local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
--tables
local arbDashes = function(str)
local dashes = ""
local length = str:len()
for _ = 1, length do
dashes = dashes .. "-"
end
return dashes
end
local ext_opts = {
active = {
hl_group = "Substitute",
},
}
return {
s("statblock", {
t("**"),
i(1, "NAME"),
t({ "**", "" }),
t("|"),
c(2, {
t("Combat|", { node_ext_opts = ext_opts }),
t(""),
}),
c(3, {
t("Strength|", { node_ext_opts = ext_opts }),
t(""),
}),
c(4, {
t("Speed|", { node_ext_opts = ext_opts }),
t(""),
}),
c(5, {
t("Intellect|", { node_ext_opts = ext_opts }),
t(""),
}),
c(6, {
t("Instinct|", { node_ext_opts = ext_opts }),
t(""),
}),
c(7, {
t("Armor Points|", { node_ext_opts = ext_opts }),
t(""),
}),
c(8, {
t("Max Wounds (Health)|", { node_ext_opts = ext_opts }),
t(""),
}),
c(9, {
t("Special Ability|", { node_ext_opts = ext_opts }),
t(""),
}),
t({ "\t", "" }),
d(10, function(args)
local line1 = "|"
local line2 = { t("|") }
local jump_index = 1
for _, arg in ipairs(args) do
print(arg)
if arg[1] ~= "" then
local argTrimmed = arg[1]:sub(1, -2)
line1 = line1 .. arbDashes(argTrimmed) .. "|"
table.insert(line2, i(jump_index, argTrimmed))
table.insert(line2, t("|"))
jump_index = jump_index + 1
end
end
return sn(1, {
t({ line1, "" }),
sn(1, line2),
})
end, { 2, 3, 4, 5, 6, 7, 8, 9 }),
}),
s("d10", {
t("|d10|"),
i(1, "Effect"),
t({ "|", "" }),
f(function(args)
return "|---|" .. arbDashes(args[1][1]) .. "|"
end, { 1 }),
t({ "", "| 0 |" }),
i(2, "effect"),
t("|"),
t({ "", "| 1 |" }),
i(3, "effect"),
t("|"),
t({ "", "| 2 |" }),
i(4, "effect"),
t("|"),
t({ "", "| 3 |" }),
i(5, "effect"),
t("|"),
t({ "", "| 4 |" }),
i(6, "effect"),
t("|"),
t({ "", "| 5 |" }),
i(7, "effect"),
t("|"),
t({ "", "| 6 |" }),
i(8, "effect"),
t("|"),
t({ "", "| 7 |" }),
i(9, "effect"),
t("|"),
t({ "", "| 8 |" }),
i(10, "effect"),
t("|"),
t({ "", "| 9 |" }),
i(11, "effect"),
t("|"),
}),
s("d100", {
t("|d100|"),
i(1, "Effect"),
t({ "|", "" }),
f(function(args)
return "|----|" .. arbDashes(args[1][1]) .. "|"
end, { 1 }),
t({ "", "" }),
}),
}