Texlab - rzukic/zed-latex GitHub Wiki

The language intelligence for LaTeX is all outsourced to texlab. There should not be any need for the user to install texlab, as it will be installed automatically if not found. 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).

Network issues should be dealt with gracefully, including falling back to a previously automatically downloaded version of texlab if necessary (everything still works when offline).

Is texlab running?

The quickest way to notice if texlab is running is to see if snippets and command names are being suggested:

https://github.com/user-attachments/assets/f0ec8aa6-b9e8-4321-befa-3d7c10ab0bd8

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 \inputed or \imported

Configuring texlab

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 workspace level (.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.

[!TIP] Check other pages in this wiki for document build, preview, formatting for specific guidance in Zed, with and without touching texlab settings.

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 enabling build on save in a case where the autoconfig does not find a suitable previewer:

// ~/.config/zed/settings.json
{
  "lsp": {
    "texlab": {
      "settings": {
        "texlab": {
          "build": {
            "onSave": true
          }
        }
      }
    }
  }
}

Dev notes

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.