🧋 a tiny plugin for smoother movement keybinds
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

doc: add auto-center example

robin 9f1bce62 e6da8f63

+38
+38
README.md
··· 33 33 ``` 34 34 35 35 this plugin is inspired by [vim-smoothie](https://github.com/psliwka/vim-smoothie) :) 36 + 37 + ## examples 38 + 39 + this example code will automatically center your cursor after 1000 ms of inactivity: 40 + 41 + ```lua 42 + local timer = vim.uv.new_timer() 43 + if not timer then 44 + return 45 + end 46 + 47 + local timeout = 1000 48 + local interval = 20 49 + local hold = false 50 + 51 + local _timeout = timeout 52 + Smoothie.throttle(function(t) 53 + _timeout = _timeout - t.delta 54 + 55 + if not hold and _timeout <= 0 then 56 + local mode = vim.api.nvim_get_mode().mode 57 + if mode ~= "n" then 58 + return 59 + end 60 + 61 + hold = true 62 + vim.api.nvim_feedkeys("zz", "n", false) 63 + end 64 + end, interval) 65 + 66 + vim.api.nvim_create_autocmd("CursorMoved", { 67 + group = vim.api.nvim_create_augroup("@smoothie.cursormoved", { clear = true }), 68 + callback = function(_) 69 + hold = false 70 + _timeout = timeout 71 + end, 72 + }) 73 + ```