[Tex/LaTex] Use arara with continuous compilation (with vimtex)

araracompilingvim

I've been using vimtex with latexmk to typeset my LaTeX documents for a while now.
But I'm trying to use arara for a new project, as one of the team members suggested to use it.

Since I always use (Neo)vim with vimtex to typeset documents, I looked up on a documentation and voila!
vimtex does support arara.
I added

let g:vimtex_compiler_method = 'arara'

and saw that \ll works to compile the document.
However I noticed it won't automatically compile the documents when I save the file using :w, and won't even clean the project files with \lc.

I then found this issue on GitHub and found out the fact that I need to manually add something like:

% arara: clean: { files: [ mypaper.log ] }

to my tex file.
I'm fine with that–but I found it cumbersome to hit \ll everytime I :w to save the file to recompile.
I skimmed the vimtex manual to find out:

arara does not do continuous compilation, and so the only relevant commands
are VimtexCompile to start (single shot) compilation, and
VimtexCompileOutput to see the compilation output.

So the question is, is there a work around using (Neo)vim or vimtex or arara perhaps borrow the help of latexmk to automatically compile my documents when they get saved?
One of the reasons I sticked with my setup (vim + vimtex + skim) was the automatic compilation, and it would be awesome if I can achieve something similar when using arara as well.

Any help would be greatly appreciated!

Best Answer

Vim provides events for which you can define autocmds to execute whatever you want when an event occurs. :h autocmd-events

I would thus suggest you put the following in ftplugin/tex.vim

autocmd! BufWritePost *.tex normal ,ll

After this line is evaluated, everytime you write with :w on a file which ends with .tex, vim will execute ,ll as if you were in normal mode

Note that this is only a vim feature and has nothing to do with arara.

Related Question