micangl / cmp-vimtex

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

Crash/errors on unrecognized key type in bibliography #13

Closed elu00 closed 8 months ago

elu00 commented 8 months ago

Hi,

Thanks for the plugin! Unfortunately, I'm getting persistent crashes/error messages when loading in bibliographies from a couple collaborators: the reason seems to be an unrecognized key in the citation. The error I'm getting is

stack traceback:
    ...cal/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/parser.lua:64: in function 'format_entry'
    ...cal/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/parser.lua:143: in function 'callback'
    ...ocal/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/timer.lua:72: in function <...ocal/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/timer.lua:66>
Error executing vim.schedule lua callback: ...cal/share/nvim/lazy/cmp-vimtex/lua/cmp_vimtex/parser.lua:102: attempt to perform arithmetic on field 'lnum' (a nil value)`

and here's a MWE: 'test.tex'

\begin{document}
\title{this is a title}
\bibliography{test}

\end{document}

'test.bib'

@misc{Harvard-01,
    title = "something"
    key = {Harvard}
}

Thanks!

micangl commented 8 months ago

Thanks for raising the issue! I've just pushed a commit which, for me, has solved the problem

elu00 commented 8 months ago

Excellent, thanks! Works for me as well :)

DubiousCactus commented 1 month ago

Sorry to reopen this issue but I'm getting crashes myself. I have 3000+ lines in my .bib file but I found the culprit. Turns out it's my own paper hahah!

So this causes the crash:

@inproceedings{
morales2022a,
title={A new benchmark for group distribution shifts in hand grasp regression for object manipulation. Can meta-learning raise the bar?},
author={Th{\'e}o Morales and Gerard Lacey},
booktitle={NeurIPS 2022 Workshop on Distribution Shifts: Connecting Methods and Applications},
year={2022},
url={https://openreview.net/forum?id=IKbA3QS7c8X}
}

and the fix is to reformat it as:

@inproceedings{morales2022a,
title={A new benchmark for group distribution shifts in hand grasp regression for object manipulation. Can meta-learning raise the bar?},
author={Th{\'e}o Morales and Gerard Lacey},
booktitle={NeurIPS 2022 Workshop on Distribution Shifts: Connecting Methods and Applications},
year={2022},
url={https://openreview.net/forum?id=IKbA3QS7c8X}
}