Git Product home page Git Product logo

sved's Introduction

Description

SVED is a Vim plugin enabling synctex synchronization support for Vim and Evince through DBus. Vim/gVim and Neovim are supported

Requirements

SVED requires Neovim or Vim 8 (for asynchronous job support) or later, Evince version 3.0 or later and the python3 command available in your PATH. You need the Python pygobject package as well as dbus-python, which are most likely already installed in your system. For Neovim you also need the pynvim Python package. Install with pip install pynvim or through your package manager. Vim does not need to be compiled with python support.

Installation

Pathogen Install

Do: git clone https://github.com/peder2tm/sved.git ~/.vim/bundle/ and create a binding to do forward synchronization: nmap <F4> :call SVED_Sync()<CR>

vim-plug Install

Add Plug 'peterbjorgensen/sved' to your list of plugins and tell vim-plug to install it with :PlugInstall. Then create a binding to do forward synchronization: nmap <F4> :call SVED_Sync()<CR>

Manual Install

Place both files of the plugin in ~/.vim/ftplugin/ and create a binding to do forward synchronization: nmap <F4> :call SVED_Sync()<CR>

Forward Synchronization

The plugin searches for a file called *.latexmain (like vim-latex-suite) or *.synctex.gz in order to do forward synchronization. If your main file of the latex project is called main.tex, you can create an empty file called main.tex.latexmain and the script will use this to find the main pdf. Compile the project with: pdflatex --synctex=1 main.tex Then forward synchronization should work.

Backward Synchronization

When you have a tex file open in Vim, ctrl-click in the Evince pdf and Vim will jump to the corresponding point. Vim will also jump to files you do not currently have open.

Older Vim installations

The plugin requires Vim 8 or later because it makes use of the asynchronous job feature introduced in Vim 8 to do backward synchronization. If you are using an older version of Vim, check out the version 1.0 release here on Github, which supports older versions of Vim, but does only work with gVim (not console Vim), because it needs the GTK loop of gVim to catch the bacward sunchronization signal from DBus.

sved's People

Contributors

doronbehar avatar peterbjorgensen avatar schneiderfelipe avatar symphorien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sved's Issues

Feature request: Support for Neovim

Neovim support would be a nice feature. It should be feasible with minor edits of the Python script and a wrapper plugin in rplugin/python3/

Feature request: (optionally) associate different vim instances with different pdfs when doing backward sync

Currently all vim instances that have opened a tex file will sync when a sync-source signal is emitted by Evince, even though they might be working in different latex projects.
This feature would add an option such that the sync source signals will be filtered. Each vim instance would have to maintain a list of pdf-files it is watching and ignore the events if the URI of the source file is not below the pdf file in the file hierarchy.

freeze in neovim on `:call SVED_Sync()`

I have upgraded my OS recently to Linux Mint 20.3 but I had this issue before.

When I call SVED_Sync() in neovim nothing happens (until I press cntrl-c to terminate the command).

Here is my setup

nvim = 0.4.3 (installed from the debian package with python support)
dbus-python = 1.2.16
vimtex, sved ... installed via `plug`

I have tweaked the evinceSync.py to always do the logging and I get the following to log files

2022-11-08 12:38:14,488 DEBUG:stdout encoding is utf-8
2022-11-08 12:38:14,488 DEBUG:got following arguments /home/heiland/.vim/plugged/sved/ftplugin/evinceSync.py 1
2022-11-08 12:38:14,488 DEBUG:connect_bus: connecting to dbus
2022-11-08 12:38:14,489 DEBUG:importing pynvim module
2022-11-08 12:38:14,513 DEBUG:attaching to neovim through socket /tmp/nvimsocket
2022-11-08 12:38:14,513 DEBUG:Using selector: EpollSelector
2022-11-08 12:38:26,011 DEBUG:stdout encoding is utf-8
2022-11-08 12:38:26,011 DEBUG:got following arguments /home/heiland/.vim/plugged/sved/ftplugin/evinceSync.py /home/heiland/work/latex/22-yk-lpv-pod-cae/paper.pdf 82 1 /home/heiland/work/latex/22-yk-lpv-pod-cae/paper.tex
2022-11-08 12:38:26,021 DEBUG:connect_bus: connecting to dbus
2022-11-08 12:38:26,023 DEBUG:sync_view: Forward syncing
2022-11-08 12:38:26,023 DEBUG:connect_daemon: connecting to Evince daemon

Any idea how to debug this?

Forward synchronisation when pdf and synctex.gz are not in main directory

Hi,

I'm trying to use SVED to enable forward/backward search between NeoVim running VimTex on one hand and Evince on the other hand. I'm working on a big LaTeX project compiled through latexmk with multiple source files that I can compile independently with the subfiles package. For the record, I'm using lualatex, not pdflatex. My directory is set up as follows :

