36 lines
1.2 KiB
Lua
36 lines
1.2 KiB
Lua
local M = {}
|
|
|
|
--- Sets a non-recursive keymap with optional description.
|
|
---@param mode string|table Mode(s) for the keymap.
|
|
---@param lhs string Left-hand side of the keymap.
|
|
---@param rhs string|function Right-hand side of the keymap.
|
|
---@param desc string|nil Description for the keymap.
|
|
---@param bufopts table|nil Additional options for the keymap.
|
|
M.mapkey = function(mode, lhs, rhs, desc, bufopts)
|
|
bufopts = bufopts or {}
|
|
if desc then
|
|
bufopts.desc = desc
|
|
end
|
|
vim.keymap.set(mode, lhs, rhs, bufopts)
|
|
end
|
|
|
|
--- Sets a non-recursive keymap for normal mode.
|
|
---@param lhs string Left-hand side of the keymap.
|
|
---@param rhs string|function Right-hand side of the keymap.
|
|
---@param desc string|nil Description for the keymap.
|
|
---@param bufopts table|nil Additional options for the keymap.
|
|
function M.nmapkey(lhs, rhs, desc, bufopts)
|
|
M.mapkey("n", lhs, rhs, desc, bufopts)
|
|
end
|
|
|
|
--- Sets a non-recursive keymap for visual mode.
|
|
---@param lhs string Left-hand side of the keymap.
|
|
---@param rhs string|function Right-hand side of the keymap.
|
|
---@param desc string|nil Description for the keymap.
|
|
---@param bufopts table|nil Additional options for the keymap.
|
|
function M.vmapkey(lhs, rhs, desc, bufopts)
|
|
M.mapkey("v", lhs, rhs, desc, bufopts)
|
|
end
|
|
|
|
return M
|