nvim-treesitter / nvim-treesitter-textobjects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support `;` for repeating movements

ghostbuster91 opened this issue · comments

I am relatively new to vim, and I don't know whether this should just work but I have broke something in my config or it is just impossible to do that. If it is the latter I would like to understand the reason behind it.

Is your feature request related to a problem? Please describe.
I would like to be able to repeat motion ]m/]M etc with ;, the same way that I repeat motion from f/F/t/T

Additional context
I am aware of the existence of vim-repeat that allows repeating custom actions, I am surprised that there is nothing like that for repeating motions.

https://github.com/vim-scripts/repeatable-motions.vim

This exists, however I have not checked it.

https://github.com/vim-scripts/repeatable-motions.vim

This exists, however I have not checked it.

Thanks for the pointer. Interesting plugin, although I tried it with TS textobjects and it raises a bunch of errors.

As far as I know, using the same ; key is not possible and you need to make a separate binding for this TS textobjects, if it gets implemented.

In order to use ; key, you need to override all f, F, t, T keys to work as usual and remember the last movement with TS textobjects. This is a dirty solution which can potentially cause problems with other plugins.. This is also how repeatable-motions.vim implements this.

https://github.com/vim-scripts/repeatable-motions.vim/blob/d51360269b312a34922d3de412505af069565e77/plugin/repeatable-motions.vim#L390-L393

I tried several stuff.

  1. Adding { repeatable = true } here:
    M.attach = attach.make_attach(nxo_mode_functions, "move", { "n", "x", "o" })

It works in normal mode but not in visual mode.

  1. Using tpope/vim-repeat
map <Plug>nextfunc <cmd>TSTextobjectGotoNextStart @function.outer<CR>
silent! call repeat#set("\<Plug>nextfunc", v:count)
map <C-A-l> <Plug>nextfunc

It works in normal mode but not in visual mode.

Adding { repeatable = true } here:

because I only allowed in normal mode. I think it is very unusual for . to be used for non-edit operations, this would not be expected. I would just add a Lua function that executes the last motion this plugin performed. This function could be enabled for "n", "x", "o". People can then map it to something they like

I agree that using . for non-edit operations would be counter-intuitive, that is why I asked originally for ; as it is used by default to repeat motions.

Adding { repeatable = true } here:
It works in normal mode but not in visual mode.

That would be already an improvement for me. Is there an option I can configure that externally?

@ghostbuster91 I am implementing this feature and it will come very soon.

@ghostbuster91 Do you mind if you try #359 and let me know how you like it? Any feedback would be appreciated!

@kiyoon During the work on the separate version of that feature I came across some weird behavior. I think that your version might be also affected but I didn't have time yet to confirm that. I will try to do it in upcoming days.

@kiyoon During the work on the separate version of that feature I came across some weird behavior. I think that your version might be also affected but I didn't have time yet to confirm that. I will try to do it in upcoming days.

Thanks for reporting. Let me know what kind of behaviour you observed

@kiyoon Sorry false alarm, it was just me being tired, all good.

Sorry to comment on a closed issue: does this refer to ts_repeat_move (with ;/,) as per README? I cannot get the repetition to work: is it supposed to work in all cases (namely for all text objects)?