Skip to content

vimtex + nvim-cmp crash when typing *some* commands #2653

@dajuno

Description

@dajuno

Description

Hi all,
the good: latex completion using nvim-cmp seems to be working generally. But when I type some commands, nvim and it's containing terminal crash.

For example, in the below MWE, typing \be (e.g., for \begin or \beta) will show completion for commands starting with be, then crash, making vimtex+nvim-cmp impossible to use together. Other latex commands are fine.

The crash always happens when typing \be after \begin{document}, but only about 50% of the time when typed in the preamble. Super weird.

Not sure if related, but with the setup below entering insert mode (by hitting i, a, o, etc) gives this error message:

E5108: Error executing lua [string "v:lua"]:1: attempt to index field 'utils' (a nil value)                  
stack traceback:
        [string "v:lua"]:1: in main chunk

This does not happen with my full config, where the crashes happen, too (and for more commands! e.g. \au, \da, ...)

Steps to reproduce

  1. Run nvim -u minimal.vim minimal.tex
  2. Type in the document body: \be
  3. Observe crash or repeat

minimal.tex

\documentclass{minimal}
\begin{document}
Test
\end{document}

minimal.vim

call plug#begin('~/.config/nvim/plugged')
    Plug 'hrsh7th/cmp-omni'
    Plug 'hrsh7th/nvim-cmp'
    Plug 'lervag/vimtex'
call plug#end()

lua << EOF
-- Adjust VimTeX config
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_syntax_enabled = 0
vim.g.vimtex_quickfix_enabled = 0

-- Setup nvim-cmp
cmp = require("cmp")
cmp.setup {
  sources = cmp.config.sources {
    { name = "omni", },
  },
}
EOF

Expected behavior

Should not crash.

Actual behavior

  1. error message whenever entering nvim's insert mode:

    E5108: Error executing lua [string "v:lua"]:1: attempt to index field 'utils' (a nil value)                  
    stack traceback:
            [string "v:lua"]:1: in main chunk
    
  2. nvim + terminal crash

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Linux 6.2.1-arch1-1
  Vim version: NVIM v0.8.3
  Has clientserver: true
  Servername: /run/user/1000/nvim.72546.0

VimTeX project: minimal
  base: minimal.tex
  root: /home/david/mwe_tex
  tex: /home/david/mwe_tex/minimal.tex
  main parser: current file verified
  document class: minimal
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    xwin id: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions