From df7c711e2a49d51249350f52c63274b72aacb739 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Sun, 27 Sep 2026 12:46:49 -0300 Subject: =?UTF-8?q?Migraci=C3=B3n=20de=20plugins=20a=20funcionalidad=20nat?= =?UTF-8?q?iva:=20statusline=20y=20treesitter=20propios,=20se=20quitan=20m?= =?UTF-8?q?ason,=20lualine,=20mini,=20notify=20y=20otros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/pi/animations.lua | 71 ++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 40 deletions(-) (limited to 'lua/pi/animations.lua') diff --git a/lua/pi/animations.lua b/lua/pi/animations.lua index 3ff711f..e4bc859 100644 --- a/lua/pi/animations.lua +++ b/lua/pi/animations.lua @@ -1,48 +1,39 @@ -local redraw_buffer = function() - local Animation = require "animation" - local fps = 15 -- frames per second - local easing = require "animation.easing" - - local buffer = 0 - local len = 0 - local place_holder = {} +-- Animación de "retipeo" del buffer, con vim.uv (antes dependía de animation.nvim). +local fps = 15 -- un caracter por frame, como la versión original +local redraw_buffer = function() + local buffer = vim.api.nvim_get_current_buf() local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true) - for _, line in ipairs(lines) do - len = len + string.len(line) + local place_holder = {} + for _ = 1, #lines do table.insert(place_holder, "") end - - vim.api.nvim_buf_set_lines(buffer, 0, #lines, true, place_holder) - - local duration = math.ceil(len / fps * 1000) - - local i = 1 - local line_nr = 1 - local insertLine = "" - - local function callback() - if lines[line_nr] == nil then - return true - end - local char = string.sub(lines[line_nr], i, i) - if char == nil then - return true - end - insertLine = insertLine .. char - i = i + 1 - vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { insertLine }) - - if insertLine == lines[line_nr] then - i = 1 - line_nr = line_nr + 1 - insertLine = "" - end - end - - local animation = Animation(duration, fps, easing.line, callback) - animation:run() + vim.api.nvim_buf_set_lines(buffer, 0, -1, true, place_holder) + + local line_nr, col = 1, 0 + local timer = assert(vim.uv.new_timer()) + + timer:start( + 0, + math.floor(1000 / fps), + vim.schedule_wrap(function() + if not vim.api.nvim_buf_is_valid(buffer) or line_nr > #lines then + timer:stop() + timer:close() + return + end + + col = col + 1 + local line = lines[line_nr] + vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { line:sub(1, col) }) + + if col >= #line then + line_nr = line_nr + 1 + col = 0 + end + end) + ) end return { -- cgit v1.2.3