:w triggers compilation with wrong output dir unless .latexmkrc is used
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?
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_latexmkwithout_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
:VimtexCompileand\llworked correctly — all files landed inbuild_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:
- you open some tex file with
nvim myfile.tex - you start compilation with
\ll - it compiles as expected, files are placed in the build dir
- you make changes, then save with
:w - the compiler, which is still running in the background, will recompile and still put the files in the build dir
I had no
.latexmkrc, noBufWritePostautocommands, and no background job running. Once I moved theout_dirlogic into a.latexmkrcfile, 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_latexmkmight 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.