vimtex icon indicating copy to clipboard operation
vimtex copied to clipboard

:w triggers compilation with wrong output dir unless .latexmkrc is used

Open anamyk opened this issue 10 months ago • 1 comments

I was using vim.g.vimtex_compiler_latexmk with out_dir = 'build_tex'.

I also tried adding -outdir=build_tex in options, but saving the file with :w would still generate output files (PDF, AUX, etc.) in the root directory.

Running :VimtexCompile and \ll worked correctly — all files landed in build_tex/. But just saving (:w) always created new files in the root.

Also VimtexInfo showed out_dir: build_dir.

I had no .latexmkrc, no BufWritePost autocommands, and no background job running. Once I moved the out_dir logic into a .latexmkrc file, the problem disappeared completely.

Is this expected behavior? If so, maybe the docs could mention that vim.g.vimtex_compiler_latexmk might not be respected on :w?

anamyk avatar May 03 '25 13:05 anamyk

Sorry for the late reply!

First: You are completely disregarding the issue template, and your issue description lacks a lot of relevant context!

I'll try to help, but you will most likely need to provide more info here.

I was using vim.g.vimtex_compiler_latexmk with out_dir = 'build_tex'.

Can you share your full Neovim config, or at least your full VimTeX config (including how you install/load VimTeX)?

Also VimtexInfo showed out_dir: build_dir.

Which indicates that you have properly configured VimTeX. Still, I would be interested in seeing the config.

Running :VimtexCompile and \ll worked correctly — all files landed in build_tex/. But just saving (:w) always created new files in the root.

I believe you may not be understanding how things work here, properly. And I suspect you have a spurios latexmk process running somehow.

Lets assume that your neovim and VimTeX are properly configured, then something like this is expected:

  1. you open some tex file with nvim myfile.tex
  2. you start compilation with \ll
  3. it compiles as expected, files are placed in the build dir
  4. you make changes, then save with :w
  5. the compiler, which is still running in the background, will recompile and still put the files in the build dir

I had no .latexmkrc, no BufWritePost autocommands, and no background job running. Once I moved the out_dir logic into a .latexmkrc file, the problem disappeared completely.

VimTeX will read this setting from .latexmkrc files as well, see :help vimtex-compiler-latexmk where this is explained in some detail.

Is this expected behavior? If so, maybe the docs could mention that vim.g.vimtex_compiler_latexmk might not be respected on :w?

No, it is not the expected behaviour, but I'm more or less 100% sure you are just doing something weird.

Thus, to go forward, we really need a reproducible example. As is asked in the issue template.

lervag avatar May 07 '25 20:05 lervag