coc-pairs icon indicating copy to clipboard operation
coc-pairs copied to clipboard

Interaction with macros

Open alextes opened this issue 4 years ago • 8 comments

I was having trouble recording a macro and noticed it appears to be due to the insertion of pairs.

With this extension on running :normal O('') produces a list that looks something like the following:

    (')''')
    ('')'')
    ('')
    (')''')
    ('')'')
    (')''')
    (')''')
    (')''')
    (')''')

Turning it off produces the sequence you'd expect.

('')
('')
('')

It's no biggie, I can turn it off when recording complex macros or use a different plugin but perhaps you do know why this is happening.

alextes avatar Apr 30 '20 09:04 alextes

Can't reproduce, it works as expected for me.

chemzqm avatar Apr 30 '20 09:04 chemzqm

I tried switching to jiangmiao/auto-pairs it fixed the problem. Maybe that helps others too.

There could be some third plugin interacting, or perhaps its a timing issue. The fact I get a few different results for the same set of input keystrokes suggests as much.

If you're not interested in digging deeper, that's fine. I understand you're strapped for time.

alextes avatar Apr 30 '20 10:04 alextes

It happens on vim8, not neovim.

chemzqm avatar Apr 30 '20 10:04 chemzqm

Interesting. Sounds more and more like performance / racing condition, in my case it's happening with NVIM v0.5.0-nightly-65-ga8f7841.

Still, using another plugin for pairs is ok too. There are quite a few coc plugins I can't live without 😅 but this one has good alternatives.

Thanks for all the great software!

alextes avatar May 01 '20 11:05 alextes

Same problem here with NVIM v0.5.0-dev+1225-gbbdd00203 Running :normal O('') will produce randomly: (')'''), (''), '()''', (')''') or ('')''). Really annoying when using macros.

I really like this auto-pairs plugin and I don't want to change... How can I help ? An idea from where the problem comes ?

gbprod avatar Apr 16 '21 07:04 gbprod

The issue is still present. Is there a way to disable the plugin temporarily, before running a macro?

JoyceBabu avatar Sep 04 '22 18:09 JoyceBabu

In help under coc-actions:

"toggleExtension" {id}					*CocAction('toggleExtension')*

	Enable/disable an extension.

So you could run a command, or map toggling it to a keybinding.

I just switched to: https://github.com/jiangmiao/auto-pairs You could also try:

  • https://github.com/cohama/lexima.vim
  • https://github.com/rstacruz/vim-closer
  • https://github.com/Raimondi/delimitMate

Because this issue reminded me, I've recently been frustrated writing macros again and just saw my advice above to switch 😅 .

Another thing one could try is to try and use multi cursor more:

  • https://github.com/mg979/vim-visual-multi

alextes avatar Sep 05 '22 08:09 alextes

coc-pairs is damn smart. jiangmiao/auto-pairs is out for me. When writing Rust, auto-pairs by default won't pair <, which is a must for type annotations. But when you turn it on, it won't be smart enough not to put <> when you're writing amount_a < amount_b. Which, to be fair, is not trivial, but coc-pairs gets this right!

On to the next 😬 .

alextes avatar Sep 06 '22 19:09 alextes