feat: use a non-invasive keymap define method
This commit is contained in:
parent
576f1eb66a
commit
da6e717f2c
@ -51,11 +51,13 @@ return {
|
|||||||
split_width = 60,
|
split_width = 60,
|
||||||
padding = 10, -- padding for hover window width
|
padding = 10, -- padding for hover window width
|
||||||
keymaps = {
|
keymaps = {
|
||||||
pageup = '[[',
|
-- pageup = '<C-u>',
|
||||||
pagedown = ']]',
|
-- pagedown = '<C-d>',
|
||||||
pin = '<leader>[',
|
-- pin = '<leader>[',
|
||||||
close = '<leader>]',
|
-- close = '<leader>]',
|
||||||
toggle_entry = '<leader>;',
|
-- toggle_entry = '<leader>;',
|
||||||
|
|
||||||
|
|
||||||
-- play = '_', -- Deprecated
|
-- play = '_', -- Deprecated
|
||||||
},
|
},
|
||||||
---@type string[] auto close events
|
---@type string[] auto close events
|
||||||
|
@ -18,13 +18,18 @@ local M = Trans.metatable('frontend.hover', {
|
|||||||
M.__index = M
|
M.__index = M
|
||||||
|
|
||||||
|
|
||||||
|
---Set up function which will be invoked when this module is loaded
|
||||||
function M.setup()
|
function M.setup()
|
||||||
local set = vim.keymap.set
|
local set = vim.keymap.set
|
||||||
for action, key in pairs(M.opts.keymaps) do
|
for action, key in pairs(M.opts.keymaps) do
|
||||||
set('n', key, function()
|
set('n', key, function()
|
||||||
local instance = M.get_active_instance()
|
local instance = M.get_active_instance()
|
||||||
return instance and coroutine.wrap(instance.execute)(instance, action) or key
|
if instance then
|
||||||
-- TODO : Fix remap
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user