Merge pull request #16969 from shadmansaleh/enhance/ingore_nore_on_plug_keymaps

feat: ignore nore on <Plug> maps
This commit is contained in:
bfredl
2022-02-27 16:47:55 +01:00
committed by GitHub
6 changed files with 56 additions and 8 deletions

View File

@@ -42,7 +42,7 @@ local keymap = {}
--- |nvim_replace_termcodes()| is applied to the result of Lua expr maps.
--- - remap: (boolean) Make the mapping recursive. This is the
--- inverse of the "noremap" option from |nvim_set_keymap()|.
--- Default `true` if `lhs` is a string starting with `<plug>` (case-insensitive), `false` otherwise.
--- Default `false`.
---@see |nvim_set_keymap()|
function keymap.set(mode, lhs, rhs, opts)
vim.validate {
@@ -66,8 +66,8 @@ function keymap.set(mode, lhs, rhs, opts)
opts.replace_keycodes = nil
if opts.remap == nil then
-- remap by default on <plug> mappings and don't otherwise.
opts.noremap = is_rhs_luaref or rhs:lower():match("^<plug>") == nil
-- default remap value is false
opts.noremap = true
else
-- remaps behavior is opposite of noremap option.
opts.noremap = not opts.remap