.
├── Chapitres
│   ├── chapitre1.tex
│   ├── chapitre2.tex
│   ├── chapitre3.tex
│   ├── chapitre4.tex
│   ├── conclusion.tex
│   ├── introduction.tex
│   └── latexmkrc
├── dist
│   ├── chapitre2.aux
│   ├── chapitre2.bbl
│   ├── chapitre2.bcf
│   ├── chapitre2.blg
│   ├── chapitre2.fdb_latexmk
│   ├── chapitre2.fls
│   ├── chapitre2.log
│   ├── chapitre2.maf
│   ├── chapitre2.mtc
│   ├── chapitre2.mtc0
│   ├── chapitre2.out
│   ├── chapitre2.pdf
│   ├── chapitre2.run.xml
│   ├── chapitre2.synctex.gz
│   └── Chapitres
├── Figures
│   ├── Chap1/
│   └── Chap2/
├── include
│   ├── file1.pdf
│   └── file2.pdf
├── latexmkrc
├── main.tex
└── references.bib

All build files, including *synctex.gz and output pdf get made in the dist folder in the root directory. The reason why I have two latexmkrc files (one in root and one in my Chapters folder) is just because it's a dirty trick I found so that everything always goes into the top level dist/ folder, whether I'm compiling main.tex or an individual chapter (they only differ by their $out_dir statement, which is a relative path, so one is just 'dist' while the other is '../dist').

Anyway, backward search works just fine, which is absolutely fantastic (I wish I had found this project sooner). However calling SVED_Sync() for forward synchronization returns "Did not find main pdf file". I noticed that if I moved the relevant synctex.gz and pdf file in the same folder as the current .tex file I'm compiling, it then works.

So my question is : is there a way to make SVED take into account my out_dir instructions ? I use either the out_dir key for the vimtex_compiler_latexmk dictionary in my init.vim or a latexmkrc instruction (in this case they come from the latexmkrc files, but I mean that my vimtex is set up to write everything in ./dist anyway).

Thank you !

Warnings on forward sync

Each time I call SVED_sync() I get this displayed at the bottom of my vim:

/home/<user>/.vim/ftplugin/evinceSync.py:197: PyGIDeprecationWarning: GObject.MainLoop is deprecated; use GLib.MainLoop instead
  gobj_main_loop = GObject.MainLoop()
/home/<user>/.vim/ftplugin/evinceSync.py:212: PyGIDeprecationWarning: GObject.timeout_add is deprecated; use GLib.timeout_add instead
  GObject.timeout_add(10, sync_view, pdf, path_source, curpos)
/home/<user>/.vim/ftplugin/evinceSync.py:206: PyGIDeprecationWarning: GObject.timeout_add is deprecated; use GLib.timeout_add instead
  GObject.timeout_add(100, gobj_main_loop.quit)

Fixing seems pretty straight forward (I haven’t tried though).

Vim 8.1 --- Backward sync: no mouse cursor

I tried on GNOME terminal 3.32.2 and Xterm

The mouse cursor always disappears on backward sync. After a click or a movement, the mouse cursor is drawn (it seems that we might be missing some redraw somewhere).

It does not happen in GVim.

Thanks

I must say thanks to the author.

Recently I'm busy with configing my VimTex. I hope to combine VimTex and evince by SyncTex because I don't like zathura. And today I found this plugin which's I'm looking for.

It works well. Thanks to the author!

reverse search

I am enjoying your plugin with nvim, thank you for providing it.
Using backwards search (from evince to nvim), nvim prompts ‘press ENTER or type command to proceed’, if in normal mode; if in insert mode, no prompt is displayed.

Any idea how to avoid this annoying prompt?

Jumps to `main.vrb` instead of `main.tex` when targeting verbatim environments

Many thanks for this software :)
For quite some time, I've been finding this problem:
When writing in verbatim environment, sved jumps to the main.vrb file instead of the main.tex file. Unfortunately, this means one cannot edit the targeted places.
verbatim and other very useful variants from fancyvrb package (i.e. begin{Verbatim}) are very useful when writing beamer documents, for instance, for showing code snippets, which I use quite a lot.
Is there a way to fix this so that it jumps to the actual .tex file ?
I provide a minimal working example below.
Many thanks

Minimal working example:

main.tex:

\documentclass{beamer}

\usepackage{adjustbox}
\usepackage{comment}
\usepackage{fancyvrb}

\usepackage{spverbatim}

\begin{document}

\section{aa}

\begin{frame}[fragile]

% \begin{Verbatim}[fontsize=\tiny,commandchars=\\\{\}] 
\begin{verbatim}
Some text

\end{verbatim}
%\end{Verbatim}

\end{frame}

\end{document}

NeoVim Pynvim dependencie

Hi Peter!

