Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Ensime + SBT to browse scala library

Is it possible to use Ensime and SBT to go to the definition of Scala library classes?

I know it is possible to see the definition of elements (using M-. or Control+Left-Click) and from there it's possible to see the doc page. Is there any way to tie this functionality into src as well?

UPDATE:

my project config (.ensime file):

(
  :root-dir "/Users/eugene/tmp/scrap"
  :sources (
    "/Users/eugene/tmp/scrap"
  )
  :reference-source-roots (
    "/usr/local/Cellar/scala/2.9.2/libexec/src"
  )
 :compile-deps (
    ""
  )
  :target "/Users/eugene/tmp/scrap"
)

/usr/local/Cellar/scala/2.9.2/libexec/src contains:

scala-compiler-src.jar scala-library-src.jar  scala-swing-src.jar
scala-dbc-src.jar      scala-partest-src.jar  scalap-src.jar

build.sbt:

name := "scrap"

version := "0.1-SNAPSHOT"

scalaVersion := "2.9.2"
like image 227
Eugene Cheipesh Avatar asked Nov 01 '12 04:11

Eugene Cheipesh


People also ask

Does sbt contain Scala?

sbt's Scala version sbt needs Scala jars to run itself since it is written in Scala. sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs.

Does sbt download Scala?

Having said that, at the very beginning, sbt will always download its own internal dependencies, Scala including. It is then saved in ~/.

How do I use sbt to build a Scala project?

We’ll use sbt, the de facto build tool for Scala. sbt compiles, runs, and tests your projects among other related tasks. We assume you know how to use a terminal. Run javac -version in the command line and make sure you see javac 1.8.___ cd to an empty folder. Run the following command sbt new scala/hello-world.g8 .

What tools can I use to build a Scala project?

Learn more about sbt new and project templates in the documentation of sbt. While sbt is widely used, there are other tools you can use to build Scala projects: In a related note, Coursier is a “dependency resolver,” similar to Maven and Ivy in function.

How do I cross-compile a Scala 3 project with Scala 2?

If you want to create a Scala 3 project that cross-compiles with Scala 2, use the template scala/scala3-cross.g8: Learn more about sbt new and project templates in the documentation of sbt. While sbt is widely used, there are other tools you can use to build Scala projects:

How do I import Scala-parser-combinators into SBT?

Here, libraryDependencies is a set of dependencies, and by using += , we’re adding the scala-parser-combinators dependency to the set of dependencies that sbt will go and fetch when it starts up. Now, in any Scala file, you can import classes, objects, etc, from scala-parser-combinators with a regular import.


1 Answers

Download the sources of scala-library and then set :reference-source-roots in your project config file.

like image 93
Eugene Burmako Avatar answered Oct 05 '22 15:10

Eugene Burmako