merge: master <--- fix/insert-mode-keybinds

* HEAD
| \
| * 114ed13 <github@luxolus.com> fix(map_util): add `<CR>` after string bindings
| * 26fb642 <github@luxolus.com> fix(map_util): insert bindings for <Plug>, <Cmd> and :Cmd work
| /
| master

Signed-off-by: Bazaah <github@luxolus.com>
This commit is contained in:
Paul Stemmet 2024-08-18 18:14:19 +00:00
commit 545479084f
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
1 changed files with 9 additions and 11 deletions

View File

@ -35,19 +35,17 @@ 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
rhs = "<Plug>" .. prefix .. rhs if not rhs:match("[<:]") then
rhs = "<Plug>" .. prefix .. rhs .. "<CR>"
else
rhs = rhs .. "<CR>"
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