mirror of https://github.com/folke/lazy.nvim.git
fix: remove lazy keymaps with the correct mode. Fixes #97
This commit is contained in:
parent
42f5aa76e2
commit
56890ce5f4
|
@ -28,7 +28,10 @@ end
|
||||||
|
|
||||||
---@param value string|LazyKeys
|
---@param value string|LazyKeys
|
||||||
function M.parse(value)
|
function M.parse(value)
|
||||||
return (type(value) == "string" and { value } or value) --[[@as LazyKeys]]
|
local ret = vim.deepcopy(value)
|
||||||
|
ret = (type(ret) == "string" and { ret } or ret) --[[@as LazyKeys]]
|
||||||
|
ret.mode = ret.mode or "n"
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.opts(keys)
|
function M.opts(keys)
|
||||||
|
@ -45,21 +48,24 @@ end
|
||||||
function M:_add(value)
|
function M:_add(value)
|
||||||
local keys = M.parse(value)
|
local keys = M.parse(value)
|
||||||
local lhs = keys[1]
|
local lhs = keys[1]
|
||||||
vim.keymap.set(keys.mode or "n", lhs, function()
|
local opts = M.opts(keys)
|
||||||
|
opts.noremap = false
|
||||||
|
vim.keymap.set(keys.mode, lhs, function()
|
||||||
Util.track({ keys = lhs })
|
Util.track({ keys = lhs })
|
||||||
self:_del(value)
|
self:_del(value)
|
||||||
Loader.load(self.active[value], { keys = lhs })
|
Loader.load(self.active[value], { keys = lhs })
|
||||||
M.retrigger(lhs)
|
M.retrigger(lhs)
|
||||||
Util.track()
|
Util.track()
|
||||||
end, M.opts(keys))
|
end, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param value string|LazyKeys
|
---@param value string|LazyKeys
|
||||||
function M:_del(value)
|
function M:_del(value)
|
||||||
local keys = M.parse(value)
|
local keys = M.parse(value)
|
||||||
pcall(vim.keymap.del, "n", keys[1])
|
vim.pretty_print(keys)
|
||||||
|
pcall(vim.keymap.del, keys.mode, keys[1])
|
||||||
if keys[2] then
|
if keys[2] then
|
||||||
vim.keymap.set(keys.mode or "n", keys[1], keys[2], M.opts(keys))
|
vim.keymap.set(keys.mode, keys[1], keys[2], M.opts(keys))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue