Skip to content

Bad \item indent when coc.nvim completion box is displayed #2179

@seyaryuki

Description

@seyaryuki

Description

This is probably related to this issue (#2156) that I opened a few weeks ago, but I later noticed that YouCompleteMe was also breaking some of my UltiSnips snippets, so I switched from YCM to coc.nvim and the issue seemed to be gone.

But the problem reappeared sometimes, and I couldn't find a way to consistently reproduce it until today.

The problem is still the same : sometimes, typing \item in insert mode will not properly indent the current line.

Steps to reproduce

minivimrc:

set nocompatible
call plug#begin()
Plug 'lervag/vimtex'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
filetype plugin indent on
syntax enable

MWE test.tex:

\begin{itemize}
  \item foo
  \item bar
\end{itemize}

On the third line of this file (starting in normal mode):

  • if I type o\item fast enough so that coc.nvim's completion box does not have time to appear, the new \item gets properly aligned with the others;
  • but if I type o\item more slowly - for instance by typing o\ite, then waiting for coc.nvim's completion box to appear (it will suggest item and itemize on this example), then typing m to finish writing \item - the new \item does not get properly aligned and I get the following:
\begin{itemize}
  \item foo
  \item bar
    \item
\end{itemize}

Expected behavior

For \item to be properly idented even when coc.nvim's completion box is displayed.

Actual behavior

A new \item is not properly indented when coc.nvim's completion box is displayed while typing it.

I'm guessing the problem comes from a completion box being displayed while typing \item, whether using coc.nvim or another completion plugin.

Do you use a latexmkrc file?

Yes

VimtexInfo

System info
  OS: Debian GNU/Linux 11 (bullseye)
  Vim version: VIM 8.2 (1-2434)
  Has clientserver: true
  Servername: GVIM2

VimTeX project: test
  base: test.tex
  root: /home/seyaryuki/tmp/test_vimtex
  tex: /home/seyaryuki/tmp/test_vimtex/test.tex
  main parser: current file
  document class: 
  compiler: latexmk
    engine: -pdf
    options:
      -pdflatex="xelatex --shell-escape %O %S"
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    engine: -pdf
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    xwin id: 0
  qf method: LaTeX logfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions