James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.47k stars 519 forks source link

Allow bibtex Intellisense for all detected bib files #4218

Closed setchin closed 4 months ago

setchin commented 4 months ago

Please fill the following fields with a star (*) and provide as much related information as possible.

Pre-checks*

Please change the following [ ] to [x] for confirmation.

  • [x] The feature request has not been suggested in this repository.

The Missed*

Is your feature request related to a problem? Please provide a clear and concise description of what the problem is.

Some latex templates include codes that set bibliography style, resolve bibliography file path, etc. In this case, LaTeX workshop cannot determine which bib file has been loaded, and Intellisense is disabled, similar to #3479.

Manually adding \bibresource{path} to main.tex can solve the problem, however, it likely to cause package option clashes if the .cls file has loaded related packages, and it will cost much effort to modify the .cls file to make Intellisense work. (Or you have to always comment out the line before compiling)

The Solution*

Please provide a solution you would like to have.

Would it be possible to allow Intellisense for all detected bib files defined in bibDirs? It is possible that users do forget to set sthe correct file path and cite bib items from a not included file, but LaTeX will throw explicit warnings about undefined references, which I believe is much more easier to debug. A safer way could be adding a switch to turn this feature on.

Anything Else?

Add any other context about the feature request below.

James-Yu commented 4 months ago

Thank you for the feature request. Unfortunately, this feature will very likely pollute the suggestion list if the class file does not include these bibs. Can you please help check whether the said bib file is present in the .fls file after compilation? If so, the extension should be able to pick it up.

setchin commented 4 months ago

Thank you for the feature request. Unfortunately, this feature will very likely pollute the suggestion list if the class file does not include these bibs. Can you please help check whether the said bib file is present in the .fls file after compilation? If so, the extension should be able to pick it up.

Hi, at least for the biblatex package with \addbibresource command, it will not input the file into .fls. The file name is however specified in .bcf with `

ref/reference.bib ` Do we parse .bcf?
jlelong commented 4 months ago

We do not parse the .bcf file but we do parse the .tex files to look for \addbibresource. If I understand correctly your issue. It seems to come from custom dir location of your .bib file. I think the setting latex-workshop.latex.bibDirs should be helpful.

Manually adding \bibresource{path} to main.tex can solve the problem, however, it likely to cause package option clashes if the .cls file has loaded related packages, and it will cost much effort to modify the .cls file to make Intellisense work.

Surround the command\bibresource{path} with \iffalse ... \fi. It will be ignored by the LaTeX compiler but LW will take it into account.