-
Notifications
You must be signed in to change notification settings - Fork 4
Texlab
The language intelligence for LaTeX is all outsourced to texlab.
As of v0.0.7 of the extension, there should not be any need for the user to install texlab
, as it should be installed automatically.
If texlab
is already installed and on PATH, or its location is specified in Zed settings
("lsp.texlab.binary.path" and "lsp.texlab.binary.arguments"), then the corresponding executable is used instead (skipping the download).
The quickest way to notice if texlab
is running is to see if snippets and command names are being suggested:
Screencast.from.2024-11-15.15-41-15.mp4
Other features that should also work out of the box include (which you can test):
- go-to-definition and find-references on user defined commands (
\newcommand
) - rename user defined commands
- go-to-definition on file names that are
\input
ed or\import
ed
To make better use of the language intelligence, texlab
can be configured through some settings which are document here. In order to configure instances of texlab
invoked by Zed, you must add your configurations in a settings.json
file for Zed at a project (.zed/settings.json
), or global level (typically .config/zed/settings.json
), see zed setting files docs. In this setting file, add some
lsp settings.
These settings will include building on save, previewing, auto-indenting, linting,... and more fine-grained settings like adding extra environments
to behave like math environments.
Note that for a setting "texlab.x" in the texlab wiki, you would add an item "lsp.texlab.settings.texlab.x" in the Zed settings file (see below for a more explicit example).
Here is an example of such a configuration file from a user, setting up build on save with tectonic:
// ~/.config/zed/settings.json
{
"lsp": {
"texlab": {
"settings": {
"texlab": {
"latexindent": { "modifyLineBreaks": true },
"build": {
"onSave": true,
"executable": "tectonic",
"args": [
"-X",
"compile",
"%f",
"--untrusted",
"--synctex",
"--keep-logs",
"--keep-intermediates"
]
}
}
}
}
}
}
The relevant files for language server related stuff in this repo is src/*.rs
.
Relevant PR have the texlab tag.
When debugging issues related to interactions of Zed with texlab
it is useful to specify the path and arguments in Zed settings explicitly (see top of page). Specify CLI args -vvvv --log-file FILE
to dump maximally verbose logs into your choice of file FILE. The benefit of this is to access logs that happen earlier than when you are able to open the language server logs within Zed. Alternatively, launching the Zed with the command RUST_LOG=lsp=trace zed --foreground
will also paste the paste the RPC messages to stdout however it is mixed with other logs from Zed and is less verbose.