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

Inverse synctex doesn't work with Sioyek #15

Open
FahimAnayet opened this issue Dec 18, 2022 · 13 comments · May be fixed by #23
Open

Inverse synctex doesn't work with Sioyek #15

FahimAnayet opened this issue Dec 18, 2022 · 13 comments · May be fixed by #23

Comments

@FahimAnayet
Copy link

This is what my configuration is. Only --reuse-instance removed (Sioyek v2.0.0 doesn't open if --reuse-instance used), everything else is default. Forward search is fine but when I enable synctex F4 then right click it doesn't do anything.

OS: macOS 12.6.1
iTerm2, nvim v0.9.0-dev-76-g45cc5fd76-dirty

 texoutputext = "pdf",
  textopdfviewerlaunch = "sioyek --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' %outputfile%",
  textopdfviewerrefresh = "none",
  textopdfforwardjump = "sioyek --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",
  textopdfshorterror = "A=%outputfile% ; LOGFILE=\"${A%.pdf}.log\" ; rubber-info \"$LOGFILE\" 2>&1 | head -n 1",
  delay = 10
@frabjous
Copy link
Owner

It does seem that v2.0 of Sioyek has made some changes that will require removing --reuse-instance (or maybe changing to --reuse-window, which seems to be new flag, at least in the forward jump part, --new-window should be OK for the launch command), so thanks for mentioning that. I'll put out a new version fixing that right away.

However, inverse search works for me on linux with your settings. If the problem is mac-specific, I have no way of troubleshooting it, as I don't have a mac (and never will, cross my fingers). I'm kinda surprised you got it working on mac at all; I've certainly never tested it there.

Maybe some other mac user will come along and have an idea.

@FahimAnayet
Copy link
Author

Alright, so I think it's a mac-specific problem. I believe the solution lies in knaphelper.lua this file. If anyone can find the soln. please open the thread. For now I am closing this.

@frabjous
Copy link
Owner

Thanks, but we might as well leave this open, so others who might be having the same trouble can find it. Out of curiosity, what does :echo v:servername show in Neovim?

@frabjous frabjous reopened this Dec 18, 2022
@FahimAnayet
Copy link
Author

/var/folders/f5/_l39kqr51s7b5zpzrtmhbwsc0000gn/T/nvim.MY_USER_NAME/LqNEwH/nvim.24523.0 this is what it spills out.

@frabjous
Copy link
Owner

Hmm, that's really complicated. I get something simpler like /run/user/1000/nvim.8183.0; still, it isn't clear why it wouldn’t work. Is nvim in your path? What does type -a nvim say in a terminal?

@FahimAnayet
Copy link
Author

Definitely nvim is on my path. type -a nvim = nvim is /usr/local/bin/nvim in my terminal.

@joelsleeba
Copy link

joelsleeba commented Feb 13, 2023

I also have encountered the same problem where the forward synctex works but not the inverse synctex. the <F4> key in sioyek doesn't make any change in the nvim buffer.

NVIM v0.8.2
kernel 6.1.9-1-MANJARO
echo v:servername return /run/user/1000/nvim.43428.0

knap config contains

    texoutputext = "pdf",
    textopdf = "pdflatex -interaction=batchmode -halt-on-error -synctex=1 %docroot%",
    textopdfviewerlaunch = "sioyek --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --new-window %outputfile%",
    textopdfviewerrefresh = "none",
    textopdfforwardjump = "sioyek --inverse-search 'nvim --headless -es --cmd \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --reuse-window --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",
    textopdfshorterror = "A=%outputfile% ; LOGFILE=\"${A%.pdf}.log\" ; rubber-info \"$LOGFILE\" 2>&1 | head -n 1",
    delay = 250

@frabjous
Copy link
Owner

frabjous commented Feb 13, 2023

The F4 key by itself isn't supposed to make any change to the nvim buffer. All the F4 key does is put you in "synctex mode" in Sioyek. (This should be indicated on the status bar in sioyek.) You then need to right click somewhere in the document to jump to the corresponding place in the buffer.

@joelsleeba
Copy link

Yes. Pressing the F4 key indicates in the status bar of the sioyek that I'm in "synctex mode". But then right clicking on the text or equation on the pdf doesn't make any changes in the buffer

@frabjous
Copy link
Owner

Works fine for me with your settings. What version of Sioyek are you using?

@FahimAnayet
Copy link
Author

It still doesn't work for me too. I remember it works if I open sioyek separately from terminal and not from knap, which is a junky soln tbh. I don't recall the command though. If I could recall, I'll comment here.

@joelsleeba
Copy link

Sioyek is version 2.0.0
Also I forgot to mention I'm using LunarVim, which gets executed by lvim
I've also checked

ps aux|grep nvim returns

joel        1744  1.2  6.0 649920 364168 ?       Ssl  01:17   0:13 /home/joel/.local/share/nvim/mason/packages/lua-language-server/bin/lua-language-server
joel        3335  0.5  0.4 107436 28640 pts/4    Sl+  01:33   0:00 nvim main.tex
joel        3576  0.0  0.0  10420  1892 pts/2    S+   01:35   0:00 sh -c cd "/home/joel/workspace/NotesHome/Master's Project" && sioyek --inverse-search 'nvim --headless -es --cmd "lua require('"'"'knaphelper'"'"').relayjump('"'"'/run/user/1000/nvim.3497.0'"'"','"'"'%1'"'"',%2,%3)"' --new-window "main.pdf" > /dev/null 2>&1 & echo $!
joel        3577  2.0  3.1 1552736 186700 pts/2  Sl+  01:35   0:00 sioyek --inverse-search nvim --headless -es --cmd "lua require('knaphelper').relayjump('/run/user/1000/nvim.3497.0','%1',%2,%3)" --new-window main.pdf
joel        3642  0.0  0.0   9492  2572 pts/3    S+   01:35   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox nvim

ps aux|grep lvim returns

joel        1736  0.7  0.8 162428 51976 pts/0    Sl+  01:17   0:08 lvim -u /home/joel/.local/share/lunarvim/lvim/init.lua .config/lvim/lua/plugins/knap.lua
joel        3497  2.4  0.8 160312 48992 pts/2    Sl+  01:34   0:02 lvim -u /home/joel/.local/share/lunarvim/lvim/init.lua main.tex
joel        3666  0.0  0.0   9492  2368 pts/3    S+   01:36   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox lvim

and ps aux|grep sioyek returns

joel        3576  0.0  0.0  10420  1892 pts/2    S+   01:35   0:00 sh -c cd "/home/joel/workspace/NotesHome/Master's Project" && sioyek --inverse-search 'nvim --headless -es --cmd "lua require('"'"'knaphelper'"'"').relayjump('"'"'/run/user/1000/nvim.3497.0'"'"','"'"'%1'"'"',%2,%3)"' --new-window "main.pdf" > /dev/null 2>&1 & echo $!
joel        3577  0.5  3.1 1552736 186700 pts/2  Sl+  01:35   0:01 sioyek --inverse-search nvim --headless -es --cmd "lua require('knaphelper').relayjump('/run/user/1000/nvim.3497.0','%1',%2,%3)" --new-window main.pdf
joel        3706  0.0  0.0   9492  2492 pts/3    S+   01:38   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox sioyek

The above config was when I was running nvim which had NvChad config and lvim which is LunarVim parallelly to see if it would give the inverse search result in either of them. It didn't work on nvim. Will the error be because the lvim command executes nvim with a custom init.lua file using the -u option?

@ChasingZenith
Copy link

Don't know why but change the code to the following solve the problem

        textopdfviewerlaunch = "sioyek --inverse-search 'nvim --headless -c \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --new-window %outputfile%",
        textopdfviewerrefresh = "none",
        textopdfforwardjump = "sioyek --inverse-search 'nvim --headless -c \"lua require('\"'\"'knaphelper'\"'\"').relayjump('\"'\"'%servername%'\"'\"','\"'\"'%1'\"'\"',%2,%3)\"' --reuse-window --forward-search-file %srcfile% --forward-search-line %line% %outputfile%",

Here, -es is drop and --cmd is changed to -c. Both changes are necessary.

ChasingZenith added a commit to ChasingZenith/knap that referenced this issue Apr 24, 2023
@ChasingZenith ChasingZenith linked a pull request Apr 24, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants