Based on #338 I installed version 0.3.3 and forward and backward searching is working fine. I'm running 14.04.3 LTS, Trusty Tahr and as soon as I switched to version 0.3.6 zathura will not open when I press \ll. I don't
Does anybody know what I have to do to get it running?
I'm using Zathura version 0.3.6, and it works mostly as expected. Both backward and forward search works.
Could you please follow the guidelines and add a complete description of how to reproduce your problem?
My minimal vimrc:
set nocompatible " Be iMproved
let g:neosnippet#expand_word_boundary = 1
let g:plug_threads = 40
call plug#begin('~/.vim/plugged/')
Plug 'Shougo/vimproc.vim'
Plug 'lervag/vimtex'
call plug#end()
let g:latex_view_general_viewer = 'zathura'
let g:vimtex_view_method = 'zathura'
Tex-File test.tex:
\documentclass{article}
\title{Cartesian closed categories and the price of eggs}
\author{Jane Doe}
\date{September 1994}
\begin{document}
\maketitle
Hello world!
\pagebreak
b
\pagebreak
c
\end{document}
My ~/.latexmkrc:
# always create a pdf
$pdf_mode = 1;
# how pdflatex will be executed
$pdflatex = 'pdflatex --shell-escape -synctex=1 %O %S';
And the version:
wm@wm禄 latexmk --version
Latexmk, John Collins, 22 April 2016. Version 4.45
Running the tex-file with: vim --servername vim test.tex. Pressing \lo gives me vimtex: No output exists. Pressing \li give me:
b:vimtex : test
pid : 0
root : '/home/wm/bla'
aux : '/home/wm/bla/test.aux'
log : '/home/wm/bla/test.log'
out : '/home/wm/bla/test.pdf'
tex : '/home/wm/bla/test.tex'
base : 'test.tex'
viewer
xwin_id : 'defaults are: --name --classname --class'
class : 'Zathura'
init : function('181')
view : function('182')
start : function('183')
forward_search : function('184')
latexmk_callback : function('185')
latexmk_append_argument : function('186')
xwin_exists : function('<SNR>172_xwin_exists')
xwin_get_id : function('<SNR>172_xwin_get_id')
Going back to my normal vim I've detected that I've used git checkout 1aedd5a7464c93af5af86fec2f4cfce97d5f2947 of your plugin. Here pressing \li gives me:
b:vimtex : test
pid : 2371
root : '/home/wm/bla'
aux : '/home/wm/bla/test.aux'
log : '/home/wm/bla/test.log'
out : '/home/wm/bla/test.pdf'
tex : '/home/wm/bla/test.tex'
tmp : '/tmp/wm/vmMKn6v/5'
cmd_latexmk_compile : 'cd ''/home/wm/bla'' && max_print_line=2000 latexmk -verbose -pdf -e ''$pdflatex =~ s/ / -file-line-error /'' -pvc -e ''$success_cmd = "\"vim\" --servername VIM --re
mote-expr \"vimtex\#latexmk\#callback(1)\""'' -e ''$failure_cmd = "\"vim\" --servername VIM --remote-expr \"vimtex\#latexmk\#callback(0)\""'' -e ''$new_viewer_always = "0"'' -e ''$pdf_previe
wer = "zathura -x \"vim --servername VIM --remote +\%{line} \%{input}\" \%S"'' ''test.tex'' >/tmp/wm/vmMKn6v/5 2>&1'
base : 'test.tex'
viewer
xwin_id : 0
cmd_start : 'zathura -x "vim --servername VIM --remote +\%{line} \%{input}" ''/home/wm/bla/test.pdf'''
cmd_forward_search : 'zathura --synctex-forward 10:1:''/home/wm/bla/test.tex'' ''/home/wm/bla/test.pdf'''
class : 'Zathura'
init : function('178')
view : function('179')
start : function('180')
forward_search : function('181')
latexmk_callback : function('182')
latexmk_append_argument : function('183')
xwin_exists : function('<SNR>167_xwin_exists')
xwin_get_id : function('<SNR>167_xwin_get_id')
Pressing \lo gives me:
1 Latexmk: This is Latexmk, John Collins, 22 April 2016, version: 4.45.
2 Viewing pdf
3 Latexmk: I have not found a previewer that is already running.
4 So I will start it for 'test.pdf'
5 ------------
6 ------------
7 Running 'start zathura -x "vim --servername VIM --remote +%{line} %{input}" "test.pdf"'
8 ------------
9 Latexmk: All targets (test.pdf) are up-to-date
10 For rule 'view', running '&if_source( )' ...
11 ------------
12 Running '"vim" --servername VIM --remote-expr "vimtex#latexmk#callback(1)"'
13 ------------
14 error: Error parsing command line arguments: Unknown option -x
I think we have found something. At least, it's working fine for me but not with current version.
Thanks. I assume you first started compilation with \ll in both of your cases (necessary for the \lo command to provide any output, since this command shows the output of the latexmk process).
I've added test files corresponding to your provided minimal example (see the commit referenced above).
When I open with vim --servername vim -u minivimrc minimal.tex, then do \ll, the pdf file opens as expected. I close it, and again it opens with \lv. Backward search also works as expected.
I notice in the output from latexmk that it says -x is unknown. This makes me remember that Zathura recently "decoupled" from synctex. This is discussed in an earlier issue, see #384. It is also commented in the docs under the Zathura viewer description.
Btw, let g:latex_view_general_viewer = 'zathura' is not necessary and can be removed from your vimrc.
Hi, thanks for taking care of my issue and thanks for pointing to that issue. I tried the minimal example again and modified your code and replaced the -x from your zathura wrapper and still got the same error-message.
I think you are using Arch for compiling zathura and it works on your machine.
I even tried mupdf but there I couldn't get backward-searching enabled (even when pressing '<localleader>lr' or VimtexRSearch.
At first, I'm very happy with my solution (even if I cannot update). Maybe a system upgrade in the future will change this.
Yes, I'm on Arch Linux. But it should be pretty easy to compile Zathura from scratch, which should solve your problem.
By the way, you have to remove both -x and the following string enclosed in the "s. That is, you should remove all of these lines:
let exe.cmd .= ' -x "' . g:vimtex_latexmk_progname
\ . ' --servername ' . v:servername
\ . ' --remote +\%{line} \%{input}"'
from the zathura.start function.
MuPDF should also work. I suspect you might not have xdotool installed, or something similar. The backward search works for me.
I'm installing zathura and girara with:
#!/bin/bash
GIRARA_VERSION=0.2.6
# need this old version form vim backward/forward search
ZATHURA_VERSION=0.3.6
rm -rf /tmp/girara /tmp/zathura
cd /tmp && git clone https://git.pwmt.org/pwmt/girara.git && cd girara && git checkout $GIRARA_VERSION && make && sudo make install
cd /tmp && git clone https://git.pwmt.org/pwmt/zathura.git && cd zathura && git checkout $ZATHURA_VERSION && make && sudo make install
I have the following settings in my zathurarc:
set synctex true
set synctex-editor-command "vim --remote-silent +%{line} %{input}"
And the optimized the zathura.start function:
function! s:zathura.start(outfile) dict " {{{2
let exe = {}
let exe.cmd = 'zathura ' . g:vimtex_view_zathura_options
let exe.cmd .= ' ' . vimtex#util#shellescape(a:outfile)
call vimtex#util#execute(exe)
let self.cmd_start = exe.cmd
sleep 300m
call self.xwin_get_id()
call self.forward_search(a:outfile)
endfunction
Removing the zathurarc settings didn't change anything.
\lo still gives me:
Latexmk: This is Latexmk, John Collins, 22 April 2016, version: 4.45.
Viewing pdf
Latexmk: I have not found a previewer that is already running.
So I will start it for 'scrum.pdf'
------------
------------
Running 'start zathura -x "vim --servername VIM --remote +%{line} %{input}" "scrum.pdf"'
------------
Latexmk: All targets (scrum.pdf) are up-to-date
For rule 'view', running '&if_source( )' ...
------------
Running '"vim" --servername VIM --remote-expr "vimtex#latexmk#callback(1)"'
------------
error: Error parsing command line arguments: Unknown option -x
First, The error message means/implies that Zathura is compiled without synctex. You need to have libsynctex installed in order for synctex to be enabled during compilation.
Also, the workaround that we've discussed is only relevant for the view command, \lv. When you enter \lo, you see the output from latexmk. latexmk will also start the pdf viewer, and it will use the command defined in zathura.latexmk_append_argument. If you want to remove the -x option for the latexmk process, then you should modify this function.
The change is _not_ an optimalization. Instead, it is a simplification that removes the automatic setting of the backward search command. It should not be necessary to remove this if Zathura is compiled with synctex support.
If you have zathura available in your system repositories, and if the version of zathura is no longer shipped with synctex support, then I would contact the package maintainers of your system and ask them to ensure they have libsynctex when they compile the zathura package.
Hi again, synctex is installed, how can I check if zathura is compiled with synctex support? Must simply the -x option work? I cannot install the libsynctex package on my system.
When you compile Zathura, you get some output, e.g.:
> make
zathura build options:
CFLAGS = -std=c11 -pedantic -Wall -Wno-format-zero-length -Wextra -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/synctex
LIBS = -lgirara-gtk3 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lgthread-2.0 -pthread -lglib-2.0 -lgmodule-2.0 -pthread -lglib-2.0 -lglib-2.0 -lpthread -lm -lsqlite3 -lmagic -lsynctex
...
Here -lsynctex implies that libsynctex is included. This is trivial to check. You simply clone the zathura repo, enter with cd and run make &> make.log.
I think you can also check this more simply with pkg-config synctex && echo 1 || echo 0.
What is your system? Ubuntu? OpenSUSE? ...
You can also inspect the output of zathura -h. If it includes the synctex options, then synctex support is compiled in. For me, I get the following output:
> zathura --help
Usage:
zathura [OPTION...] [file1] [file2] [...]
Help Options:
-h, --help Show help options
Application Options:
-e, --reparent=xid Reparents to window specified by xid (X11)
-c, --config-dir=path Path to the config directory
-d, --data-dir=path Path to the data directory
--cache-dir=path Path to the cache directory
-p, --plugins-dir=path Path to the directories containing plugins
--fork Fork into the background
-w, --password=password Document password
-P, --page=number Page number to go to
-l, --debug=level Log level (debug, info, warning, error)
-v, --version Print version information
-x, --synctex-editor-command=cmd Synctex editor (forwarded to the synctex command)
--synctex-forward=position Move to given synctex position
--synctex-pid=pid Highlight given position in the given process
--mode=mode Start in a non-default mode
Hi,
zathura --help gives me:
Usage:
zathura [OPTION...] [file1] [file2] [...]
Help Options:
-h, --help Show help options
Application Options:
-e, --reparent=xid Reparents to window specified by xid
-c, --config-dir=path Path to the config directory
-d, --data-dir=path Path to the data directory
--cache-dir=path Path to the cache directory
-p, --plugins-dir=path Path to the directories containing plugins
--fork Fork into the background
-w, --password=password Document password
-P, --page=number Page number to go to
-l, --debug=level Log level (debug, info, warning, error)
-v, --version Print version information
-x, --synctex-editor-command=cmd Synctex editor (forwarded to the synctex command)
--synctex-forward=position Move to given synctex position
--synctex-pid=pid Highlight given position in the given process
--mode=mode Start in a non-default mode
And pkg-config synctex && echo 1 || echo 0 print 0, so it's not there.
And the build options:
zathura build options:
44 CFLAGS = -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/ 鈫猧nclude/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/ 鈫猣reetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/ 鈫猧nclude/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/ 鈫猣reetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/ 鈫猧386-linux-gnu/glib-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include
45 LIBS = -lgirara-gtk3 -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -pthread -lgthread-2.0 - 鈫猯glib-2.0 -pthread -lgmodule-2.0 -lglib-2.0 -lglib-2.0 -lpthread -lm -lsqlite3 -lmagic -lz
Opening a pdf with zathura -x test.pdf gives me a black screen.
I'm using Xubuntu. The official Ubuntu package is. Installing it with the latest package https://www.howtoinstall.co/en/ubuntu/utopic/zathura gives me only version 0.2.9-2.
The -x argument will eat the next argument, so you should instead try zathura -x dummy test.pdf. This should output the same as what you see in the latexmk output that you've posted earlier.
However, as you see, the issue here is that you don't have libsynctex compiled in. I would suspect that it should be available from the main repositories. A simple search gave me this:
https://www.howtoinstall.co/en/ubuntu/wily/main/libsynctex-dev/
Ok, Package not found :(. I think closing this issue is fine.
Too bad. I'm pretty sure this should be solvable. You could/should also send a message to the ubuntu package maintainer about the updates to Zathura. He/She might ensure that an update in the future will include synctex support.
I will (thanks for motivating me).
No problem. Let me know if you have further questions or other issues with vimtex!
I will (and love your plugin so much and your help that I'll prepare a talk about it).
Wow, thanks! I'll be very happy to see the presentation! I'd be happy to give some comments, if applicable or desired. My email should be readily available from the git repo/source files, feel free to contact me.
Cool, to have the creator of the plugin as a reviewer. Wait a little bit until it's ready for reading it.
Contacted the package maintainer under https://answers.launchpad.net/ubuntu/+source/zathura/+question/293917.
I finally got it working with the latest zathura. I had to use make WITH_SYNCTEX=1 for building zathura. But going from vimtex SHA 1aedd5a to a35bcaf (Don't overwrite user mappings) it stopped working with \ll and \lv. It still works if I go to version 0212c94 (Added test files for #332)!
Could you check if :VimtexView and :VimtexCompile works? I suspect the problem might be related to mapping conflicts. Do you have any other mappings at \lv and \ll? You can check with :map \l to see all defined mappings that start with \l.
Does it work with the latest version? If you use a git bisect from the latest version, is a35bcaf the first bad commit?
Yeah, https://github.com/lervag/vimtex/commit/a35bcaf5c1e6729d0eea8c3520e46ff797867069 is the first bad commit. I don't have any other mappings to \ll or \lv - it worked before with the mapping.
I'll try when I'm at home.
Ok. I think you really do have other mappings, perhaps from some plugin or whatnot. The only thing changing in the commit that breaks things is that a mapping is not defined if it is already defined...
I'll check and let you know (but is sounds like the problem, I could run the commands without the mappings and they should work).
:VimtexCompile and :VimtexView works. :map \l gives me:
\lj *@:LatexLabels<CR>
\lL *@:Latexmk!<CR>
n \lm @<Plug>(vimtex-imaps-list)
\lv *@:LatexView<CR>
n \lY @<Plug>(vimtex-labels-toggle)
n \ly @<Plug>(vimtex-labels-open)
n \lT @<Plug>(vimtex-toc-toggle)
\lt *@:LatexTOC<CR>
\lG *@:LatexmkStatus!<CR>
\lg *@:LatexmkStatus<CR>
\lC *@:LatexmkClean!<CR>
\lc *@:LatexmkClean<CR>
\le *@:LatexErrors<CR>
n \lK @<Plug>(vimtex-stop-all)
\lk *@:LatexmkStop<CR>
n \lo @<Plug>(vimtex-compile-output)
\ll *@:Latexmk<CR>
n \ls @<Plug>(vimtex-toggle-main)
n \lx @<Plug>(vimtex-reload)
n \lI @<Plug>(vimtex-info-full)
n \li @<Plug>(vimtex-info)
Going back to https://github.com/lervag/vimtex/commit/0212c94e31f953378092249bc791eaaa4c5ccb1a I get for :map \l the following output:
n \lv @<Plug>(vimtex-view)
n \lt @<Plug>(vimtex-toc-open)
n \lG @<Plug>(vimtex-status-all)
n \lg @<Plug>(vimtex-status)
n \lC @<Plug>(vimtex-clean-full)
n \lc @<Plug>(vimtex-clean)
n \le @<Plug>(vimtex-errors)
n \lk @<Plug>(vimtex-stop)
n \ll @<Plug>(vimtex-compile-toggle)
\lj *@:LatexLabels<CR>
\lL *@:Latexmk!<CR>
n \lm @<Plug>(vimtex-imaps-list)
ov \lv *@:LatexView<CR>
n \lY @<Plug>(vimtex-labels-toggle)
n \ly @<Plug>(vimtex-labels-open)
n \lT @<Plug>(vimtex-toc-toggle)
ov \lt *@:LatexTOC<CR>
ov \lG *@:LatexmkStatus!<CR>
ov \lg *@:LatexmkStatus<CR>
ov \lC *@:LatexmkClean!<CR>
ov \lc *@:LatexmkClean<CR>
ov \le *@:LatexErrors<CR>
n \lK @<Plug>(vimtex-stop-all)
ov \lk *@:LatexmkStop<CR>
n \lo @<Plug>(vimtex-compile-output)
ov \ll *@:Latexmk<CR>
n \ls @<Plug>(vimtex-toggle-main)
n \lx @<Plug>(vimtex-reload)
n \lI @<Plug>(vimtex-info-full)
n \li @<Plug>(vimtex-info)
Should I simply change mappings to use the commands you suggested or should your plugin handle this?
I suspect you have either LaTeX-Box or vim-polyglot installed. LaTeX-Box should _not_ be used together with vimtex (unless you know exactly what you are doing). vim-polyglot bundles LaTeX-Box for LaTeX. You can disable with:
let g:polyglot_disabled = ['latex']
See also here: #450.
Yes, I've polyglot installed. Never thought that it would cause so much trouble. I'll let you know if this fixes the issue.
Personally I don't like polyglot. It might be convenient for some, but I like to have fine grained control over my setup, and when you install ~100 different filetype plugins in one go, you loose a lot of control.
My guess is that you don't really work with more than ~10 different file types, and it should be pretty easy to manually install the desired plugins.
In any case, I'm pretty sure this is the problem and that my solution works.
Yeah, I was thinking that too ... but switched to polyglot so that I don't have to take care of all the different syntax detection. Think I'll switch back to normal "command-controll" mode.
This was the solution. Thank you very much. Now I can prepare the talk and write about my learning.
No problem, and good luck with the talk! :)
Disabling polyglot worked for me too! (and solved some other issues)
Maybe we should mention that polyglot loads LaTeXBox, somewhere in the README and/or help pages? Lots of people use polyglot, as it's a 'must have plugin', so I think it would be worthwhile to add this information.
I don't agree that polyglot is a "must have plugin". Quite the opposite, actually. I understand that this is a matter of taste, but IMHO, people should know what they are doing. When you use polyglot, it adds a huge amount of plugins, and it becomes very hard to debug if any of the plugins should interfer with another, or with other plugins you use. Instead, you should install specifically the plugins you actually use and need.
I do not want to add a comment about this to vimtex, because if you use polyglot, then you should know what you are doing. Whenever you add a new filetype plugin, you must check if this is already added through polyglot. If you are surprised, as people seem to be, then you should stop using polyglot at once!
I fully agree with you. Polygot is _not_ a must have plugin. (Hence the quotation marks) Unfortunately, it's a plugin that's recommended to beginners, and to most beginners it seems like a good idea to 'improve vim a lot using this one plugin'. It's also included in some of those big dotfiles repos (like YADR and the like).
When one uses polyglot, they should know what it's doing. The truth is many don't. 'Vimtex should not be used alongside LaTeXBox, which is included in polyglot' would help these people tremendously, as they'd get a better experience with vimtex, and they would probably stop using polyglot.
Anyway, I fully respect that you don't want to add this to the readme. Thanks for making vimtex, and solving my problem. Have a great day!
Ok. Let's say I add such a sentence. Where should I put it in order for people to actually see it before they open issues?
I'd add it to the issue template (as seen in the first picture of issue and pull request templates)
Mentioning polyglot under Alternatives > LaTeXBox would be helpful too.
Another option would be to make a section 'Common problems' in the readme, but that seems like stretching it.
Thanks. I've added to README and to troubleshoot-section of docs.
Most helpful comment
I suspect you have either LaTeX-Box or vim-polyglot installed. LaTeX-Box should _not_ be used together with vimtex (unless you know exactly what you are doing). vim-polyglot bundles LaTeX-Box for LaTeX. You can disable with:
See also here: #450.