Skip to content

Unable to Autocomplete Citations with Nvim-Cmp + Cmp-Omni #2596

@benbrastmckie

Description

@benbrastmckie

Description

I've been having troubles trying to get VimTex + nvim-cmp + cmp-omni to work well in Lua, and have been reading everything I can find to try to sort out the problem. I've followed the VimTex help docs and believe that I have it all configured in the right way, and get most of the functionality that I'm looking for, just no access to my .bib file in the autocomplete menu, and so I can't autocomplete citations.

Here are some other relevant issues:

Steps to reproduce

Here is a MWE which I named minimal.lua

-- PLUGINS --

vim.cmd [[packadd packer.nvim]]

-- Packer 
require('packer').startup(function(use)
  -- Have packer manage itself
  use { "wbthomason/packer.nvim" }
  -- Useful lua functions used by lots of plugins
  use { "nvim-lua/plenary.nvim" }


-- Cmp 
  use { "hrsh7th/nvim-cmp" }
	use { "hrsh7th/cmp-nvim-lsp" }
  -- buffer completions
  use { "hrsh7th/cmp-buffer" }
  -- helps Vimtex completions
  use { "hrsh7th/cmp-omni" }


-- LSP
  -- enable LSP
	use { "neovim/nvim-lspconfig" }
  -- simple to use language server installer
  use { "williamboman/mason.nvim" }
  use { "williamboman/mason-lspconfig.nvim" }


-- LaTeX
  -- Vimscript
  use { "lervag/vimtex" } -- Vimscript


-- Treesitter
	use { "nvim-treesitter/nvim-treesitter", commit = "8e763332b7bf7b3a426fd8707b7f5aa85823a5ac" }

end)


-- CMP -----------------------------------------------------------

local cmp = require("cmp")

cmp.setup {
  sources = {
    { name = "omni" },
    { name = "nvim_lsp" },
    { name = "buffer", keyword_length = 3 },
  },
}

-- VimTeX -----------------------------------------------------------

vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_syntax_enabled = 0
vim.g.vimtex_quickfix_enabled = 0

I was able to reproduce the observations above by running nvim -u minimal.lua minimal.tex. In case it is helpful, I also created a MW branch of my full config (I'm on the Lua branch until I can get full functionality out of VimTex). The same observations given above continue to apply. Any help or pointers about how to test the problem would be greatly appreciated.

NOTE: My config includes some files for tmux, alacrity, etc., so as to provide a complete package for those just starting off (i.e., academics with no experience working with the terminal etc., and so are stuck inside TexShop or Overleaf). I have not removed all of these files from the MWE since I can't imagine they are causing the problem.

Expected behavior

I expect to be able to autocomplete citations in the manner that I had working for my vimscript config.

Actual behavior

Here are some observations:

  • I don't get VimTex autocompletion for Bibtex sources upon writing \citet{} as expected.
  • I do get VimTex completions via Omni when writing \usepackage{}, so cmp-omni does seem to be working.
  • The VimTex menu also works great, so I can open pdfs while hovering over citations etc.
  • Upon triggering completion with when my cursor is here \citet{|}, I get the following error:
Error detected while processing function vimtex#complete#omnifunc[31]..167[6]..<SNR>107_filter_with_options[19]..<lambda>403:
line    1:
E716: Key not present in Dictionary: "mstr"

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: Garuda Linux
  Vim version: NVIM v0.8.0
  Has clientserver: true
  Servername: /run/user/1000/nvim.1726766.0

VimTeX project: LogicReligion
  base: LogicReligion.tex
  root: /home/benjamin/Documents/Philosophy/Papers/LogicReligion
  tex: /home/benjamin/Documents/Philosophy/Papers/LogicReligion/LogicReligion.tex
  main parser: current file verified
  document class: article
  packages: adjmulticol amsbsy amsfonts amsgen amsmath amsopn amssymb amstext atbegshi atbegshi-ltx atveryend atveryend-ltx auxhook bigintcalc bitset colonequals enumitem epstopdf-base etexcmds etoolbox fancyhdr float fontenc footmisc geometry gettitlestring graphics graphicx hycolor hyperref iftex ifvtex infwarerr intcalc keyval kvdefinekeys kvoptions kvsetkeys letltxmacro ltxcmds mathabx mathrsfs microtype multicol nameref natbib pdfescape pdftexcmds pgf pgfcomp-version-0-65 pgfcomp-version-1-18 pgfcore pgffor pgfkeys pgfmath pgfrcs pgfsubpic pgfsys pgftree refcount rerunfilecheck scrbase scrextend scrkbase scrlfile scrlfile-hook scrlogo setspace stmaryrd tikz tikz-qtree tipa titlesec tocloft trig uniquecounter url verbatim xcolor xstring
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    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