Extra directories for LaTeX - rzukic/zed-latex GitHub Wiki
One thing to keep in mind if coming from VSCode with the LaTeX workshop extension is that the extension capabilities in Zed are much smaller, outsourcing all capabilities to external grammars and language servers (whereas LaTeX workshop does many things itself). When trying to replicate a setting or scenario from VSCode, most suggestions here will redirect to a solution outside the editor and this extension. Although the reader may possibly see this as frustrating, this could also be beneficial for reproducibility and collaboration by not relying on a specific editor.
Can I add extra directories to be picked up by the project?
Depending on your exact scenario, here are a few solutions to consider which work well with both independent LaTeX tooling, and the language intelligence received with this extension (go to definition, hover, autocomplete, etc...).
... for a personal preamble:
If you have some form of global preamble that you use in multiple projects, including it as a package in your personal texmf
tree is a good solution, at the cost of portability, and will work correctly with all latex tools with or without Zed, including texlab
(the language server used by this extension).
The instructions to do this will depend on your system and LaTeX distribution, and will likely involve some kind of "rehashing" step on top of just placing an .sty
file in the correct directory. See next solution for a more portable idea.
... for a sub-project:
If you have another directory containing files relating to a part of the content of the document, consider using \input
, \include
or \import
from the import
package. Both of these work well with the language intelligence provided by texlab
. The price to pay here is that the other directory needs to be specified each time, but for certain things such as bibliographies and figures, the "source" can also be specified only once (i.e. using \addbibresource
, \graphicspath
).
If needing a sub-project to appear in multiple other projects, which cannot just be a personal .sty
package, the author does not have a simple solution. One could also consider using Git submodules.
... for something else:
The environment variable TEXINPUTS
also provides extra locations for the LaTeX compiler to find files (and similarly BIBINPUTS
for bib files). TEXINPUTS
could be set in a latexmkrc
file to make latexmk
build the document correctly but this will not fix other texlab
features such as go-to-definition. For directories to be searched in all projects, you could set TEXINPUTS
in the init script for your shell (e.g. .bashrc). Alternatively set environment variables for language servers in the zed settings.
{
"lsp": {
"texlab": {
"binary": {
"env": {
"TEXINPUTS": ".:/extra/path/1/:extra_relative/path2/:",
"BIBINPUTS": ".:extrabiblocation:"
}
}
}
}
}
[!WARNING] The starting
.
is to make sure that the current directory is still checked for.tex
files, and the trailing:
is to make sure that system packages are still found.