LaTeX code listings with Minted

While typesetting an article I had some code highlighting issues with the standard LaTeX listing package, so I departed on an epic journey in search of a better alternative. Seriously though, I found Minted, which is pretty awesome because it uses the Python library Pygments for highlighting, and is therefore a lot more powerful than the standard LaTeX stuff:

After some twisting and tweaking, and with the help of the Minted documentation and some awesome people on Stackoverflow, I came up with the following code listing style, which I deem acceptable:

Here’s a little excerpt from my LateX:

% This is how minted is configured
\usepackage{minted}
\usepackage{caption}
\floatsetup[listing]{style=Plaintop}

\DeclareCaptionFont{white}{\scriptsize\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\linewidth-2\fboxsep}{#1#2#3}}}
\captionsetup[listing]{format=listing,labelfont=white,textfont=white}

\newmintedfile{javascript}{numbersep=5pt, linenos, fontsize=\footnotesize, frame=bottomline, framesep=3mm
}

% This is how a listing is created, in this case for JavaScript
\begin{listing}
    \javascriptfile{../code/design/agent-directory-entry.json}
    \caption{Example of an agent directory entry in JSON representation}
    \label{code:design:agent-directory-entry}
\end{listing
}

Dark Pastels with Groovy support for IntelliJ IDEA 11

I recently ran across the awesone Dark Pastels color scheme for IntelliJ IDEA by Ted Wise:

(image taken from here)

Unfortunately it didn’t support Groovy and had some minor other flaws (in my opinion) which I have corrected. The Groovy highlighting looks like this:

Installation

Download the coding-journa-dark-pastels.jar and import it using the File -> Import Settings dialog from the IntelliJ menu.

Suggestions and Bugs

Have a suggestion or found something odd? Leave a comment and I’ll get back to you :)

Using Groovy classes from within Java when building with Gradle

I’ve been experimenting a bit on Terasology, an open-source game inspired by Minecraft. They’re using Groovy and Java in their project, and their build tool is gradle.

Unfortunately it wasn’t as straight forward as I had hoped to use a Groovy class from within Java, because by default, Gradle seems to first invoke the Java compiler and afterwards the Groovy compiler, which leaves the former with missing symbols (the classes from Groovy that haven’t been compiled yet).

Apparently, to enable “joint compilation”, you have to force the Groovy compiler to compile both Java and Groovy sources (as stated here), which can be done by adding the following snippet to your “build.gradle”:

sourceSets {
    main {
        java { srcDirs = [] }    // no source dirs for the java compiler
        groovy { srcDir ‘src’ }  // compile everything in src/ with groovy
   }
}