fix(map_util): add `<CR>` after string bindings

If you have two <Plug> bindings, one that's a prefix to another:
- <Plug>MyScript:Cmd
- <Plug>MyScript:Cmd2
If you try and use the prefix binding, vim will wait for `ttimeoutlen`

Co-authored-by: Oliver Marshall <olivershawmarshall@gmail.com>
This commit is contained in:
Paul Stemmet 2024-08-18 18:11:13 +00:00
parent 26fb642ff3
commit 114ed132a3
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
1 changed files with 3 additions and 1 deletions

View File

@ -37,7 +37,9 @@ M.create_maps_to_plug = function(bufnr, mode, bindings, prefix)
-- 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" then if type(rhs) == "string" then
if not rhs:match("[<:]") then if not rhs:match("[<:]") then
rhs = "<Plug>" .. prefix .. rhs rhs = "<Plug>" .. prefix .. rhs .. "<CR>"
else
rhs = rhs .. "<CR>"
end end
if mode == "i" then if mode == "i" then
rhs = "<C-o>" .. rhs rhs = "<C-o>" .. rhs