馃 smoothie.nvim#
a tiny plugin for smoother movement keybinds
requirements#
- Neovim
>= 0.12
installation#
install with vim.pack:
vim.pack.add({ { src = "https://codeberg.org/comfysage/smoothie.nvim" } })
usage#
smoothie currently on supports smoothing for the ctrl-d and ctrl-u keybinds.
vim.keymap.set("n", "<c-d>", "<plug>(smoothie-ctrl-d)")
vim.keymap.set("n", "<c-u>", "<plug>(smoothie-ctrl-u)")
you can configure the smoothing settings:
vim.g.smoothie_config = {
interval = 5,
maxtime = 100,
}
this plugin is inspired by vim-smoothie :)
examples#
this example code will automatically center your cursor after 1000 ms of inactivity:
local timer = vim.uv.new_timer()
if not timer then
return
end
local timeout = 1000
local interval = 20
local hold = false
local _timeout = timeout
Smoothie.throttle(function(t)
_timeout = _timeout - t.delta
if not hold and _timeout <= 0 then
local mode = vim.api.nvim_get_mode().mode
if mode ~= "n" then
return
end
hold = true
vim.api.nvim_feedkeys("zz", "n", false)
end
end, interval)
vim.api.nvim_create_autocmd("CursorMoved", {
group = vim.api.nvim_create_augroup("@smoothie.cursormoved", { clear = true }),
callback = function(_)
hold = false
_timeout = timeout
end,
})