fix(api): add lhs option for keymap deletion

This commit is contained in:
Barrett Ruth
2026-07-25 10:26:01 -07:00
parent 1facf1e081
commit 22d44ef875
13 changed files with 120 additions and 31 deletions

View File

@@ -3049,6 +3049,23 @@ describe('vim.keymap', function()
eq('\nNo mapping found', n.exec_capture('nmap qwer'))
end)
it('unmap with lhs option', function()
eq(
'q',
exec_lua [[
vim.keymap.set('n', 'ge', 'q')
local ok, err = pcall(vim.keymap.del, 'n', 'q', { lhs = true })
assert(not ok and err:match('E31: No such mapping'), err)
return vim.fn.maparg('ge', 'n')
]]
)
exec_lua [[
vim.keymap.del('n', 'ge', { lhs = true })
]]
eq('\nNo mapping found', n.exec_capture('nmap ge'))
end)
it('buffer-local mappings', function()
eq(
0,