40 lines
676 B
Lua
40 lines
676 B
Lua
local M = {}
|
|
|
|
function M.map(mode, lhs, rhs, opts)
|
|
local options = { silent = true, noremap = true }
|
|
|
|
if opts then
|
|
options = vim.tbl_extend("force", options, opts)
|
|
end
|
|
|
|
if type(mode) == "table" then
|
|
for _, m in ipairs(mode) do
|
|
vim.keymap.set(m, lhs, rhs, options)
|
|
end
|
|
else
|
|
vim.keymap.set(mode, lhs, rhs, options)
|
|
end
|
|
end
|
|
|
|
function M.nmap(lhs, rhs, opts)
|
|
M.map("n", lhs, rhs, opts)
|
|
end
|
|
|
|
function M.imap(lhs, rhs, opts)
|
|
M.map("i", lhs, rhs, opts)
|
|
end
|
|
|
|
function M.vmap(lhs, rhs, opts)
|
|
M.map("v", lhs, rhs, opts)
|
|
end
|
|
|
|
function M.tmap(lhs, rhs, opts)
|
|
M.map("t", lhs, rhs, opts)
|
|
end
|
|
|
|
function M.cmap(lhs, rhs, opts)
|
|
M.map("c", lhs, rhs, opts)
|
|
end
|
|
|
|
return M
|