Syntax highlighting of roxygen documentation in TextMate

With roxygen now on github, the release of roxygen2 and Hadley’s might now behind the project I expect roxygen to gain even more momentum.

R development in TextMate is great with the R bundle. Unfortunately the R bundle does not support highlighting of roxygen documentation by default. That was always a sticking point for me switching to roxygen because TextMate has really nice highlighting for Rd files.

So I hacked on the syntax file to get at least some preliminary highlighting of stuff after roxygen comments (#'). The file is in a gist over at github. It doesn’t yet work quite as well as I would like but it is better than nothing. In particular, highlighting of R code in examples does not work. Contributions/additions are welcome.

You must have must have the R bundle installed. The easiest way to install is to open the bundle editor (“Bundles” > “Bundle Editor” > “Show Bundle Editor”) and copy this file over the R syntax file from the R bundle. Then “Reload Bundles” or restart TextMate.

You may need to install the R bundle first if you have not already:

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd /Library/Application\ Support/TextMate/Bundles
svn co http://svn.textmate.org/trunk/Bundles/R.tmbundle

Then either reload the bundles or restart TextMate to get the bundle activated.

2 thoughts on “Syntax highlighting of roxygen documentation in TextMate

  1. Cool. I hope this develops a bit further. Right now if you have something like var$item in an @examples section, the rest of the file is colored as if it was waiting for a closing $ in tex. Also, @references is not picked up. That being said, I am a total noob on these syntax files and I tip my hat to your work.

  2. Thanks for the report, I see that happening too, There are definitely some tricky things to figure out. I should get it sorted out soon since I want to use it too!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>