Flow
Flow

Reputation: 24083

How to enable tab completion in Scala's MainGenericRunner REPL (interactive interpreter)?

I've added a REPL (read eval print loop) to may Java project1 which is build with maven. The REPL can be started with a script. The relevant parts are

declare -r GRADLE_CLASSPATH="$(gradle :minidns-repl:printClasspath --quiet |tail -n1)"

java \
    -Dscala.usejavacp=true \
    -classpath "${GRADLE_CLASSPATH}" \
    scala.tools.nsc.MainGenericRunner \
    -i minidns-repl/scala.repl

This works so far. The only thing that is missing which would make the REPL perfect is tab completion. I know from Scala that it does support this.

How can I enable it for MainGenericRunner?

1: Feel free to test the REPL:

git clone https://github.com/rtreffer/minidns.git \
  && cd minidns \
  && ./repl`

Then perform a DNS query, e.g. c.query("wikipedia.org", TYPE.A)

Upvotes: 3

Views: 623

Answers (2)

vitalii
vitalii

Reputation: 3365

Although current scala repl has autocompletion feature right now it is not working very well. (that's aside the issue mentioned by som-snytt).

If you need the working completions in repl you best bet would be Ammonite REPL which also has some more features then the standard repl.

NOTE: I haven't tested tab completions in 2.11.8, but it looks like they had been rewritten from scratch and are looking very promising.

Upvotes: 2

som-snytt
som-snytt

Reputation: 39577

There's a known issue with the way -i is handled, that breaks completion.

There's also a fix pending, but I don't if it will get into 2.11.8, which also has an entirely new completion feature.

Upvotes: 1

Related Questions