diff options
| author | Barrett Ruth <br@barrettruth.com> | 2026-07-25 10:26:01 -0700 |
|---|---|---|
| committer | Barrett Ruth <br@barrettruth.com> | 2026-07-25 10:36:56 -0700 |
| commit | 22d44ef8754448294833fcbc197defaca355f3b5 (patch) | |
| tree | c87aa5aa31b471dad36ffb2873f8dfcf308afc91 /runtime/lua/vim/keymap.lua | |
| parent | 1facf1e0818a15588deea4809292cd32cf362bed (diff) | |
| download | rneovim-22d44ef8754448294833fcbc197defaca355f3b5.tar.gz rneovim-22d44ef8754448294833fcbc197defaca355f3b5.tar.bz2 rneovim-22d44ef8754448294833fcbc197defaca355f3b5.zip | |
fix(api): add `lhs` option for keymap deletion
Diffstat (limited to 'runtime/lua/vim/keymap.lua')
| -rw-r--r-- | runtime/lua/vim/keymap.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index 4b9a32ff8c..8b68b75cf3 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -119,8 +119,11 @@ end --- --- Remove a mapping from the given buffer. `0` for current. --- @field buf? integer +--- When true, only match {lhs}, not {rhs}. +--- @field lhs? boolean --- Removes a mapping, or removes each (mode, lhs) pair if `lhs` is a list. +--- --- Examples: --- --- ```lua @@ -152,12 +155,14 @@ function keymap.del(modes, lhs, opts) buf = opts.buffer == true and 0 or opts.buffer --[[@as integer?]] end + local api_opts = { lhs = opts.lhs } + for _, m in ipairs(modes) do for _, l in ipairs(lhs) do if buf then - vim.api.nvim_buf_del_keymap(buf, m, l) + vim.api.nvim_buf_del_keymap(buf, m, l, api_opts) else - vim.api.nvim_del_keymap(m, l) + vim.api.nvim_del_keymap(m, l, api_opts) end end end |