guns / vim-sexp

Precision Editing for S-expressions
MIT License
612 stars 33 forks source link

vim repeat sets could include insert-mode text #26

Open SevereOverfl0w opened 6 years ago

SevereOverfl0w commented 6 years ago

e.g.

<localleader>wdefn should be the repeat#set text instead of <localleaderw alone. This makes it easier to repeat that kind of change, and would align the behavior with a and i for example.

justinmk commented 6 years ago

Based on https://github.com/tpope/vim-repeat/issues/63#issuecomment-390281441 it seems like the best option is to avoid using repeat.vim and use an operatorfunc (g@) instead.

Vim's b:changedtick behavior is too unpredictable for repeat.vim to be reliable.

SevereOverfl0w commented 6 years ago

I tried to do the easiest solution with:

func! Foo(...)
  call sexp#wrap('e', '(', ')', 0, g:sexp_insert_after_wrap)
endf

set opfunc=Foo

Then doing g@iwfoo. When doing ., the text "foo" was inserted, but not the wrapping parens, so I guess there's limitations to how far opfunc can repeat something.

This limitation might be overcome with the right change to vim-sexp however.

SevereOverfl0w commented 6 years ago

I can't quite figure out how to do this, I stumbled upon https://github.com/vim/vim/issues/202 which suggests that this is possible. The linked commit doesn't seem related though.

I've opened https://github.com/vim/vim/issues/3126 in the hopes of getting some information. I don't think it's currently possible to implement c in user-code though. Maybe you will have some insight into that though @justinmk?