ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
7.02k stars 232 forks source link

Inverse search not working with Sioyek and VS Code on macOS #1098

Open tsunho12 opened 3 months ago

tsunho12 commented 3 months ago

Issue Description

Describe the bug

I am trying to set up inverse search with Sioyek and VS Code using LaTeX Workshop on macOS. Sioyek successfully launches and displays the PDF, but inverse search is not working. The error message indicates the arguments for the inverse search command are not being properly substituted.

My VS Code Setting.json and prefs_user.config configuration

{
    "latex-workshop.view.pdf.external.viewer.command": "/Applications/sioyek.app/Contents/MacOS/sioyek",
    "latex-workshop.view.pdf.external.viewer.args": [
        "%PDF%"
    ],
    "latex-workshop.view.pdf.external.synctex.command": "/Applications/sioyek.app/Contents/MacOS/sioyek",
    "latex-workshop.view.pdf.external.synctex.args": [
        "--inverse-search",
        "\"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code\" -r -g \"%1:%2\"",
        "--reuse-instance",
        "--forward-search-file",
        "%TEX%",
        "--forward-search-line",
        "%LINE%",
        "%PDF%"
    ]
}
inverse_search_command "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" "/Applications/Visual Studio Code.app/Contents/Resources/app/out/cli.js" --ms-enable-electron-run-as-node -r -g "%1:%2"

Actual behavior

QString::arg: 1 argument(s) missing in "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" "/Applications/Visual Studio Code.app/Contents/Resources/app/out/cli.js" --ms-enable-electron-run-as-node -r -g "%1:%2"
Warning: 'ms-enable-electron-run-as-node' is not in the list of known options, but still passed to Electron/Chromium.

Desktop

Additional context

It seems that the %1 and %2 placeholders are not being correctly substituted. I have also tried using {input} and {line} placeholders, but the issue persists. Any guidance on how to properly configure inverse search with Sioyek and VS Code would be greatly appreciated.

Thank you for your help!

ahrm commented 3 months ago

Unfortunately I don't have access to a mac right now so I can't test it there, but maybe the issue is inverse_search_command? Here is what I use for inverse_search_command on windows:

inverse_search_command      "C:\path\to\Code.exe" -r -g "%1":%2
tsunho12 commented 3 months ago

Thanks you for your prompt response. I followed your suggestions and made adjustments to my prefs_user.config file. Now, I am able to jump from Sioyek to the LaTeX source code in VS Code.

inverse_search_command "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" -r -g "%1:%2"

However, I am still facing two issues:

  1. I am unable to open the compiled PDF from VS Code using Sioyek.
  2. I cannot jump from the LaTeX source VS Code to the corresponding location in the PDF opened with Sioyek.

When using the shortcut command to open the compiled PDF, the macOS activity bar indicates an action to start Sioyek, but Sioyek does not actually open.

The current version of manual still contain the problematic configuration that caused my initial issues. It would be beneficial for future uses if the manual could be updated to reflect the corrected configuration.

image
ahrm commented 3 months ago

Unfortunately I can't help right now because I am pretty sure these are macos-specific issues. Maybe someone else with mac can help?

arrowmancer commented 3 months ago

Thanks you for your prompt response. I followed your suggestions and made adjustments to my prefs_user.config file. Now, I am able to jump from Sioyek to the LaTeX source code in VS Code.

inverse_search_command "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" -r -g "%1:%2"

However, I am still facing two issues:

1. I am unable to open the compiled PDF from VS Code using Sioyek.

2. I cannot jump from the LaTeX source VS Code to the corresponding location in the PDF opened with Sioyek.

When using the shortcut command to open the compiled PDF, the macOS activity bar indicates an action to start Sioyek, but Sioyek does not actually open.

The current version of manual still contain the problematic configuration that caused my initial issues. It would be beneficial for future uses if the manual could be updated to reflect the corrected configuration. image

Hi Tsunho,

I am still currently facing your second issue as well:

2. I cannot jump from the LaTeX source VS Code to the corresponding location in the PDF opened with Sioyek.

and I have a feeling it is due to missing the command to the output of cli.js that we had to remove in order to have the reverse-mode (pdf -> source) synctex functioning in Sioyek.

For your first problem:

1. I am unable to open the compiled PDF from VS Code using Sioyek.

I'm able to open the PDF from vscode just fine, perhaps you are missing some latex-workshop.view.pdf configurations in your settings.json file? Here's mine for reference, where I am indicating to vscode (vscodium in my case, though it shouldn't matter) that I am using an external pdf viewer, and also where to find it:

"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "/Applications/sioyek.app/Contents/MacOS/sioyek",
"latex-workshop.view.pdf.external.viewer.args": [
        "%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "/Applications/sioyek.app/Contents/MacOS/sioyek",

Please let me know if you've found a way to get forward-mode (source code -> pdf) synctex to function!

tsunho12 commented 2 months ago

Thanks you for your prompt response. I followed your suggestions and made adjustments to my prefs_user.config file. Now, I am able to jump from Sioyek to the LaTeX source code in VS Code.

inverse_search_command "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" -r -g "%1:%2"

However, I am still facing two issues:

1. I am unable to open the compiled PDF from VS Code using Sioyek.

2. I cannot jump from the LaTeX source VS Code to the corresponding location in the PDF opened with Sioyek.

When using the shortcut command to open the compiled PDF, the macOS activity bar indicates an action to start Sioyek, but Sioyek does not actually open. The current version of manual still contain the problematic configuration that caused my initial issues. It would be beneficial for future uses if the manual could be updated to reflect the corrected configuration. image

Hi Tsunho,

I am still currently facing your second issue as well:

2. I cannot jump from the LaTeX source VS Code to the corresponding location in the PDF opened with Sioyek.

and I have a feeling it is due to missing the command to the output of cli.js that we had to remove in order to have the reverse-mode (pdf -> source) synctex functioning in Sioyek.

For your first problem:

1. I am unable to open the compiled PDF from VS Code using Sioyek.

I'm able to open the PDF from vscode just fine, perhaps you are missing some latex-workshop.view.pdf configurations in your settings.json file? Here's mine for reference, where I am indicating to vscode (vscodium in my case, though it shouldn't matter) that I am using an external pdf viewer, and also where to find it:

"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "/Applications/sioyek.app/Contents/MacOS/sioyek",
"latex-workshop.view.pdf.external.viewer.args": [
        "%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "/Applications/sioyek.app/Contents/MacOS/sioyek",

Please let me know if you've found a way to get forward-mode (source code -> pdf) synctex to function!

Thanks. Now, I can use Sioyek to open LaTeX compiled PDF files. After enabling SyncTeX mode, I can jump from the PDF to the LaTeX source code by right-clicking. However, I have not found a way to jump from the source code to the PDF file, nor can I trigger Sioyek to launch and open the compiled PDF. Therefore, I have switched to Skim, a PDF reader available only for Mac.