jinh0 / eyeliner.nvim

👀 Move faster with unique f/F indicators.
461 stars 15 forks source link

Restore `Esc` mapping for custom keymaps #52

Closed mawkler closed 1 month ago

mawkler commented 3 months ago

Following up the discussion from https://github.com/jinh0/eyeliner.nvim/issues/46 here.

Here's what I've currently got with default_keymaps = false:

local function eyeliner_move(key, forward)
  return function()
    require('eyeliner').highlight({ forward = forward })
    return repeat_move['builtin_' .. key .. '_expr']()
  end
end

vim.keymap.set(nxo, 'f', eyeliner_move('f', true), opts)
vim.keymap.set(nxo, 'F', eyeliner_move('F', false), opts)
vim.keymap.set(nxo, 't', eyeliner_move('t', true), opts)
vim.keymap.set(nxo, 'T', eyeliner_move('T', false), opts)
vim.keymap.set(nxo, ';', repeat_move.repeat_last_move_next)
vim.keymap.set(nxo, ',', repeat_move.repeat_last_move_previous)

What would be neat is if eyeliner exposed a function that creates a one-shot <Esc> mapping, or perhaps even if eyeliner.highlight created that mapping. And that key mapping gets cleared once <Esc> is pressed.

jinh0 commented 1 month ago

If I understand it correctly, @cosmicbuffalo has fixed the issue by using vim.on_key() in #61 ! Let me know if there's any issue!

mawkler commented 1 month ago

Awesome! It seems to be working. Thank you @cosmicbuffalo!