From b3390c702aeeed813585f64c90dfdf9d704c1b05 Mon Sep 17 00:00:00 2001 From: Ricman Date: Sat, 19 Apr 2025 01:34:07 -0300 Subject: [PATCH] =?UTF-8?q?agregu=C3=A9=20la=20creaci=C3=B3n=20de=20matric?= =?UTF-8?q?es=20de=20nxn=20autom=C3=A1ticamente,=20y=20creo=20que=20algo?= =?UTF-8?q?=20mas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/snippets/tex.lua | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lua/snippets/tex.lua b/lua/snippets/tex.lua index 94c3fbf6..8d30a4d4 100644 --- a/lua/snippets/tex.lua +++ b/lua/snippets/tex.lua @@ -12,6 +12,29 @@ vim.keymap.set({ 'i', 's' }, '', 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(