diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2026-09-27 12:46:49 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2026-09-27 12:46:49 -0300 |
| commit | df7c711e2a49d51249350f52c63274b72aacb739 (patch) | |
| tree | 426da3b65371f857f3ee3d9893d7ff3279aac02e /lua/pi/animations.lua | |
| parent | a0bd84df02ce235123dfc939327e8bd33dffdd7e (diff) | |
| download | nvim-conf-df7c711e2a49d51249350f52c63274b72aacb739.tar.gz nvim-conf-df7c711e2a49d51249350f52c63274b72aacb739.zip | |
Migración de plugins a funcionalidad nativa: statusline y treesitter propios, se quitan mason, lualine, mini, notify y otros
Diffstat (limited to 'lua/pi/animations.lua')
| -rw-r--r-- | lua/pi/animations.lua | 71 |
1 files changed, 31 insertions, 40 deletions
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 { |