2023-01-10 02:38:06 +01:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
local function swap(key)
|
|
|
|
vim.keymap.set({ "n", "v" }, key, "g" .. key, { buffer = true })
|
|
|
|
vim.keymap.set({ "n", "v" }, "g" .. key, key, { buffer = true })
|
|
|
|
end
|
|
|
|
|
2023-11-11 06:55:14 +01:00
|
|
|
local function unswap(key)
|
|
|
|
vim.keymap.del({ "n", "v" }, key)
|
|
|
|
vim.keymap.del({ "n", "v" }, "g" .. key)
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.enable()
|
2023-03-07 15:19:18 +01:00
|
|
|
vim.opt.wrap = true
|
|
|
|
|
2023-01-10 02:38:06 +01:00
|
|
|
swap("j")
|
|
|
|
swap("k")
|
|
|
|
swap("0")
|
|
|
|
swap("$")
|
|
|
|
end
|
|
|
|
|
2023-11-11 06:55:14 +01:00
|
|
|
function M.disable()
|
|
|
|
vim.opt.wrap = false
|
|
|
|
|
|
|
|
unswap("j")
|
|
|
|
unswap("k")
|
|
|
|
unswap("0")
|
|
|
|
unswap("$")
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.toggle()
|
|
|
|
if vim.opt.wrap == true then
|
|
|
|
M.disable()
|
|
|
|
else
|
|
|
|
M.enable()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-01-10 02:38:06 +01:00
|
|
|
return M
|