Rich Dougherty rd.nz

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='http://www.freedesktop.org/standards/shared-mime-info'>
    <mime-type type="text/x-scala">
    <comment>Scala programming language</comment>
    <glob pattern="*.scala"/>
    </mime-type>
    </mime-info>
    
  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/ https://raw.github.com/scala/scala-dist/master/tool-support/src/gedit/scala.lang
    
  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.