neoclide / coc-snippets

Snippets solution for coc.nvim
969 stars 41 forks source link

Compatibility issue with andymass/vim-matchup #328

Open moetayuko opened 1 year ago

moetayuko commented 1 year ago

https://github.com/andymass/vim-matchup is a popular vim plugin. However, the cursor doesn't behave as expected after expanding some snippets.

MWE

call plug#begin()
 Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
 Plug 'honza/vim-snippets'
 Plug 'andymass/vim-matchup'
call plug#end()
set nocp
let g:tex_flavor = "latex"
let g:coc_global_extensions = [
      \ 'coc-snippets',
      \ ]
imap <C-l> <Plug>(coc-snippets-expand)

To reproduce

  1. vim t.tex
  2. type beg<ctrl_l>

The snippet expands correctly, but the cursor doesn't locate at the expected position.

Expected (w/o vim-matchup)

| denotes cursor position

\begin{|}

\end{}

Current (w/ vim-matchup)

\be|gin{}

\end{}

It's worth noting that https://github.com/SirVer/ultisnips works correctly with vim-matchup

kevin61416 commented 1 year ago

I encountered the same issue 🥲 Any update about this?

JS-Zheng commented 1 year ago

Dear maintainers @chemzqm @fannheyward, I discovered that vim-matchup has these two commands:

:NoMatchParen       Disable matching after the plugin was loaded.
:DoMatchParen       Enable matching again.

The issue can be fixed by using :NoMatchParen before auto-completion, and using :DoMatchParen after auto-completion.

However, I was unable to find a suitable autocmd to call these commands automatically.

Could you consider adding autocmds like CocPumCanceled, CocCompletionDone? This way, users could manually call :NoMatchParen to temporarily disable vim-matchup or other conflicting plugins when invoking coc#refresh(), and let these autocmds actively call :DoMatchParen to restore the operation of vim-matchup.

fannheyward commented 1 year ago

@JS-Zheng there's CompleteStop autocmd, does it work for your case?

JS-Zheng commented 1 year ago

@JS-Zheng there's CompleteStop autocmd, does it work for your case?

I only discovered the following coc autocmds in Vim:

CocLocationsChange, CocNvimInit, CocStatusChange, CocDiagnosticChange, 
CocJumpPlaceholder, CocOpenFloat, CocOpenFloatPrompt & CocTerminalOpen

I believe CompleteStop is a RPC event, not an autocmd, correct?