feat: use a non-invasive keymap define method

This commit is contained in:
JuanZoran
2023-04-02 18:02:21 +08:00
parent 576f1eb66a
commit da6e717f2c
2 changed files with 14 additions and 7 deletions

View File

@@ -18,13 +18,18 @@ local M = Trans.metatable('frontend.hover', {
M.__index = M
---Set up function which will be invoked when this module is loaded
function M.setup()
local set = vim.keymap.set
for action, key in pairs(M.opts.keymaps) do
set('n', key, function()
local instance = M.get_active_instance()
return instance and coroutine.wrap(instance.execute)(instance, action) or key
-- TODO : Fix remap
if instance then
coroutine.wrap(instance.execute)(instance, action)
else
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), 'n', false)
end
end)
end
end