Sunday, March 25, 2012

Scala in gedit

The standard distribution of gedit doesn't understand Scala source. Here's how to add it.

  1. Create ~/.local/share/mime/packages/scala-mime.xml with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns=''>
    <mime-type type="text/x-scala">
    <comment>Scala programming language</comment>
    <glob pattern="*.scala"/>
  2. Register the new MIME information and check that the registration has been successful.
    $ update-mime-database ~/.local/share/mime
    $ gnomevfs-info myfile.scala | grep MIME
    MIME type         : text/x-scala
  3. Add the Scala syntax highlighting information.
    mkdir -p ~/.gnome2/gtksourceview-1.0/language-specs/
    wget -P ~/.gnome2/gtksourceview-1.0/language-specs/
  4. Enjoy your highlighted source!
    $ gedit myfile.scala

This post is based on information from Shashank Tiwari and from the GNOME Desktop System Administration Guide.