ggandor / leap-spooky.nvim

👻 Actions at a distance
The Unlicense
277 stars 7 forks source link

It'd be cool to support treesitter-textobjects #1

Closed nick4tech closed 9 months ago

nick4tech commented 1 year ago

I use https://github.com/nvim-treesitter/nvim-treesitter-textobjects a lot and it'd be awesome if spooky would support some of those motions, mainly @class, @function and @parameter.

ggandor commented 1 year ago

Definitely, I'm just thinking about the appropriate API in setup for handling arbitrary text objects that don't necessarily follow the a/i pattern.

For the moment, if you have e.g. an if mapping for @function.inner, then you can set the remote version by:

vim.keymap.set('o', 'irf', function ()
  require('leap').leap {
    -- for cross-window, call require('leap.util').get_enterable_windows()
    target_windows = { vim.fn.win_getid() }
    action = require('leap-spooky').spooky_action(
      function () return "vif" end,
      { keeppos = true, on_return = (vim.v.operator == 'y') and 'p', },
    ),
  } end, {})

See the "Customisation" section that I just added to the Readme.