Skip to content

Preview

Luke Naylor edited this page Oct 20, 2024 · 5 revisions

important recent issue: https://github.com/rzukic/zed-latex/issues/33

Preview and forwards/backwards search

Zed does not provide an internal PDF viewer, however external PDF viewers (supporting synctex) can be set up to allow jumping to locations to and from Zed using texlab (see texlab to make sure that is set up). To set up your PDF viewer, see the corresponding texlab wiki page. Note that Zed does not appear to support the window/showDocument request. However when calling zed <file>:<line number>, any existing workspace and buffer will be reused instead of opening a new window. So this can be used instead of texlab inverse-search --input <file name> --line <line no> for any inverse-search command in the texlab wiki page.

Zathura example

For example if you have zathura installed and on $PATH, adapting the instructions from here to use in Zed would amount to adding the following to your Zed settings.json:

// ~/.config/zed/settings.json
{
  // ...
  "lsp": {
    "texlab": {
      "settings": {
        "texlab": {
          // ...
          "build": {
            "onSave": true,
            "forwardSearchAfter": true
          },
          "forwardSearch": {
            "executable": "zathura",
            "args": [
              "--synctex-forward",
              "%l:1:%f",
              "-x",
              "zed %%{input}:%%{line}",
              "%p"
            ]
          }
        }
      }
    }
  }
  // ...
}

For other PDF viewers, use the above as a model in conjunction with the relevant page in the texlab wiki. If the reader is interested in this extension providing presets for common PDF viewers, they can raise an issue on this extension's repository.

Note: the above example settings enable build-on-save and automatically forward-searches after build. texlab recommends triggering builds through it instead of elsewhere (i.e. running latexmk -pvc in a separate terminal), but there does not seem to be a way to trigger a build, or forward-search by texlab manually (see issue #19). So we recommend using these settings to automatically do these two things, as this is the only way for them to happen.

Clone this wiki locally