david.perez david.perez - 2 months ago 12
Scala Question

What is the best way of having autocompletion in IDEA for Ammonite scripts

Suppose I do this in my Ammonite script:

import ammonite.ops._


but I don't have autocompletion in IDEA, because it doesn't know I'm using this dependency from:

"com.lihaoyi" %% "ammonite-ops" % "0.7.7"


The same can be said when I import some ivy module using this syntax:

import $ivy.`com.google.guava:guava:18.0`


What is the best way to let IDEA know what dependencies I'm using?

References:


Answer

One solution is to create a module that holds the scripts.

I create a new module by defining a project in SBT and adding the dependencies necessary:

projectDependencies ++= Seq(
    "com.lihaoyi" %% "ammonite-ops" % "0.7.7"
)

Then I have to reimport the SBT project into IDEA. The process is a little slow, but voilĂ , I can have autocompletion in my scritps.

I've created also an issue in IDEA for 1st class support of Ammonite. https://youtrack.jetbrains.com/issue/SCL-10752