ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Scala Syntax

by gwenzek ST3

A syntax file for Scala in Sublime

Details

Installs

  • Total 4K
  • Win 1K
  • OS X 2K
  • Linux 931
Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4
Windows 0 2 3 1 0 3 0 0 0 1 3 2 1 3 1 1 2 1 2 4 6 1 2 5 2 1 4 5 1 4 3 6 3 3 4 6 3 4 1 2 2 3 1 2 5 1
OS X 2 3 6 1 1 1 3 0 1 1 1 1 1 2 4 3 5 1 1 1 0 5 0 5 4 1 2 3 8 7 3 7 2 5 5 12 8 3 1 1 1 5 4 3 1 1
Linux 0 3 1 1 2 1 0 1 0 2 2 1 0 0 2 1 2 3 1 0 1 2 2 3 2 0 0 3 1 2 3 1 0 1 5 4 4 0 3 2 0 4 3 1 0 2

Readme

Source
raw.​githubusercontent.​com

sublime-scala-syntax

Improved syntax for Scala in Sublime Text. This syntax was wrote around release 3084 of ST. Meanwhile the Scala syntax has been improved and now supports several features from this syntax. Still there are some differences that I didn't got integrated in the main version because the others contributor didn't like them.

The main syntax has probably less bugs because it has been more tested.

I - Installation

This plugin is available on package control. It's recommended you get it from there.
If you know what you're doing you can also clone the repository in your Packages/User folder.
If you don't see this plugin in package control is likely because you have a too old version. The plugin will only be visible with a build >= 3084.

Then you can change a given file using the command set syntax: Scala2, or through the menu: View > Syntax > Scala2.
If you like it you can set it as default for .scala files with View > Syntax > Open all with current extension as ... > Scala2.

The new syntax will improve the way your scala code is colored. But to get the best out of it I recommend using the modified version of the Espresso Libre color theme I made. If you don't like Espresso, the diff between the old version and the new one should help you to port your favorite color theme.

II - Features

Build 3084 of Sublime introduced a new format for syntax definition files.
The documentation can be found here.

I took this is as a great opportunity to improve the scala syntax highligthing in Sublime.
The following features has been implemented in this syntax. Ticked features are now also present in the main Scala syntax.

  • [x] string interpolations (like s"Foo: $foo")
  • [x] complex method names (like abc_*^=)
  • [x] annotations (like @tailrec)
  • [x] xml inside scala code
  • [ ] escaped characters (like '\u2101')
  • [ ] wrongly escaped characters
  • [ ] function calls
  • [ ] precice scope for braces and punctutation
  • [ ] formatting inside scaladoc comments
  • [ ] operators

As I always found my scala files really savorless compared to my python files, I added a bit of color on operators, types and predef methods (println, assert, …).

Also, I put very precise scopes on punctuation allowing the punctuation to be nicely colored. For instance curly braces aren't the same if they mark a class or a function.

Here is a comparaison between the actual Sublime Text highlighting (version 3140) and mine:

Default Scala syntax:

alt text

This Scala syntax:

alt text

III - Disclaimer

Scala is a complex language with a rich syntax, so I haven't covered all the language yet and I may have introduced regressions.
If your code is poorly colored please open an issue with a sample.