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

Support arara (feature request/ question) #907

Closed
petobens opened this issue Jul 18, 2017 · 16 comments
Closed

Support arara (feature request/ question) #907

petobens opened this issue Jul 18, 2017 · 16 comments

Comments

@petobens
Copy link

petobens commented Jul 18, 2017

I have two questions:

i) Is it possible to add support for arara
ii) Can I somehow disable the quickfix parsing? I've set

let g:vimtex_compiler_enabled = 0

but I would also like to set

let g:vimtex_quickfix_method = 0

and parse the quickfix myself.
Thanks!!

@lervag
Copy link
Owner

lervag commented Jul 19, 2017

I'll look into arara. I'm pushing an update for the second request as we speak.

lervag added a commit that referenced this issue Jul 19, 2017
@petobens
Copy link
Author

Thanks for the quick fix!

Regarding arara, my ararara.yaml config looks like this:

---
!config

# Define key to minimize number of runs.
# Note that we always use batchmode since arara sees pdftex exit code and stops
# without executing further directives only if the exit code of the command was
# not zero (independent of the visibility on the console).
preambles:
    minimize_runs: |
        % arara: pdflatex: {interaction: batchmode, synctex: yes, shell: yes,
        % arara: --> options: ["-file-line-error", "-max-print-line=120"]}
        % arara: biber if found('log', 'Please \\(re\\)run Biber on the file')
        % arara: --> && found('bcf', 'citekey')
        % arara: pdflatex: {interaction: batchmode, synctex: yes,
        % arara: --> options: ["-file-line-error", "-max-print-line=120"]}
        % arara: --> if found('log', 'Please \\(re\\)run Biber on the file')
        % arara: --> && found('bcf', 'citekey')
        % arara: pdflatex: {interaction: batchmode, synctex: yes, shell: yes,
        % arara: --> options: ["-file-line-error", "-max-print-line=120"]}
        % arara: --> if found('log', '(undefined references|Please rerun|Rerun to get)')

I can then replicate latexmk functionaly by running arara -p minimize_runs -v main.tex.
Thank you!!!

lervag added a commit that referenced this issue Jul 25, 2017
@lervag
Copy link
Owner

lervag commented Jul 25, 2017

Ok, I've added an initial version of this now. I don't really think it will work very well, but it is a starting point. If you are willing to help me, I think we can make this work well together.

To be more specific: I don't quite understand how to define a natural default behaviour. It seems arara depends on directives in the preamble, although based on your last post I understand you can or should use yaml files. Before I understand how this should be expected to work, it is (of course) difficult to provide a natural interface from vimtex.

It would also be useful to get some info on how you think the different commands should work from an arara perspective. I assume arara does not do continuous compilation..?

@petobens
Copy link
Author

Thank you! I will test it this weekend. I know @cereda is a vim user so he might be interested...

@lervag
Copy link
Owner

lervag commented Jul 25, 2017

No problem. Although so far this is very untested and will probably fail... :p

@cereda
Copy link

cereda commented Jul 26, 2017

I've been summoned here by the power of poking ducks! 😄

Hello friends!

Nice to meet you, Karl! It is always a great experience to learn about awesome projects like yours and make new friends. That's what open source and knowledge sharing are about. 😉

The default behaviour of arara relies on reading the directives (special commands inside comments) and taking whatever semantic actions were specified. A document with, say,

% arara: pdftex
Hello world.
\bye

will tell arara to run PDFTeX on the file. If I add another % arara: pdftex line somewhere in the document, the tool will run PDFTeX twice, and so forth. It's arara's responsibility to know what to do with the file. 😉

A very straightforward approach would be a simple external call to arara on the current file, like one would run pdflatex or other engine. Eventually, it could be interesting to specify some flags, say --log, in order to provide a better understanding of what's going on under the hood. I cannot remember if arara 3.0 (currently in TeX Live and MiKTeX) has exit codes, but version 4.0 (the one Pedro is using) certainly has. It follows the usual conventions. My source code helps me remind what my self past did at that time:

  • 0 : everything went just fine (note that the dry-run mode always makes arara exit with 0, unless it is an error in the directive builder itself).
  • 1 : one of the tasks failed, so the execution ended abruptly. This means the error relies on the command line call, not with arara.
  • 2 : arara just handled an exception, meaning that something bad just happened and might require user intervention.

So far so good. Then Pedro decided to complicate things. 😄

As seen in https://github.com/cereda/arara/issues/65, we can now have a predefined preamble. The new --preamble flag takes an argument, which is the corresponding identifier. Maybe the vim plugin could take an optional parameter referencing this feature (if empty, run arara normally, or run arara with --preamble <value> otherwise).

That's it, basically. 😄

Thanks for your effort in making the vim world better! Cheerio!

Paulo

:wq

@mjezzini
Copy link

Hello,

I would like to use arara too. So I added to my vimrc

let g:vimtex_compiler_method = 'arara'

based on the doc (g:vimtex_compiler_method)

Now, when I open an existing tex file I get the next error

vimtex warning: latexrun is not executable!
vimtex#compiler was not initialized!

Other than that error the file opens normally. Runing :VimtexCompile throws:

Error detected while processing function vimtex#compiler#compile:
line 1:
E716: Key not present in Dictionary: compiler, 'continuous')
E116: Invalid arguments for function get(b:vimtex.compiler, 'continuous')
E15: Invalid expression: get(b:vimtex.compiler, 'continuous')

