-
Notifications
You must be signed in to change notification settings - Fork 64
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
\inputor\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/texlabrootfile. Then, the server uses thetexlab.build.auxDirectory,texlab.build.logDirectoryandtexlab.build.pdfDirectorysettings to find the build artifacts and auxiliary files. - Check if there is a
Tectonic.tomlmanifest. Then, the server uses thesrcandbuilddirectories and adds_preamble.texand_postamble.texto the project (if present). - Check if there is a
.latexmkrc/latexmkrcfile. Then, the server uses the settings defined inside thelatexmkrc. If failing to do so, thentexlab.build.auxDirectory,texlab.build.logDirectoryandtexlab.build.pdfDirectoryare used as fallback. - Use the directory of the root source file. A root source file is a TeX document that has a
documentenvironment. Documents with\documentclass{subfiles}are excluded.