fix(map_util): insert bindings for <Plug>, <Cmd> and :Cmd work
Co-authored-by: Oliver Marshall <olivershawmarshall@gmail.com>
This commit is contained in:
parent
c5775a888a
commit
26fb642ff3
|
@ -35,19 +35,15 @@ M.create_maps_to_plug = function(bufnr, mode, bindings, prefix)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Prefix with <Plug> unless this is a <Cmd> or :Cmd mapping
|
-- Prefix with <Plug> unless this is a <Cmd> or :Cmd mapping
|
||||||
if type(rhs) == "string" and not rhs:match("[<:]") then
|
if type(rhs) == "string" then
|
||||||
|
if not rhs:match("[<:]") then
|
||||||
rhs = "<Plug>" .. prefix .. rhs
|
rhs = "<Plug>" .. prefix .. rhs
|
||||||
end
|
end
|
||||||
if mode == "i" then
|
if mode == "i" then
|
||||||
-- HACK for some reason I can't get plug mappings to work in insert mode
|
rhs = "<C-o>" .. rhs
|
||||||
for _, map in ipairs(maps) do
|
|
||||||
if map.lhs == rhs then
|
|
||||||
---@diagnostic disable-next-line: cast-local-type
|
|
||||||
rhs = map.callback or map.rhs
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@cast rhs string
|
---@cast rhs string
|
||||||
vim.keymap.set(mode, lhs, rhs, opts)
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue