I want to read texts with Neovim scrolling them down automatically. The following code provides such functionality:
local M = {}
function M.down()
local timer = vim.loop.new_timer()
local stop = false
local sleep = 5000
timer:start(1000, sleep, vim.schedule_wrap(function()
local scroll_down = vim.api.nvim_replace_termcodes('normal <C-E>', true, true, true)
vim.cmd(scroll_down)
if stop then
timer:close()
end
end))
end
return M
How can I interact with vim.loop
by changing stop
and sleep
variables, so the scrolling can be made faster/slower, or stopped?
stop
you could use a global variable instead of a local and change that from anywhere, I guess.