-
Notifications
You must be signed in to change notification settings - Fork 53
Project Detection
Whenever you open a TeX file in the editor, texlab
tries to find out all files that are part of the same project, meaning they are compiled into the same document. The server needs this information to implement most of its features. For example, packages imported in the preamble should be visible in other project files as well. In particular, the project is also used determine the root document, which is passed to the TeX engine when compiling.
The server does the following steps to figure out the project:
- Walk up the directory tree until we either reach the file system root (
/
), the home directory or a root directory (see below). For each directory along the way, we load all contained TeX files that we have not opened yet. - Next, we build a dependency tree by resolving include commands such as
\input
or\import
. The referenced files are added to the workspace. - Repeat this procedure until there are no more changes to the workspace
Due to the way, the TeX engine is designed, commands such as \input
operate on the working directory of the TeX engine instead on the directory of the parent source file. That's why we need to determine the root directory in the server.
texlab
walks up the directory tree of the document and tries the following steps in this order:
- Check if there is a
.texlabroot
/texlabroot
file. Then, the server uses thetexlab.build.auxDirectory
,texlab.build.logDirectory
andtexlab.build.pdfDirectory
settings to find the build artifacts and auxiliary files. - Check if there is a
Tectonic.toml
manifest. Then, the server uses thesrc
andbuild
directories and adds_preamble.tex
and_postamble.tex
to the project (if present). - Check if there is a
.latexmkrc
/latexmkrc
file. Then, the server uses the settings defined inside thelatexmkrc
. If failing to do so, thentexlab.build.auxDirectory
,texlab.build.logDirectory
andtexlab.build.pdfDirectory
are used as fallback. - Use the directory of the root source file. A root source file is a TeX document that has a
document
environment. Documents with\documentclass{subfiles}
are excluded.