aspeddro / cmp-pandoc.nvim

Pandoc source for nvim-cmp
MIT License
38 stars 9 forks source link

No completion for last bibliography entry #4

Closed TerseTears closed 2 years ago

TerseTears commented 2 years ago

Hello.

I believe the issue is with this line of code: https://github.com/aspeddro/cmp-pandoc.nvim/blob/0bde46176e78d50773c02bcee8352ba19d3e7be3/lua/cmp_pandoc/parse.lua#L129

The extra \n to be matched is problematic if the bib file doesn't end with one, resulting in the last element to not show.

A possible fix is to just remove that \n at the end. I'm not sure how the code works exactly, but it seems that any bib element is collapsed between the outermost {} pair so the first \n seems enough to match the pattern correctly. Otherwise the solution is to combine the two separate matches (data:gmatch("@.-\n}\n") and data:gmatch("@.-\n}$")) since Lua doesn't support alternation.