Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
seyaryuki opened this issue Sep 23, 2021 · 3 comments
Closed

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

seyaryuki opened this issue Sep 23, 2021 · 3 comments
Labels

Comments

@seyaryuki
Copy link

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
@lervag
Copy link
Owner

lervag commented Sep 23, 2021

Again, as in #2156, this is not a VimTeX issue. I'm quite certain it is a conflict with the completion menu and that it may not be easy to fix, but I've opened an issue at the coc.nvim repo to check. It may be closed quickly, but it may also turn out that this is indeed a bug that can be resolved.

@lervag lervag closed this as completed Sep 23, 2021
@ghost
Copy link

ghost commented Mar 23, 2022

@lervag I hope this is the correct place to put this — let me know if I should make a new issue. After some discussion in the coc.nvim issue you mentioned, you pushed this workaround to the VimTeX repo. I've found this doesn't work properly for certain values of tabstop and shiftwidth when noexpandtab is set on nvim 0.7 and vim 8.2

Here's a minimal.vim for Neovim:

lua require("packer").startup(function() use "lervag/vimtex" end)
set noexpandtab
set tabstop=4
set shiftwidth=0

and a minimal.tex:

\documentclass{minimal}
\begin{document}
\begin{enumerate}
	\item Foo.
\end{enumerate}
\end{document}

To reproduce, go to the line containing the \item and press

o\ite<C-x><C-o><Space>

This will give

	\i |tem

instead of the expected

	\item |

(Here | is the cursor.)

lervag added a commit that referenced this issue Mar 24, 2022
@lervag
Copy link
Owner

lervag commented Mar 24, 2022

I looked into it, and it seems it works well when I simplify the code. This may introduce a regression, but I tried to find a case where the code I removed actually does anything useful and I couldn't... crossing my fingers. 🤞🏻

lervag added a commit that referenced this issue May 7, 2022
Using a more specific indentkeys setting (see #2382) means the fix for
the issues #2179 and #2156 are no longer necessary.

refer: #2382, #2179, #2156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants