GithubHelp home page GithubHelp logo

ammonite-term-repl's Introduction

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

ammonite-term-repl's People

Contributors

kschwarz1116 avatar zwild avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.