Skip to content

Commit 56890ce

Browse files
committed
fix: remove lazy keymaps with the correct mode. Fixes #97
1 parent 42f5aa7 commit 56890ce

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lua/lazy/core/handler/keys.lua

+11-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ end
2828

2929
---@param value string|LazyKeys
3030
function M.parse(value)
31-
return (type(value) == "string" and { value } or value) --[[@as LazyKeys]]
31+
local ret = vim.deepcopy(value)
32+
ret = (type(ret) == "string" and { ret } or ret) --[[@as LazyKeys]]
33+
ret.mode = ret.mode or "n"
34+
return ret
3235
end
3336

3437
function M.opts(keys)
@@ -45,21 +48,24 @@ end
4548
function M:_add(value)
4649
local keys = M.parse(value)
4750
local lhs = keys[1]
48-
vim.keymap.set(keys.mode or "n", lhs, function()
51+
local opts = M.opts(keys)
52+
opts.noremap = false
53+
vim.keymap.set(keys.mode, lhs, function()
4954
Util.track({ keys = lhs })
5055
self:_del(value)
5156
Loader.load(self.active[value], { keys = lhs })
5257
M.retrigger(lhs)
5358
Util.track()
54-
end, M.opts(keys))
59+
end, opts)
5560
end
5661

5762
---@param value string|LazyKeys
5863
function M:_del(value)
5964
local keys = M.parse(value)
60-
pcall(vim.keymap.del, "n", keys[1])
65+
vim.pretty_print(keys)
66+
pcall(vim.keymap.del, keys.mode, keys[1])
6167
if keys[2] then
62-
vim.keymap.set(keys.mode or "n", keys[1], keys[2], M.opts(keys))
68+
vim.keymap.set(keys.mode, keys[1], keys[2], M.opts(keys))
6369
end
6470
end
6571

0 commit comments

Comments
 (0)