ggandor / leap.nvim

Neovim's answer to the mouse 🦘
MIT License
4.33k stars 47 forks source link

Include current window as target for `<Plug>(leap-from-window)` #241

Closed EtiamNullam closed 2 months ago

EtiamNullam commented 2 months ago

I'm a fan of simply using s to jump anywhere, even across windows. I was hoping to use <Plug>(leap-from-window) for that, but it seems like it excludes the current window. Maybe it's worth to include it or provide an alternative "<Plug>..." with this behavior?

My solution:

vim.keymap.set(
  { 'n', 'x', 'o' },
  's',
  function()
    local all_windows = require('leap.util').get_enterable_windows()
    table.insert(all_windows, vim.api.nvim_get_current_win())

    require('leap').leap {
      target_windows = all_windows,
    }
  end,
)

This leaves S free for me to use for the remote leap:

vim.keymap.set(
  { 'n', 'x', 'o' },
  'S',
  function()
    require('leap.remote').action()
  end,
)
ggandor commented 2 months ago

See https://github.com/ggandor/leap.nvim?tab=readme-ov-file#features, there is get_focusable_windows too. As I've written there, although it's cool to use just one key (and feel free to do so, obviously), I personally don't recommend it (and therefore don't want to expose a <Plug> key), because I think losing the ability to auto-jump is not worth it.

EtiamNullam commented 2 months ago

Sure, I can imagine auto-jump might be important for some people, but with <Plug>(leap-from-window) we can already expect to have a lot of targets from possibly multiple windows with lower chance for auto-jump.

If someone would like to commit 2 keys for this kind of movement - and still care about the auto-jump - I think most convenient would be: s - jump in window, S - jump anywhere.

Sorry, I've missed this one. Seems like you've already provided a short example there of what I need.

At least require('leap.remote').action() seems to be working across windows like I want it to (for now :D).

Thank you for your work - it's a really good plugin, I just need to use it more often.