Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Latest commit

 

History

History
112 lines (85 loc) · 3.99 KB

README.org

File metadata and controls

112 lines (85 loc) · 3.99 KB

ammonite-term-repl

Scala Ammonite REPL in Emacs term mode.

https://melpa.org/packages/ammonite-term-repl-badge.svg

Install

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.

Usage

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`

Detecting predef.sc

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:

  1. amm --predef $HOME/ammonite/term/repl/predef.sc
  2. amm --predef $HOME/ammonite/term/predef.sc
  3. amm --predef $HOME/ammonite/predef.sc
  4. amm --predef $HOME/predef.sc
  5. 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)

Auto config mill project

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)

Keybindings

ammonite-term-replC-` or C-c C-z
ammonite-term-repl-send-defunC-c C-e
ammonite-term-repl-send-regionC-c C-r
ammonite-term-repl-load-fileC-c C-l

Hooks

ammonite-term-repl-minor-mode-hook ammonite-term-repl-run-hook

Variables

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")

Why not comint-mode

Because (make-comint "amm") throws a Exec format error. Run amm in eshell also get the same error.

Screenshot

./screenshot.png