-
Notifications
You must be signed in to change notification settings - Fork 395
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
Zathura backward search: bug with multi-file projects #2127
Comments
Yes.
I assume it would not fail if you use
Ok. But we need to consider how such configuration would look.
So, one possibility would be to allow to change between variants of " The default would be
let g:vimtex_view_zathura_remote = 'expr'
" Now you could easily change to this
let g:vimtex_view_zathura_remote = 'tab' Another option would be to allow customizing the entire reverse_goto option. E.g. " The default would be
let g:vimtex_view_zathura_reverse_goto =
\ '--remote-expr \"vimtex#view#reverse_goto(%{line}, ''%{input}'')\"'
" Now you could easily change to this
let g:vimtex_view_zathura_reverse_goto =
\ '--remote-tab \"vimtex#view#reverse_goto(%{line}, ''%{input}'')\"'
Yes - in this case, we are passing a command line to latexmk to start Zathura for us, and I was never able to figure out the proper escaping to make the more "advanced" version work. But the simpler
No, I think this is new - no need to apologize! |
Using
One way could be that the command " view.vim in VimTeX
execute g:vimtex_view_zathura_edit_command l:file
" The default would be
let g:vimtex_view_zathura_edit_command = 'edit'
" Now you could easily change to this
let g:vimtex_view_zathura_edit_command = 'tabedit' Setting this variable to Alternatively, the syntax of this variable could be changed to a full Vim command line with " view.vim in VimTeX
execute printf(g:vimtex_view_zathura_edit_command, l:file)
" The default would be
let g:vimtex_view_zathura_edit_command = 'edit %s'
" Now you could easily change to this
let g:vimtex_view_zathura_edit_command = 'call MyFunc(''%s'')'
Note that the syntax for |
I'll not argue preferences, of course, although I would expect your preference here to be quite uncommon. :)
Do you think this would resolve your entire request? If so, then I think it is a good idea. As this is actually not purely related to Zathura, I would propose the following configuration: let g:vimtex_view_reverse_search_edit_cmd = 'edit'
" Allowed values are any values that can be used in place of 'edit'
Yes, that's also a nice idea. The question is if the extra flexibility is really useful for anyone and worth the complexity cost. There's also the even |
Yes, this sounds like a good resolution. I can work on a fix and open a pull request. Thanks for all of your help! |
Fixes an issue raised in <lervag#2127 (comment)>. In the latexmk command line, make sure that --remote-expr is used instead of --remote for SyncTeX backwards search when opening Zathura. This ensures consistency between starting compilation via <LocalLeader>ll and opening the viewer separately via <LocalLeader>lv.
This option controls the command that is used to open new files from SyncTeX backward search in multi-file projects. Refer lervag#2127
In the latexmk command line, make sure that --remote-expr is used instead of --remote for SyncTeX backwards search when opening Zathura. This ensures consistency between starting compilation via <LocalLeader>ll and opening the viewer separately via <LocalLeader>lv. Refer lervag#2127 (comment)
This option controls the command that is used to open new files from SyncTeX backward search in multi-file projects. Refer lervag#2127
Great! Happy to help, and glad to receive PR contributions! I'll close this issue; let's continue the discussion in #2135. |
In the latexmk command line, make sure that --remote-expr is used instead of --remote for SyncTeX backwards search when opening Zathura. This ensures consistency between starting compilation via <LocalLeader>ll and opening the viewer separately via <LocalLeader>lv. Refer #2127 (comment)
This option controls the command that is used to open new files from SyncTeX backward search in multi-file projects. Refer #2127
Problem
The SyncTeX support for Zathura is excellent out of the box, but I noticed that the backward search command line is hard-coded to use
--remote-expr
to callvimtex#view#reverse_goto
:vimtex/autoload/vimtex/view/zathura.vim
Lines 38 to 41 in 078292e
This function works well in single-file projects, but I noticed a few problems when switching files in multi-file projects. Specifically, consider the case that a project has files
a.tex
andb.tex
, my Vim currently hasa.tex
open, and I perform a reverse search from a place in the PDF that corresponds tob.tex
line 50.a.tex
has unsaved changes, then VimTeX focusesa.tex
line 50. This seems to be because thesilent edit
fails here:vimtex/autoload/vimtex/view.vim
Lines 74 to 77 in 078292e
a.tex
does not have unsaved changes, thenb.tex
takes over the buffer where I was editinga.tex
. While this may be desirable behavior for other users, I would prefer thatb.tex
open in a new tab page.Suggested solutions/workarounds
I suppose that the first bullet point is a bug and should be fixed globally, but that the second bullet point hinges on subjective preferences. So, I propose that the first part be fixed e.g. by splitting the window, which is what Vim's
--remote
argument does. To address the tab page issue, I think it would be a good idea to make the behavior configurable.Alternatively, the use of
--remote-expr
(as opposed to--remote
or--remote-tab
) could be made configurable. The stopgap solution that I am using right now is changing the hard-coded--remote-expr
to use--remote-tab
, and this seems to work fine.My stopgap solution
I suppose that one could also work around this by using the
general
viewer and configuring everything manually, but this has obvious downsides.Miscellany
Additionally, I noticed that
--remote
and not--remote-expr
is used later in the same file, ins:zathura.latexmk_append_argument()
. Is there a reason for this? Apologies if this (or anything else in this issue) has already been addressed elsewhere.vimtex/autoload/vimtex/view/zathura.vim
Lines 79 to 84 in 078292e
The text was updated successfully, but these errors were encountered: