Closed brandon-feder closed 1 week ago
There's definitely a lot of texlab configuration that this extension could expose. I'm going to look into this soon, but for now if you haven't done so already, adding a .texlabroot
file next to the main tex file makes a bunch of stuff work.
Looking at this a little closer, texlab doesn't seem to have an equivalent configuration to "texDirs". In my experiments, it seems to pick things up correctly through \input
, \import
, \addbibresource
etc. If you didn't have the .texlabroot
file (just an empty text file) next to the main tex file, let me know what adding it changes.
There is still plenty to improve on the texlab utilisation though.
In accordance with this, adding the .texlabroot
helps texlab determine the root directory which, while good to know, does not solve my issue. I have a preamble called my-preamble.tex
in something like /home/username/Documents/latex-preamble
. Ideally, I would set some texlab variable so that by simply adding \input{my-preamble.tex}
to the top of a .tex
file in a completely different directory, texlab automatically looks for the my preamble in another directory, and I gain all the benefits of this extension. I'll let you know if I find a solution.
Based on clason's reply here: https://github.com/latex-lsp/texlab/issues/100 , it sounds like texlab is aware of the contents of the TEXINPUTS
environment variable.
I'll experiment with some stuff this weekend. But what I imagine could be a full solution would be for this extension to read in a "texInputs" workspace setting for latex, and then make sure texlab is invoked with the environment variable set accordingly.
Based on clason's reply here: latex-lsp/texlab#100 , it sounds like texlab is aware of the contents of the
TEXINPUTS
environment variable.
This turned out to be a premature reply before reading whole conversation. It seems that texlab
is not affected by TEXINPUTS
but it does read your personal texmf tree. For example, with texlive on linux, you can add a .sty
file to ~/texmf/tex/latex/
, run texhash ~/texmf
(instructions will differ in other setups).
Then you do seem to get:
For your situation with a personal "global" preamble, this might be the best solution. It's also agnostic to tools and text editors. All of this only works well for packages, but putting a .tex
file and \input
ing in will allow you to build the document correctly from my experiments, but you don't get the completions.
Otherwise, I think the course of action would be to convince the texlab project to include this configuration option, or read the TEXINPUTS
env var (the latter is more sensible in my opinion). Then work from there.
I have added some notes on the topic in the wiki FAQ. Closing as texlab
has no configuration setting that achieves what is asked.
Feel free to raise any other issues about migrating workflows from VSCode+LaTeX Workshop. Stuff can still be added to the wiki on the topic even if there is no work that can be done about it in the extension itself.
A recent texlab
PR puts this feature back on the table. I envision specifying the directories in settings.json
and then this extension would read it and set TEXINPUTS
accordingly when invoking the language server.
For later reference: https://github.com/latex-lsp/texlab/pull/1252
texlab
does not make use of initialization options, so that part of the zed settings could be repurposed for adding a texInputs
item as a list of strings. When implementing the method for providing the command to invoke the language server, this extension should set the environment variable accordingly, with colon separated directories on Linux/Mac, and do something sensible if the variable is already non-empty. On windows, the extension should explicitly fail or preemptively deal with it correctly (semicolon separated directories) to avoid hidden issues when Zed is released on Windows. In the latter case, check that forward/backward slashes behave as expected (be consistent with pdflatex).
Addressed by PR #37 to appear in release v0.1.2
How can I add project-specific additional paths so that texlab can find other
.tex
files. For example, in VSC I am using the LaTeX Workshop package which provides thelatex-workshop.latex.texDirs
setting for exactly this purpose.Great work on this extension so far!