Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lua/cmp_vimtex/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ parser.parse_string = function(self, line)
end

parser.parse_entry = function(self, line)
-- The cite key is not required to share a line with "@type{" (this is how
-- OpenReview exports its BibTeX). When parse_type could not find it, pick
-- it up from the first subsequent line that supplies it.
if self.current.cite_key == nil then
local key = vim.fn['matchlist'](line, [[\v^\s*([^, ]+)\s*,\s*(.*)]])
if self.empty(key) then
self.current.body = self.current.body .. line
return false
end
self.current.cite_key = key[2]
line = key[3]
end

self.current.level = self.current.level + vim.fn['cmp_vimtex#count'](line, '{') - vim.fn['cmp_vimtex#count'](line, '}')
if self.current.level > 0 then
self.current.body = self.current.body .. line
Expand Down Expand Up @@ -329,6 +342,10 @@ parser.empty = function(list)
return false
end
end

-- nil (e.g. an out-of-range matchlist() result) counts as empty; without
-- this the guards above silently fall through on a nil argument.
return true
end

return parser