nvim-treesitter-textobjects
nvim-treesitter-textobjects copied to clipboard
Allow to use "." for swapping
Fix #35
If possible I would recommend avoiding vim-repeat. Instead you can use vim's native g@
like in this example:
https://gist.github.com/andymass/d465970cc178452eac006840e5e58b2b
Specifically, although g@
is usually used as the start of normal operators you can also use it for entire normal commands with the sequence g@l
.
@andymass can you create a PR for it? I can't think of a elegant way to implement this. As far as I understood, we must set operatorfunc. But we can't refer to our Lua functions with v:lua
because we have a -
in our folder name. Also we would have to create a outer function that sets the operatorfunc and an inner that does the actual action.
Can't you use the g@l
hack already now in your config?
Can't you use the g@l hack already now in your config?
Yes, it's possible via a wrapper function;
function! s:repeatable(cmd)
function! s:inner(...) closure abort
execute a:cmd
endfunction
let &opfunc=get(funcref('s:inner'), 'name')
return 'g@l'
endfunction
nnoremap <silent><expr> <left>
\ <sid>repeatable('TSTextobjectSwapPrevious @parameter.inner')
nnoremap <silent><expr> <right>
\ <sid>repeatable('TSTextobjectSwapNext @parameter.inner')
But we can't refer to our Lua functions with v:lua because we have a - in our folder name.
I think that could be fixed fairly easily, but a problem remains that there would have to be some state held somewhere and I'm not sure how to refer to lua inner functions in operatorfunc.
can you create a PR for it?
Here is a first shot at it using the same technique as above: #55 . I'm not sure how to do it with pure lua.
Ping
Bump
Superseded by #343 or #55