Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bib completion not working #133

Closed
petobens opened this issue Oct 5, 2013 · 29 comments
Closed

Bib completion not working #133

petobens opened this issue Oct 5, 2013 · 29 comments

Comments

@petobens
Copy link

petobens commented Oct 5, 2013

I was mostly completing my citations using tag files generated by ctags from the relevant bib file and today I decided to try the omni complete function. However when I tested it with a simple document as

\documentclass{article}
\usepackage{biblatex}
\addbibresource{test.bib}

\begin{document}
\textcite{
\printbibliography
\end{document}

where test.bib is

@Article{doe10,
author  = {John Doe},
title   = {Foo},
journal = {Bar Journal},
year    = {2010},
volume  = {11},
number  = {1},
pages   = {110-113}
}

I got the following error:

Error detected while processing function LatexBox_Complete..LatexBox_BibCompelte..LatexBox_Bibsearch:
E484: Can't open file C:/Users/Pedro/Desktop/blah/_LatexBox_BibComplete.bbl
Pattern not found

Is bib completion suppose to work on MS Windows? I believe kpsewhich works with Miktex. Thanks in advance for the help.

@lervag
Copy link

lervag commented Oct 5, 2013

Hi!

I think the problem is in ftplugin/latex-box/complete.vim line 250:

silent execute '! cd ' shellescape(LatexBox_GetTexRoot()) .
                       \ ' ; bibtex -terse '
                       \ . fnamemodify(auxfile, ':t') . ' >/dev/null'

First: I am not sure if bibtex is accepted as an executable in windows? Next, >/dev/null should probably be >nul on windows.

However, since I dont use windows, I am not able to debug this case myself. Perhaps you could try to fix the mentioned line, and if you find an expression that works on windows, then I can add it and push a fix?

@petobens
Copy link
Author

petobens commented Oct 5, 2013

I don't know if bibtex is accepted as an executable. Hope the image below helps. I changed >/dev/null to >nul but the problem persists. If there is anything else I can test to help you fix it just tell me and I''ll happily do it. Thanks

bibtexcmd

@lervag
Copy link

lervag commented Oct 5, 2013

This indicates that bibtex is accepted as executable. You can try to remove the silent flag and the >nul to get more output. Perhaps that will give an indication on what's wrong.

@petobens
Copy link
Author

petobens commented Oct 5, 2013

I removed the silent flag and the error that I get is:

The filename, directory name, or volume label syntax is incorrect

@lervag
Copy link

lervag commented Oct 6, 2013

Hmm. Could you try with

execute '! cd /D ' shellescape(LatexBox_GetTexRoot()) .
                       \ ' & bibtex -terse '
                       \ . fnamemodify(auxfile, ':t')

If it works, could you also try with

silent execute '! cd /D ' shellescape(LatexBox_GetTexRoot()) .
                       \ ' & bibtex -terse '
                       \ . fnamemodify(auxfile, ':t') . '>nul'

Thanks!

@petobens
Copy link
Author

petobens commented Oct 7, 2013

Unluckily I'm getting the same error as before. I will however test again tomorrow. Thanks for the help and patience.

@lervag
Copy link

lervag commented Oct 7, 2013

That's strange and unfortunate. Let me know if/when you find anything. At least I am pretty sure this is where the error is.

@petobens
Copy link
Author

petobens commented Oct 7, 2013

If I set in my vimrc

set noshellslash

And write in complete.vim the problematic lines as:

silent execute '! cd ' shellescape(LatexBox_GetTexRoot()) .
           \ ' & bibtex -terse ' . fnamemodify(auxfile, ':t') . ' >nul'

then there are no errors but I don't get any completion! I just says

Pattern not found

@lervag
Copy link

lervag commented Oct 7, 2013

Interesting. Note that silent removes all error messages, and so does >nul! So you should make sure to try

execute '! cd ' shellescape(LatexBox_GetTexRoot()) .
       \ ' & bibtex -terse ' . fnamemodify(auxfile, ':t')

and see if it produces any error messages. It would also be helpful for me if you could add

echom shellescape(LatexBox_GetTexRoot())

just before this line and copy the output here. echom will write a message that should appear after the completion has been begun. If you don't see it, try :messages after you try completion.

If all files are in the same root directory, then you could also simply try

execute '!bibtex -terse ' . fnamemodify(auxfile, ':t')

Or perhaps:

execute '!bibtex -terse ' . shellescape(fnamemodify(auxfile, ':t'))

@petobens
Copy link
Author

petobens commented Oct 7, 2013

When I try with

execute '! cd ' shellescape(LatexBox_GetTexRoot()) .
       \ ' & bibtex -terse ' . fnamemodify(auxfile, ':t')

I get the output that is seen in the image. On the other hand

echom shellescape(LatexBox_GetTexRoot())

gives

"C:\Users\Pedro\Desktop\blah"

which i think is the expected (correct) result.
biberror

@lervag
Copy link

lervag commented Oct 7, 2013

I think we are getting closer. Could you try to change test.bib to simply test in your tex file?

@lervag
Copy link

lervag commented Oct 7, 2013

Btw: What version of bibtex are you using?

@lervag
Copy link

lervag commented Oct 7, 2013

To be more specific, I think the error is in the bibtex command, as you see in your screenshot. For some reason, bibtex tries to search test.bib.bib, which is very strange. I have tested your case on my linux machine, and here everything works as expected.

Perhaps if you make a file test2.aux with:

\citation{*}
\bibstyle{/path/to/bundle/LaTeX-Box/ftplugin/latex-box/vimcomplete.bst}
\bibdata{test.bib}

And then run

bibtex -terse test2.aux

And report the output. Oh, hmm... perhaps the problem is the path for the bst file? Could you also try to add echom s:bstfile to complete.vim and report the output?

@petobens
Copy link
Author

petobens commented Oct 8, 2013

Replacing test.bib by test in \addbibresource solves the problem. However, since I'm using biblatex, when using \addbibresource one needs to add the .bib extension (this is specified in the documentation and errors appear if the extension is removed). Note that for it to work under MS Windows I've changed the relevant complete.vim file lines like this

silent execute '! cd ' shellescape(LatexBox_GetTexRoot()) .
            \ ' & bibtex -terse '
             \ . fnamemodify(auxfile, ':t') . ' >nul'

and also set in my vimrc:

set noshellslash

So is there a way to avoid searching for test.bib.bib?

@petobens
Copy link
Author

petobens commented Oct 8, 2013

I'm using Bibtex version 2.9.4360 (0.99d) and doing the tests with test2.aux gives result shown in the following image.

bibtest

@lervag
Copy link

lervag commented Oct 8, 2013

This really is strange. When I try to reproduce, I also get that the database becomes test.bib.bib. However, bibtex completes successfully with no error.

It seems that the problem can be solved if we remove the extensions, since bibtex obviously does not need the extension. Could you try to change

return join(bibdata_list, ',')

with

return join(map(bibdata_list, 'fnamemodify(v:val, '':r'')'), ',')

at the end of s:FindBibData() and use the fixed silent execute ... line, and see if it works with your original problem?

@lervag lervag closed this as completed in 7dadd01 Oct 8, 2013
@lervag
Copy link

lervag commented Oct 8, 2013

I think I fixed it now, please test.

@petobens
Copy link
Author

petobens commented Oct 8, 2013

Thank you! That works great. I was wondering whether you could also make it work when setting
set shellslash in my vimrc. If I do so I get the following error

The filename, directory name, or volume label syntax is incorrect
I couldn't open file name '_LatexBox_BibComplete.aux'

@lervag
Copy link

lervag commented Oct 8, 2013

Could you add

echom shellescape(LatexBox_GetTexRoot())
echom fnamemodify(auxfile, ':t')

just before the execution line, so that I can see what the problem is when shellslash is on?

@petobens
Copy link
Author

petobens commented Oct 8, 2013

Sure. Here it goes:

shellslasherror

@petobens
Copy link
Author

petobens commented Oct 8, 2013

This may also help: the first image shows the console with set noshellslash and the second one (not working) with set shellslash.
noshellslash
withshellslash

lervag added a commit that referenced this issue Oct 8, 2013
@lervag
Copy link

lervag commented Oct 8, 2013

Can you try now? I added a very quick and dirty fix, and I am not sure if it works...

@petobens
Copy link
Author

petobens commented Oct 8, 2013

The completion eventually works but an error message appears:

E474: Invalid argument: shellslash=1

And the shellslash option is not restored properly.

@petobens
Copy link
Author

petobens commented Oct 8, 2013

Setting it like this seems to work:

let l:old_shellslash = &l:shellslash
setlocal noshellslash
silent execute '! cd ' shellescape(LatexBox_GetTexRoot()) .
        \ ' & bibtex -terse '
        \ . fnamemodify(auxfile, ':t') . ' >nul'
let &l:shellslash = l:old_shellslash 

@lervag
Copy link

lervag commented Oct 8, 2013

Thanks! I updated. Does everything work as it should now?

@petobens
Copy link
Author

petobens commented Oct 8, 2013

Yes! Thank you so much. It works great, so much nicer than completing with ctags. One minor question, is there a reason to have upper case letter for the book type but not for instance for articles or collections? This can be seen in the image below:

uppercasecomplete

@lervag
Copy link

lervag commented Oct 8, 2013

Good question. I don't know, but there might be. Perhaps there are entries where upper and lower case means different things? I don't want to change it unless you can give a good reason why I should.

@petobens
Copy link
Author

petobens commented Oct 8, 2013

Ahhh it is used to distinguish between "book" type and "in book" type. Thanks for all the great help and patience!

@lervag
Copy link

lervag commented Oct 8, 2013

No problem, I'm happy to help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants