Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty getting Okular inverse search to work #2870

Closed
TryerGit opened this issue Jan 14, 2024 · 7 comments
Closed

Difficulty getting Okular inverse search to work #2870

TryerGit opened this issue Jan 14, 2024 · 7 comments
Labels

Comments

@TryerGit
Copy link

TryerGit commented Jan 14, 2024

Description

On Linux, I am able to get Okular forward search to work fine. I am unable to get backward search to work.

Steps to reproduce

My vimrc is:

let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
if empty(v:servername) && exists('*remote_startserver')
  call remote_startserver('VIM')
endif

if empty(glob('~/.vim/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()

My main.tex which I call via vim main.tex in a folder containing the .tex file and above .vimrc is:

\documentclass{article}
\begin{document}
Page 1

\newpage
Page 2

\newpage
Page 3
\end{document}

Extra white space in the .tex file is to ensure that backward search actually working. The pdf output spans 3 pages long even without the extra white space.

EDIT by @lervag: The extra white space is not necessary to test backward search and adds unnecessary scrolling when viewing the issue.

Forward search works fine with \lv from within the .tex to the output pdf file, taking me to each of the 3 pages on demand. Inverse search with "Shift + Left Mouse Click" on the Okular pdf file location, however, does not work.

I indeed have set within "Configure Okular dialog box" following https://docs.kde.org/stable5/en/okular/okular/inverse_search.html the setup of "Custom Text Editor" with Command: vim --remote-silent +%l %f

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

No.

VimtexInfo

System info:
  OS: Ubuntu 20.04.6 LTS
  Vim version: VIM 9.0 (1-2009)
  Has clientserver: true
  Servername: VIM

VimTeX project: main
  base: main.tex
  root: /home/TryerGit/GoogleDrive/research_programming/Setup Folder/latex/okular_reverse_search
  tex: /home/TryerGit/GoogleDrive/research_programming/Setup Folder/latex/okular_reverse_search/main.tex
  main parser: fallback current file
  document class: 
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: process 6917 run
      output: /tmp/vC8PC7M/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -view=none -e '$compiling_cmd = ($compiling_cmd ? $compilin
g_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'main.tex'
      pid: 6917
  viewer: General
    job: 
      pid: 7185
      cmd: okular --unique file:'/home/TryerGit/GoogleDrive/research_programming/Setup Folder/latex/okular_reverse_search/main.pdf'\#src:86'/home/TryerGit/GoogleDrive/research_programming/Setup Folder/latex/okular_reverse_search/main.tex'
  qf method: LaTeX logfile
~
@TryerGit TryerGit added the bug label Jan 14, 2024
@lervag
Copy link
Owner

lervag commented Jan 14, 2024

My main.tex which I call via vim main.tex in a folder containing the .tex file and above .vimrc is: …

FYI: I updated your example and removed the unnecessary white space.

Inverse search with "Shift + Left Mouse Click" on the Okular pdf file location, however, does not work.

I indeed have set within "Configure Okular dialog box" following https://docs.kde.org/stable5/en/okular/okular/inverse_search.html the setup of "Custom Text Editor" with Command: vim --remote-silent +%l %f

Ah, but you didn't set it following the VimTeX docs. ;)

Please see :help vimtex-view-okular and :help vimtex-synctex-inverse-search. I'll be glad to help if you still find it hard to set up, but I believe the docs should give the necessary info.

@lervag lervag closed this as completed Jan 14, 2024
@TryerGit
Copy link
Author

TryerGit commented Jan 14, 2024

I am still struggling, @lervag .

Are you referring to the line?

To configure with `VimtexInverseSearch`, use: >bash

  vim -v --not-a-term -T dumb -c "VimtexInverseSearch %l '%f'"

in https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt

Initially, I was confused about the >bash at the beginning line there before I opened this issue. Then, after your post, when I looked into :help from within Vim, I realized that the >bash is used for formatting purposes. (something new is learned everyday!)

In any case, I put in vim -v --not-a-term -T dumb -c "VimtexInverseSearch %l '%f'" into the command argument of Okular and tried it again and it still does not work. Is there a way to capture within Vim (some debug output?) what is happening when Shift Click is pressed in Okular?

Thanks for your patient help.

----Edit---
I should add that :echo serverlist() does return VIM, so I would imagine that the server is indeed running on my Vim side.

@lervag
Copy link
Owner

lervag commented Jan 14, 2024

You can try to run the command from a terminal. E.g.:

  1. Open your LaTeX file (e.g. test.tex) with Vim like you normally would.
  2. Verify that you have a servername (e.g. with \li).
  3. Compile the file from VimTeX.
  4. In a different terminal, cd to the directory where your LaTeX file is.
  5. Run vim -v --not-a-term -T dumb -c "VimtexInverseSearch 3 'test.tex'" in the terminal.

This should move your cursor to line 3 inside the VimTeX buffer. If it works as expected, then we should be able to make it work in Okular as well.

While debugging in Okular, one simple trick is to use echo CMD ARGS > /home/USER/okular.log. E.g., you can try to use echo "vim -v --not-a-term -T dumb -c ""VimtexInverseSearch %l '%f'"" > /home/USER/okular.log" (notice how "" becomes a single double quote within a double quoted string).

@TryerGit
Copy link
Author

TryerGit commented Jan 14, 2024

I am able to confirm that your steps 1 through 5 indeed work as you describe.
When I copy pasted your echo command modifying USER appropriately, strangely, no log file is created in /home/USER

Perhaps this is a bug with Okular than. :-(

I tried within Okular simply echo "pwd > /home/TryerGit/Okular.log" and this also does not create any log file.

@TryerGit
Copy link
Author

@lervag

I installed qpdfview and it seems to work. So, all is well now. In the qpdfview documentation, perhaps you can consider adding the place where the setting should be specified. I could not find it specified otherwise.

It is in Edit->Setting->Source Editor->vim -v --not-a-term -T dumb -c "VimtexInverseSearch %2 '%1'"

Then, rightclicking on the document pdf opens up a popup the first option of which is the file / line number of the .tex file.
Thank you!

@lervag
Copy link
Owner

lervag commented Jan 14, 2024

I am able to confirm that your steps 1 through 5 indeed work as you describe. When I copy pasted your echo command modifying USER appropriately, strangely, no log file is created in /home/USER

Perhaps this is a bug with Okular than. :-(

My initial thought is that you may be using the wrong sequence for activating backward search? E.g., perhaps it is CTRL + right click? I'm not sure, but that would be one thing to look into.

I tried within Okular simply echo "pwd > /home/TryerGit/Okular.log" and this also does not create any log file.

You should use echo "pwd" > /home/TryerGit/Okular.log (or echo $PWD ...).

I installed qpdfview and it seems to work. So, all is well now. In the qpdfview documentation, perhaps you can consider adding the place where the setting should be specified. I could not find it specified otherwise.

I'm glad to hear it! I've found qpdfview to be a solid viewer (although I personally prefer Zathura). And thanks, I'll update the docs.

lervag added a commit that referenced this issue Jan 14, 2024
@TryerGit
Copy link
Author

TryerGit commented Jan 14, 2024

Just wanted to close the loop in terms of my tests thus far. While reverse-search seems to work in single .tex files, somehow neither Okular/Zathura/qpdfview seem to work for me with multi-file projects. Time permitting, I will create some minimal working example and share it.
----Edit----
On a simple small example multifile project's forward and reverse search work fine. On my larger main project, it does not work. So, there is something in my config that is incorrect. VimTeX seems fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants