Saturday, February 02, 2008

A *new* Scala Bundle for Textmate

No doubt, the upcoming Scala Module will make Netbeans the No.1 Scala IDE. I use the current pre-release version on my linux box at work without any difficulties. Unfortunately, I have encountered problems running the recommended daily development builds of Netbeans on my private macbook pro. I hoped that I could at least use my favorite editor for MacOS X, Textmate, but the bundle shipped with Scala 2.6.1 still seems to be a dummy/placeholder. Well, instead of falling into a deep depression, I invested half a day to create a new bundle myself.

For those interested, please find the download below:

- The Scala Bundle
- An Example Project (with some sources ripped from scala-lang.org)

The main goal was to have simple syntax highlighting, which actually looks quite good using the 'Cobalt Theme'. (I'm not 100% sure that value:Type is always displayed correctly, but it seemed to work with the samples.)

Further, there is a template for an Ant-Script which includes a compile, run & deploy task. These can be executed as bundle commands (menu or shortcuts), if the file is called 'build.xml'. Customization should be easy with a few properties at the top of the file.

Finally, there are a few snippets to write new code quickly. E.g. typing

trait ->| Adder ->| def ->| add ->| Int ->| 2 ->| left ->| Int ->| right ->| Int

results in
/**
* Adder
*/
trait Adder
{
def add ( left : Int, right : Int ) : Int
}
without pressing two keys at the same time (no SHIFT)!

But of course you can sketch your own (and share them with me =) ) !

7 comments:

Andreas Meingast said...

Thanks a lot! Have you thought about submitting it to the textmate folks to get it into their bundle repository?

Bobo said...

thanks for sharing this!

ifesdjeen said...

i'm constantly getting this error:
Searching for build.xml ...
Buildfile: /Users/oleksandr/projects/illinois/ScalaExamples.project/build.xml

init:
[taskdef] Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found.

compile:

BUILD FAILED
build.xml:80: Problem: failed to create task or type fsc
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.


do you have any idea why does it happen?
thank you

Unknown said...

The build.xml defines a scala.home property, I bet it doesn't point to your scala installation. Look for

<property name="scala.home" value="/usr/local/scala/"/>

ifesdjeen said...

Thank you Michael!

I've fixed this one, but another appeared: "Could not connect to compilation daemon. java.lang.Exception: fsc failure"

Should i have launched FSC as a service somehow?.. thank you!

Unknown said...

Hm no, the fsc 'service' is started the first time it's called... sounds more that the specific port is blocked on your machine. Does fsc work when you call it form the SCALA_HOME/bin/ from the terminal?

Anyhow, the simplest work-around is to replace <fsc ...>..</fsc> with <scalac ...>..</scalac> in the build.xml.

That way the standard scalac is used which means subsequent compilation might be a bit slower =(

Tim said...

THANK YOU
(saved me spending the day doing this - much appreciated)