Skip to content

Commit

Permalink
fix: load on specific keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
eph authored and lewis6991 committed Jul 19, 2024
1 parent 9a4a309 commit 28426ea
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lua/pckr/loader/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@ return function(mode, key, rhs, opts)
opts.silent = true
end

rhs = rhs
or function()
--- @param loader fun()
return function(loader)
local rhs_func = function()
-- always delete the mapping immediately to prevent recursive mappings
vim.keymap.del(mode, key, opts)
loader()
if mode == 'n' then
vim.api.nvim_input(key)
else
vim.api.nvim_feedkeys(key, mode, false)
vim.api.nvim_feedkeys(key, '', false)
end
end

--- @param loader fun()
return function(loader)
-- TODO(lewis6991): detect is mapping already exists
-- TODO(Zhou-Yicheng): delete mapping if exists
-- vim.keymap.del(mode, key)
loader()
vim.keymap.set(mode, key, rhs, opts)
vim.keymap.set(mode, key, rhs_func, opts)
end
end

0 comments on commit 28426ea

Please sign in to comment.