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

"Compile selected lines" works but cannot open a viewer when the build_dir of vimtex_compiler_latexmk is set #2522

Closed
krishnakumarg1984 opened this issue Oct 17, 2022 · 7 comments
Labels

Comments

@krishnakumarg1984
Copy link
Contributor

Description

With the following configuration,

  let g:vimtex_compiler_latexmk = {
  \ 'build_dir' : 'build',
  \ 'callback' : 1,
  \ 'continuous' : 1,
  \ 'executable' : 'latexmk',
  \ 'hooks': [function('Callback')],
  \ 'options' : [
  \   '-verbose',
  \   '-recorder',
  \   '-file-line-error',
  \   '-synctex=1',
  \   '-interaction=nonstopmode',
  \ ]
  \}

Visually selecting a few lines of latex source code, and performing a <leader>lL triggers a successful compilation of the selected lines. However, the view command fails with the error message:

VimTeX: viewer cannot read the PDF file.

This is with the default settings, wherein the viewer is supposed to automatically open and do a forward search.

Setting the 'build_dir' back to '' ensures a successful compilation of selected lines and immediately opens the PDF viewer

Steps to reproduce

Please see description above

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

N/A

VimtexInfo

N/A?
@lervag
Copy link
Owner

lervag commented Oct 18, 2022

Interesting. I'll look into this when I get the time!

@lervag
Copy link
Owner

lervag commented Oct 22, 2022

With the following configuration,

  let g:vimtex_compiler_latexmk = {
  \ 'build_dir' : 'build',
  \ 'callback' : 1,
  \ 'continuous' : 1,
  \ 'executable' : 'latexmk',
  \ 'hooks': [function('Callback')],
  \ 'options' : [
  \   '-verbose',
  \   '-recorder',
  \   '-file-line-error',
  \   '-synctex=1',
  \   '-interaction=nonstopmode',
  \ ]
  \}
  1. You don't need to set values to their defaults. Thus, you can simplify the above to this:

      let g:vimtex_compiler_latexmk = {
            \ 'build_dir' : 'build',
            \ 'hooks': [function('Callback')],
            \ 'options' : [
            \   '-verbose',
            \   '-recorder',
            \   '-file-line-error',
            \   '-synctex=1',
            \   '-interaction=nonstopmode',
            \ ]
            \}
  2. What is the 'Callback' function?

  3. I believe the callback function and -recorder option is not relevant to this issue anyway, which means you could probably simplify (for this issue) to

      let g:vimtex_compiler_latexmk = { 'build_dir' : 'build' }

lervag added a commit that referenced this issue Oct 22, 2022
@lervag
Copy link
Owner

lervag commented Oct 22, 2022

I believe this is fixed now, please test.

@lervag lervag closed this as completed Oct 22, 2022
@krishnakumarg1984
Copy link
Contributor Author

@lervag Tested, and while it compiles the selected lines, two PDF viewers are opened

@krishnakumarg1984
Copy link
Contributor Author

krishnakumarg1984 commented Oct 22, 2022

err.... It also creates a file main_vimtex_selected.tex in my project's root.

@lervag
Copy link
Owner

lervag commented Oct 22, 2022

@lervag Tested, and while it compiles the selected lines, two PDF viewers are opened

Not on my end. Can you make a minimal example for that?

@lervag
Copy link
Owner

lervag commented Oct 22, 2022

err.... It also creates a file main_vimtex_selected.tex in my project's root.

Ah, yes. I guess you'd expect the temporary file to be created inside the build_dir. Agreed, I'll update accordingly.

lervag added a commit that referenced this issue Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants