Scala Ammonite REPL in Emacs term mode.
brew install ammonite-repl
It is recommended installed by the MELPA package system.
You could install it by M-x
: with package-install
: ammonite-term-repl
.
To start an ammonite repl, you can just hit M-x:
with run-ammonite
(add-hook 'scala-mode-hook
(lambda ()
(ammonite-term-repl-minor-mode t)))
If you have a build.sbt with dependencies in this form (and only this form)
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.21",
libraryDependencies += "org.scalanlp" %% "breeze" % "0.13.2",
libraryDependencies += "org.scalanlp" %% "breeze-natives" % "0.13.2",
libraryDependencies += "org.scalanlp" %% "breeze-viz" % "0.13.2",
libraryDependencies += "org.apache.spark" %% "spark-core" % "2.4.0" % "provided",
libraryDependencies += "org.apache.spark" %% "spark-mllib" % "2.4.0" % "provided",
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.4.0" % "provided",
libraryDependencies += "org.apache.spark" %% "spark-streaming" % "2.4.0" % "provided"
command ammonite-term-repl-import-ivy-dependencies-from-sbt
will try to convert and import this to your Ammonite process.
import $ivy.`com.typesafe.akka::akka-actor:2.5.21`
import $ivy.`org.scalanlp::breeze:0.13.2`
import $ivy.`org.scalanlp::breeze-natives:0.13.2`
import $ivy.`org.scalanlp::breeze-viz:0.13.2`
import $ivy.`org.apache.spark::spark-core:2.4.0`
import $ivy.`org.apache.spark::spark-mllib:2.4.0`
import $ivy.`org.apache.spark::spark-sql:2.4.0`
import $ivy.`org.apache.spark::spark-streaming:2.4.0`
If you can have many predef.sc
files for your Ammonite, it would be great. ammonite-term-repl
can detect predef.sc
file from your current location up to $HOME
. If you are on $HOME/ammonite/term/repl/scala.org
, it will try finding it in following order:
amm --predef $HOME/ammonite/term/repl/predef.sc
amm --predef $HOME/ammonite/term/predef.sc
amm --predef $HOME/ammonite/predef.sc
amm --predef $HOME/predef.sc
amm --predef $HOME/.ammonite/predef.sc
If you don’t like it, you can turn off:
(setq ammonite-term-repl-auto-detect-predef-file nil)
If you use mill to build your project, this will auto set ammonite-term-repl-program
to “mill” and ammonite-term-repl-program-args
to ‘(-i foo.repl).
If you don’t want this, you can turn off:
(setq ammonite-term-repl-auto-config-mill-project nil)
ammonite-term-repl | C-` or C-c C-z |
ammonite-term-repl-send-defun | C-c C-e |
ammonite-term-repl-send-region | C-c C-r |
ammonite-term-repl-load-file | C-c C-l |
ammonite-term-repl-minor-mode-hook
ammonite-term-repl-run-hook
ammonite-term-repl-program-args
An example
(setq ammonite-term-repl-program-args '("-s" "--no-default-predef"))
ammonite-term-repl-predef-sc-filename
You can change predef.sc
filename
(setq ammonite-term-repl-predef-sc-filename "predef.sc")
ammonite-term-repl-default-predef-dir
You can change Ammonite home directory
(setq ammonite-term-repl-default-predef-dir "~/.ammonite")
Because (make-comint "amm")
throws a Exec format error
.
Run amm
in eshell also get the same error.