mg979 / vim-visual-multi

Multiple cursors plugin for vim/neovim
MIT License
4.21k stars 81 forks source link

Conflicting issues when used with other plug-ins #172

Closed onlycalm closed 3 years ago

onlycalm commented 3 years ago

Describe the issue: There is a conflict between Vim-visual-multi and the following plug-ins : auto-pairs, coc.nvim Maybe it's not the Vim-Visual-multi problem, but I don't know who to turn to. These are all great plugins, and I want to use them all together. I would be very grateful if you could give me some advice.

Steps to reproduce

Vim-visual-multi and auto-pairs conflict:

  1. Install the two plug-ins with the default configuration.
  2. Open a file and enter multi-cursor mode.

2021-06-20_12-51-36

The high probability results in abnormal functioning of auto-pairs.

b5: Overwritten imap: <CR> (I Return)  ->  <CR><SID>AutoPairsReturn
b5: Overwritten imap: <BS> (I BS)  ->  <C-R>=AutoPairsDelete()<CR>

Vim-visual-multi and coc.nvim conflict:

  1. Install the two plug-ins with the default configuration.
  2. Open a file into multi-cursor mode and press the backspace key.

2021-06-20_13-22-18

When the COC detects a syntax error or warning in the file, using backspace in multi-cursor mode will cause an exception.


mg979 commented 3 years ago
  1. Issue with CR has been discussed, look for it in issues.
  2. about autopairs, I tried to make it compatible but maybe I didn't succeed. It uses buffer mappings for something that wouldn't need buffer mappings (imho), maybe you can contact autopairs author and ask if he's interested in making the plugins compatible because I can't fix this kind of issues on my part. Autopairs should be aware of VM to be compatible.
mg979 commented 3 years ago

About coc issue, I'm not sure. If there is a more general problem that is reproducible with all plugins (or with nvim lsp in similar situations, for example), I may look into it, but if it's a coc.nvim specific thing honestly I don't care.

onlycalm commented 3 years ago

I've fed back the questions to the author of auto-pairs. I used other LSP plug-in tests (ALE), and there was no exception. It seems that this problem is only related to coc. I try to feed this back to the COC authors.

Thanks!

LunarWatcher commented 3 years ago

For the record, the original auto-pair author hasn't been online in a couple years (https://github.com/jiangmiao/auto-pairs/issues/309) -- and based on the pattern, they're probably not gonna come back, at least any time soon.

That being said, this is vim-visual-multi's fault. Some update is now causing errors. It doesn't have anything to do with keybind overrides, though -- those weren't an error in the earlier version I had installed, anyway. While testing, I couldn't repro with my plugin. Installed jiangmiao and updated everything, reproduced, and thought it had always been broken. Rolled back to my auto-pairs and it now broke, so it's definitely something related to vim-visual-multi.

Gonna have to look into this though (I'm maintaining a fork of auto-pairs -- I assume there's some plugin config that can be done for compatibility now too), but it really depends on what's classified as an error now. :VMDebug doesn't really give any useful information on what's actually going wrong.

... though for whatever reason, bisecting vim-visual-multi doesn't find a single good version, including for versions that I knew were good xd

onlycalm commented 3 years ago

2021-06-20_18-27-29

Here's more information. Press d in multi cursor mode to get an error message.

mg979 commented 3 years ago

@onlycalm that error looks like #75, you should either update vim or use nvim.

@LunarWatcher I don't know what to say, other than this: plugins can be made easily compatible with VM, they only need a command to be disabled and one to be reenabled. Autopairs has these commands, but they don't reset <cr> and <bs>, so VM overwrites them anyway. It's not something I can fix on my part, it's autopairs commands that are broken (imho).

onlycalm commented 3 years ago

@mg979 For the second question. Like you say. I updated VIM8.1 to VIM8.2 and it worked fine. Thanks for your help.

chancez commented 2 years ago

~I have the same issue with a different autopairs plugin: windwp/nvim-autopairs. It sounds like toggling the plugins keycaps is what's needed when the VM starts. How does one go about that?~

I found it was the backspace mapping and so I just disabled it, I can always use a different key for block mode.

vim.g.VM_maps = {
  ["I BS"] = '', -- disable backspace mapping
}
ronandalton commented 2 months ago

I just wanted to share my solution to the conflict with the windwp/nvim-autopairs plugin. This should allow backspace to continue to work for both plugins and get rid of the warning:

-- lazy.nvim plugin spec
return {
  'mg979/vim-visual-multi',
  init = function()
    -- Hack around issue with conflicting insert mode <BS> mapping
    -- between this plugin and nvim-autopairs
    vim.api.nvim_create_autocmd('User', {
      pattern = 'visual_multi_start',
      callback = function()
        pcall(vim.keymap.del, 'i', '<BS>', { buffer = 0 })
      end,
    })
    vim.api.nvim_create_autocmd('User', {
      pattern = 'visual_multi_exit',
      callback = function()
        require('nvim-autopairs').force_attach()
      end,
    })
  end,
}
ulises-castro commented 3 weeks ago

I just wanted to share my solution to the conflict with the windwp/nvim-autopairs plugin. This should allow backspace to continue to work for both plugins and get rid of the warning:

-- lazy.nvim plugin spec
return {
  'mg979/vim-visual-multi',
  init = function()
    -- Hack around issue with conflicting insert mode <BS> mapping
    -- between this plugin and nvim-autopairs
    vim.api.nvim_create_autocmd('User', {
      pattern = 'visual_multi_start',
      callback = function()
        pcall(vim.keymap.del, 'i', '<BS>', { buffer = 0 })
      end,
    })
    vim.api.nvim_create_autocmd('User', {
      pattern = 'visual_multi_exit',
      callback = function()
        require('nvim-autopairs').force_attach()
      end,
    })
  end,
}

Thank you, this solve my problem when I was working on TSX files.