mirror of
https://codeberg.org/JasterV/dotfiles.git
synced 2026-04-26 18:40:04 +00:00
42 lines
889 B
Lua
42 lines
889 B
Lua
local M = {}
|
|
|
|
local max = 10
|
|
|
|
local keymap_opts = { expr = true, silent = true }
|
|
|
|
function M.cowboy()
|
|
---@type table?
|
|
local id
|
|
local ok = true
|
|
for _, key in ipairs({ "h", "j", "k", "l", "+", "-" }) do
|
|
local count = 0
|
|
local timer = assert(vim.loop.new_timer())
|
|
local map = key
|
|
vim.keymap.set("n", key, function()
|
|
if vim.v.count > 0 then
|
|
count = 0
|
|
end
|
|
if count >= max then
|
|
ok, id = pcall(vim.notify, "Hold it Cowboy!", vim.log.levels.WARN, {
|
|
icon = "🤠",
|
|
replace = id,
|
|
keep = function()
|
|
return count >= max
|
|
end,
|
|
})
|
|
if not ok then
|
|
id = nil
|
|
return map
|
|
end
|
|
else
|
|
count = count + 1
|
|
timer:start(2000, 0, function()
|
|
count = 0
|
|
end)
|
|
return map
|
|
end
|
|
end, keymap_opts)
|
|
end
|
|
end
|
|
|
|
return M
|