Just letting you know that, in order to get backward sync in this plugin to work with NeoVim, I first needed to install the package Pynvim, which seems to be a dependencie for evinceSync.py. More specifically, line 89 of evinceSync.py

import neovim

fails to execute when not having Pynvim installed.

I could install app-editors/pynvim through my package manager and alike packages are probably available in most disto-repos. I'm sure some distros might even ship Pynvim with their NeoVim package. According to the Pynvim authors, it could also be installed through pip via:

pip install pynvim

Nevertheless, this might be worth mentioning in README.md to help future users get this great plugin going.

All love,
Mikael Henriksson

Filenames with some special characters results in a bug with forward synchronization

Characters like ( or , are not shell escaped which then creates a bug in the vim command : SVED_Sync() tries a first forward sync, but then we're stuck in Vim command in a special character loop/bug. Sorry, I can't explain properly, but I link some screenshots : https://imgur.com/a/4fVkjVU

  1. I call SVED_Sync() in my file containing a comma in its filename. Evince is launched (but no forward sync is done)
  2. I pressed F4 (my shortcut for SVED_Sync()) : result ends up in a special character being inserted in the shell
  3. And so on... (I tried F1 (compile) at some point).

To exit the loop I have to press CTRL+C twice.

Source of the problem : in tex_evinceSync.vim, line end-5 there is indeed a shellescape(l:pdffile) but shellescape() escapes only some characters, but not parenthesis () nor comma , .

What I tried : add some substitute() operations to l:pdffile but ended up in "evince cannot find file". I'm not good enough for that, but the solution should just be to add some other escapes somewhere...

Using SVED with SpaceVim

I'm completely new to vim and I've installed SpaceVim on top of nvim. I'm trying to have SVED working in this context. Inspired by what I found on SpaceVim doc, I've added

[[custom_plugins]]
  repo = "peterbjorgensen/sved"
  merged = false
  on_cmd = "vimtex-reverse-search"

to ~/.SpaceVim/init.toml, with or without the last line, but it does not work. Maybe you're not aware of how SpaceVim works, but in case you have any idea, I'd be happy to read it.

evinceSynctex job quit with status 143

Hi. I have a following configuration system for the LaTeX:

  • NVim 0.9
  • Vimtex
  • SVED (the current version)
  • Evince - PDF viewer
  • System: Linux 5.15.0-52-generic #58~20.04.1-Ubuntu x86_64 GNU/Linux

After editing any tex file, every time I exit nvim I get this status in terminal: evinceSynctex job quit with status 143, although the plugin works as expected. Any idea what may cause it?

Thanks

Backward sync doesn't work with NVIM

When i use your script with vim, forward and backward search work as expected. However, when I use it with nvim, only forward search works. Nothing happens when i ctrl+click in evince. Any ideas what can be going wrong?

btw: awesome script, thanks!

update: issue is fixed when i use vim-plug to install the plugin rather than manual installation.

Choosing the correct pyhon environment

Hi,

I have python3_host_prog set to a neovim enviroment with the required packages. All works if I don't have another virtual environment activated when starting neovim. However, if I do have another environment activated sved uses that python rather than the one I have configured in neovim. Any way to fix this? Or is this something that needs to be set in sved?

Thanks for this plugin, I have now archived my old one: https://github.com/gauteh/vim-evince-synctex

Regards, Gaute

undefined variable pycmd_list

Hi,
I am getting the error shown in the screenshot.
Screenshot from 2024-06-10 23-09-35

What should I do? I have installed it using vim-plug. I am also using vimtex.
My vim version is:

vim --version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled May 06 2024 00:00:00)
Included patches: 1-393
Modified by <[email protected]>
Compiled by <[email protected]>
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl/dyn          +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby/dyn          +wildignore
+cursorbind        +lua/dyn           +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             +xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        +mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -L/usr/local/lib -o vim -lm -lselinux -lncurses -lsodium -lacl -lattr -lgpm 

Backward sync does not open new vim file

Hello ! I've been away for a few months and something changed since that time. Before that, when I had an instance of vim opened, and when I ctrl+click on some pdf file properly compiled, vim would open the .tex file and put me on the correct line of code (what you mean by

Vim will also jump to files you do not currently have open.

Now, this does not work anymore and for backward sync to work I need to have the tex file already opened in vim.

I do not know what changed since I just updated everything after a few months without touching my system.

GNOME 3.32.2 --- backward sync does not focus Vim window

GNOME shell 3.32.2

Backward sync works, but the window where Vim/GVim is running is not focused or hinted as ready.
Forward search does this correctly. GNOME shell presents a message saying "X is ready" if X is not visible on screen.

About pygobject and dbus-python

Hi. My environment (anaconda3-5.3.1 installed by pyenv) did not have dbus and pygobject installed.
How about adding these installation instructions or links to them in the README?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.