This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/nvim/lua/key/Rekey.lua

50 lines
998 B
Lua
Raw Normal View History

2024-02-06 15:25:18 +03:00
-- Base rekey function.
2023-08-08 16:24:15 +03:00
local function rekey(t, key, command)
2023-12-05 22:06:39 +03:00
vim.api.nvim_set_keymap(t, key, command, { noremap = true })
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Base remap function.
2023-08-08 16:24:15 +03:00
local function remap(t, key, command)
2023-12-05 22:06:39 +03:00
vim.api.nvim_set_keymap(t, key, command, { noremap = false })
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Rekey in normal mode.
2023-08-08 16:24:15 +03:00
function rekey_normal(key, command)
2024-02-06 15:25:18 +03:00
rekey("n", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Rekey in input mode.
2023-08-08 16:24:15 +03:00
function rekey_input(key, command)
2024-02-06 15:25:18 +03:00
rekey("i", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Rekey in visual mode.
2023-08-08 16:24:15 +03:00
function rekey_visual(key, command)
2024-02-06 15:25:18 +03:00
rekey("v", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Rekey in terminal mode.
2023-08-08 16:24:15 +03:00
function rekey_terminal(key, command)
2024-02-06 15:25:18 +03:00
rekey("t", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Remap in normal mode.
2023-08-08 16:24:15 +03:00
function remap_normal(key, command)
2024-02-06 15:25:18 +03:00
remap("n", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Remap in input mode.
2023-08-08 16:24:15 +03:00
function remap_input(key, command)
2024-02-06 15:25:18 +03:00
remap("i", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Remap in visual mode.
2023-08-08 16:24:15 +03:00
function remap_visual(key, command)
2024-02-06 15:25:18 +03:00
remap("v", key, command)
2023-08-08 16:24:15 +03:00
end
2024-02-06 15:25:18 +03:00
-- Remap in terminal mode.
2023-08-08 16:24:15 +03:00
function remap_terminal(key, command)
2024-02-06 15:25:18 +03:00
remap("t", key, command)
2023-08-08 16:24:15 +03:00
end