At the moment I am manually compiling by :silent !arara main.tex. The quickfix parses the warnings and errors correctly, but I need to call the quickfix window by \le (no autoopen).

@lervag
Copy link
Owner

lervag commented Aug 8, 2017

First, all: Sorry for taking so long to respond. It's been summer holidays, and
I've barely managed to keep on top of more serious issues. I finally have some
time to consider the arara stuff again.

@cereda Nice to meet you as well, Paulo! I'm happy to see you join the
discussion, and thanks for your input on how arara works. I don't think the preamble feature
will be a problem for vimtex, since this is still specified in the file that
vimtex runs arara on. One thing, though: Can arara be used to clean
auxilliary files in a similar manner as latexrun and latexmk? If so, how?

@mjezzini I'm sorry that you had to experience the pre-alpha version. I've
pushed some updates that should fix most of the issues. Please test, I will be
happy to get some feedback.

@petobens I think things should work relatively well now. Doing \ll will run arara -v main.tex. You can specify options with let g:vimtex_compiler_arara = {'options' : [...]}, e.g. if you want to add the -p minimize_runs option. If I undestand correctly, you could also just have a % arara: minimize_runs at the top of your tex file, which makes the option unnecessary.

Let me know what you all think. I guess the main thing lacking now is the docs...

lervag added a commit that referenced this issue Aug 8, 2017
@lervag
Copy link
Owner

lervag commented Aug 8, 2017

I've updated the docs and removed the experimental label. I think things work mostly as expected now.

@lervag lervag closed this as completed Aug 8, 2017
@cereda
Copy link

cereda commented Aug 9, 2017

@lervag Hello, Karl!

Can arara be used to clean auxilliary files in a similar manner as latexrun and latexmk? If so, how?

Yes and no, actually. 😉 The tool takes a different approach and requires an explicit mention, in the form of a directive, of which files should be removed. For instance (using the new syntax introduced in version 4.0):

% arara: clean: { files: [
% arara: --> test.aux,
% arara: --> test.log,
% arara: --> test.toc
% arara: --> ] }
\documentclass{article}
...

Another way of achieving this is by using extension matching:

% arara: clean: { extensions: [ aux, log, toc ] }
\documentclass{article}
...

However, this approach only removes files based on the base name of the current file + provided extensions. The two approaches can be combined at any time.

In short, arara does not have a built-in cleaning feature as latexmk (e.g, either -c or -C), but this can be reproduced as a set of directives inside the file. The tool expects an explicit indication of what to do in those cases. 😉

Cheerio!

@petobens
Copy link
Author

petobens commented Aug 9, 2017

@lervag thank you!!

@lervag
Copy link
Owner

lervag commented Aug 9, 2017

@petobens Happy to help :)

@cereda I'm not sure I understand. How do you determine if you do clean or compile? Can you have multiple directives in one file, then specify on the command line which directive to use? I guess that is what @petobens example sort of shows, and so this makes sense. I think one could use this to allow cleaning from vimtex by assuming there is a clean directive available. However, perhaps it is simpler to just use latexmk for cleaning from vimtex, even with arara?

My proposal is this: If being able to clean the document from vimtex (e.g. with the \lc mapping) is desirable, then I suggest @petobens or someone else opens a new issue and explains how a project would look like that allows both compiling and cleaning with arara. I could use that as a starting point for making an interface that seems sensible.

@cereda
Copy link

cereda commented Aug 10, 2017

@lervag Hello, Karl!

This might sound like a paradigm shift: arara does not have the concept of compilation or even cleaning. The tool simply reads the document preamble (either directly in the source code or through the switch @petobens uses with predefined entries) and extract directives, in the form of % arara:. Those lines tell the tool of what to do with that file and nothing more. Say I have:

% arara: pdftex
% arara: pdftex
Hello world.
\bye

The two directives tell arara to run pdftex twice on this document. Another example:

% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
...

This is a typical scenario for a paper or thesis writing, in which you have to rerun your engine a couple of times in order to get labels correctly adjusted, and one run of bibtex to generate the underlying bibliography. In this new scenario:

% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: pdflatex
% arara: clean: { files: [ mypaper.log ] }
\documentclass{article}
...

I added a clean rule in the end which will remove mypaper.log as the last step. The tool does only what is told to do through directives, that's why it's quite different from latexmk. So, there's no cleaning feature out of the box unless the user explicitly tells arara of what it should remove.

The command line switch @petobens uses refers to shortcuts of predefined preambles which will be appended to the existing one inside the source code. Directives are all executed once found (there are conditionals too, but for now let us keep things simple). 😉

Sorry if my explanation was a bit confused, it's early in the morning and I am running out of coffee. ☕️ 😉

Cheerio!

Paulo

@lervag
Copy link
Owner

lervag commented Aug 10, 2017

Ok, I think I understand. And if I do, then I think the current seemingly minimal implementation should work well. Thanks for your input, @cereda!

@mjezzini
Copy link

@lervag I can confirm that let g:vimtex_compiler_method = 'arara' works in my case. Thank you for this amazing plug in!

@lervag
Copy link
Owner

lervag commented Aug 11, 2017

Great, happy to hear it! And thanks for the kind words :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants