agregué la creación de matrices de nxn automáticamente, y creo que algo mas

This commit is contained in:
Ricman 2025-04-19 01:34:07 -03:00
parent 52e3d61ea1
commit b3390c702a
1 changed files with 46 additions and 0 deletions

View File

@ -12,6 +12,29 @@ vim.keymap.set({ 'i', 's' }, '<C-h>', function()
end
end)
-- Generador dinámico de matrices
local function matrix_generator(_, snip)
local dims = snip.captures[1] -- Extraído del regex (por ejemplo, "3x3")
local n, m = dims:match '(%d+)x(%d+)'
n = tonumber(n)
m = tonumber(m)
local nodes = {}
for row = 1, n do
for col = 1, m do
table.insert(nodes, i((row - 1) * m + col, ''))
if col < m then
table.insert(nodes, t ' & ')
end
end
if row < n then
table.insert(nodes, t { ' \\\\', '' })
end
end
return sn(nil, nodes)
end
return {
-- NOTE: AUTOSNIPPETS
@ -113,6 +136,29 @@ return {
)
),
s(
{ trig = ';mat(%d+x%d+)', regTrig = true, name = 'Matrix' },
fmt(
[[
\begin{{{}}}
{}
\end{{{}}}
]],
{
c(1, {
t 'bmatrix',
t 'pmatrix',
t 'Bmatrix',
t 'vmatrix',
t 'Vmatrix',
t 'matrix',
}),
d(2, matrix_generator, {}),
rep(1),
}
)
),
-- NOTE: MATH
s(