26 lines
773 B
Lua
26 lines
773 B
Lua
--- Thanks to Jarmos-san for the following Gist
|
|
-- https://gist.githubusercontent.com/Jarmos-san/c8bf40de6721b4a199799234be2c9f75/raw/1fdfb22233ad46fd7b23e4e450482758f52def42/utlis-map.lua
|
|
|
|
local M = {}
|
|
|
|
function M.map(mode, lhs, rhs, opts)
|
|
for i=1,string.len(mode) do
|
|
local options = { noremap = true }
|
|
if opts then
|
|
options = vim.tbl_extend("force", options, opts)
|
|
end
|
|
|
|
-- In Windows, `|` must be represented as `<bar>`.
|
|
if string.find(rhs, '|') then
|
|
local path_prefix = package.config:sub(1,1)
|
|
if path_prefix == '\\' then
|
|
rhs = rhs:gsub('|', "<bar>")
|
|
end
|
|
end
|
|
|
|
vim.api.nvim_set_keymap(string.sub(mode,i,i), lhs, rhs, options)
|
|
end
|
|
end
|
|
|
|
return M
|