5
5

More than 5 years have passed since last update.

ScalaでHello Worldまで+vim設定 on Mac

Last updated at Posted at 2012-04-24
[15435]hash% brew install scala
Warning: You have Xcode 4.1, which is outdated.
Please install Xcode 4.3.

いきなりぐぬぬ。でも一応インストールは始まる。後でバージョン上げとこう。

==> Downloading http://www.scala-lang.org/downloads/distrib/files/scala-2.9.2.tgz
######################################################################## 100.0%
==> Downloading https://raw.github.com/scala/scala-dist/27bc0c25145a8/completion.d/2.9.1/scala
######################################################################## 100.0%
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
/usr/local/Cellar/scala/2.9.2: 38 files, 26M, built in 2.1 minutes
% which scala
/usr/local/bin/scala

% scala -version
Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL

ほむ。irb的な対話shellがあるよ。

% scala
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.

scala> print("heyhey")
heyhey

ふむふむ。

hello.scala
object HelloWorld {
  def main(args: Array[String]) {
    println("Hello Scala!!")
  }
}

見た感じあかぬけたJavaって感じ。scalacでコンパイル, scalaで実行。

% scalac hello.scala
% ls
HelloWorld$.class  HelloWorld.class   hello.scala

クラスファイルができた。なんだ"$"って。

% scala HelloWorld
Hello Scala!!

vim設定

scalaのsyntax highlight -- Scala Bazaar System -- 通称sbazという、scalaにとってのgemを使いたい。なんか他のトコ見てるとbrewでscala入れたら当然入ってるよね的な空気で泣きたい。

sbaz探してさまよってたけど、どうもsyntax highlightについては公式(?)のscala.vimを入れれば事足りそう。

.vimrc
+ Bundle 'scala.vim'

augroup MyAutoCmdFileType
  autocmd! MyAutoCmdFileType 
+ autocmd BufRead,BufNewFile *.scala set filetype=scala
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5