-
Notifications
You must be signed in to change notification settings - Fork 4
Preview
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). Forward search is when you place your cursor in Zed to a position in the LaTeX file and then jump to the corresponding position in the PDF and possibly highlight a more specific section.
Backwards, or inverse, search is the opposite, where you click somewhere on the PDF (usually whilst also holding a modifier key, ctrl, alt, or shift) to then open Zed at the correct file and place the cursor in the corresponding position.
If any of the following PDF viewer executables are found on PATH, then this extension will configure the texlab
workspace settings to enable forward-search out of the box:
- zathura
- skim (only on MacOS, and the standard install location is searched instead of PATH)
- sioyek
- okular
- qpdfview
try
which PDFVIEWER
for one of the above options (apart from skim) in the Zed terminal to check that the location can be found before raising an issue
In addition to auto configuring forward-search, this extension will also configure inverse-search out of the box for:
- zathura
- sioyek
The others require adjusting settings within the PDF viewer, see the inverse search section below.
A custom configuration may be necessary if your PDF viewer needs a special command to launch or for other bespoke situations (such as building inside a container).
To set up your PDF viewer, edit your "lsp.texlab.settings.texlab.forwardSearch" Zed settings in accordance with 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.
Here is an example of the (equivalent) configuration which this extension automatically sets if zathura is installed and on $PATH.
// ~/.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. The reader may also find the following useful to model off the automatic configurations provided by this extension when a suitable PDF viewer is found: https://github.com/rzukic/zed-latex/blob/main/src/preview_presets.rs.
Note: the above example settings enable build-on-save and automatically forward-searches after build. The custom capabilities from texlab
to make requests to build and forward search (manually instead of on save) are not yet usable from Zed (see issue #19).
Some PDF viewers require you to adjust settings from within the GUI to enable inverse-search, whereas others can have these settings adjusted from the CLI arguments used to invoke them. In the latter case, the auto configs will set this up correctly without user input. Otherwise, for the following, the settings need adjusting:
- skim
- okular
- qpdfview
The PDF viewer will work out which LaTeX file and line number corresponds to where you click, it just needs to be provided with a command to open that location in the text editor. In our case, that command is zed "FILE":LINENO
. Find your PDF viewer in the corresponding texlab wiki page for more help.