From 9c9091ca7b7db56ebd0c7a150aec7ac18976a070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Thu, 29 Dec 2016 19:27:50 +0100 Subject: [PATCH] Fixed #614: Better citation completion - Support \jobname in bibliography file name - Support \nobibliography - Support \bibentry for completion --- autoload/vimtex/complete.vim | 10 +++++++--- test/issues/614/test.tex | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 test/issues/614/test.tex diff --git a/autoload/vimtex/complete.vim b/autoload/vimtex/complete.vim index 00f3c87..dde4905 100644 --- a/autoload/vimtex/complete.vim +++ b/autoload/vimtex/complete.vim @@ -76,9 +76,12 @@ endfunction " {{{1 Bibtex let s:bib = { - \ 'patterns' : ['\v\\\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*$'], + \ 'patterns' : [ + \ '\v\\\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*$', + \ '\v\\bibentry\s*\{[^}]*$', + \ ], \ 'bibs' : '''\v%(%(\\@:p:h') . '/vimcomplete', @@ -231,7 +234,8 @@ function! s:bib.find_bibs() dict " {{{2 let l:bibfiles = [] for l:entry in map(filter(l:lines, 'v:val =~ ' . self.bibs), - \ 'matchstr(v:val, ' . self.bibs . ')') + \ 'matchstr(v:val, ' . self.bibs . ')') + let l:entry = substitute(l:entry, '\\jobname', b:vimtex.name, 'g') let l:bibfiles += map(split(l:entry, ','), 'fnamemodify(v:val, '':r'')') endfor diff --git a/test/issues/614/test.tex b/test/issues/614/test.tex new file mode 100644 index 0000000..9c5dffa --- /dev/null +++ b/test/issues/614/test.tex @@ -0,0 +1,24 @@ +\documentclass{article} +\usepackage{natbib} +\usepackage{bibentry} + +\bibliographystyle{apalike} +\nobibliography{\jobname} + +% This is the sample bib file +\begin{filecontents}{\jobname.bib} + @book{Saussure1995, + Author = {Ferdinand de Saussure}, + Origyear = {1916}, + Publisher = {Payot}, + Title = {Cours de Linguistique G{\'e}n{\'e}rale}, + Year = {1995} + } +\end{filecontents} +\begin{document} + +This is a complete citation in the middle of the text: + +\bibentry{ + +\end{document}