peterbjorgensen / sved

Synctex support for Vim and Evince through DBus
37 stars 10 forks source link

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

Open Mr5quid opened 1 year ago

Mr5quid commented 1 year ago

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 !

peterbjorgensen commented 6 months ago

Sorry for the late reply. Currently the search for pdf file starts from the current directory and loops upwards in directories until it finds a .latexmain or a .synctex.gz file and a pdf file with the same basename.

Would it be most useful if the is an out_dir setting in the plugin or if it's possible to call the SVED_Sync() function with an argument?

peterbjorgensen commented 6 months ago

If you want a quick and dirty hack you can take inspiration from this pull request https://github.com/peterbjorgensen/sved/pull/14