micangl / cmp-vimtex

Vimtex source for nvim-cmp.
MIT License
78 stars 5 forks source link

Suppress error fired sometimes by `vimtex#bib#files` #19

Closed jdujava closed 6 months ago

jdujava commented 6 months ago

When opening .sty files, I would get the following error

Vim(append):Error executing lua callback: BufReadPost Autocommands for "*"..FileType Autocommands
for "tex" ..function vimtex#bib#files, line 14: Vim (let):E716: Key not present in Dictionary: "compiler"

I just wrapped the call in pcall and returned from function if the call was not successful, not sure if it is the right solution though.

micangl commented 6 months ago

It's a good idea, thanks for contributing!

Although, the error seems to be caused by vimtex#bib#files; maybe @lervag will be interested.

lervag commented 6 months ago

I believe vimtex#bib#files will no longer throw that error. Please update and check.

I'm curious, how did you reproduce the original issue here? I mean, in which context did vimtex#bib#files throw this error?

lervag commented 6 months ago

Also, IMHO, I think it is better to fix the errors upstream than to hide them with pcall. Thus, I would advice against using pcall here and instead open issues with VimTeX so that I can solve things properly.

micangl commented 6 months ago

The error was thrown when opening .sty files. Even when I tried with a newly created, empty one this happened.

I reverted the change and can confirm that the error is gone, thanks.

lervag commented 6 months ago

Ah, yes, that makes sense. VimTeX does "activate" for .sty files for some minimal integration support. But it does not load the compiler module, and thus vimtex#bib#files would not work as expected.