Getting started with scala-mode and emacs

Does anyone on this forum ever interact with the ensime-emacs development community?
There is lots of documentation about ensime and scale-mode for emacs, but it’s extremely difficult to understand, especially for the beginner. I suspect that for the most part, the only people using it are people who are already experts. The documentation is pretty hostile to the beginner, in the sense that the undertone is “don’t ask questions until you’ve read all the documentation and you are sure you’re question is not covered somewhere hidden in the available documentation”. It could be that the actual community is friendlier than the documentation might appear.

If anyone can give me advise about how to address that forum without being yelled at or ignored, I’d love to have your advise before I dive in head first.

1 Like

I started using ensime-emacs last month. What exactly is your problem?

If you are using sbt and emacs, I would recommend reading http://ensime.github.io/build_tools/sbt/ and http://ensime.github.io/editors/emacs/install/ first.

I basically followed the instructions on the sbt part and since I am familiar with emacs, I did not follow the emacs part and did it in my own way.

Although the documentation is not detailed, it helped me get started.

Thanks for the offer to help. I hope it is easy for you.
I have lots of problems. But let’s start with one.
I start sbt and run ensimeConfig, and I get the output below.
I don’t understand what it means “the base of your project”.
In my case I have only one scala file, at it is inside a directory src/main/scala

sbt:scala> ensimeConfig
[info] ENSIME update.
[info] Updating ...
[info] Done updating.
[info] ENSIME processing scala (scala)
[warn] You have .scala files in the base of your project. Such "script style" projects
[warn] are not supported by ENSIME. Move them into src/main/scala to get support.
[warn] Please read https://github.com/ensime/ensime-server/issues/1432
[error] org.ensime.EnsimePlugin$$anon$2: To ignore this error, customise `ensimeIgnoreSourcesInBase`
[error] (ensimeConfigTask) org.ensime.EnsimePlugin$$anon$2: To ignore this error, customise `ensimeIgnoreSourcesInBase`
[error] Total time: 2 s, completed Feb 19, 2019 9:31:35 AM
sbt:scala> 

A typical structure for sbt project directory looks like the
following. It is in the same style as Java.

.
├── build.sbt
├── project
│   └── build.properties
└── src
    ├── main
    │   └── scala
    │       └── example
    │           └── Hello.scala
    └── test
        └── scala
            └── HelloSpec.scala

7 directories, 4 files

I believe what ENSIME complains on your machine is that you have scala
files on your project root directory (the directory containing
build.sbt, project, and src). And you can simply remove those
scala files or move them to other directories outside the directory.

Thanks, I have made a bit of progress.

BTW, I don’t know Java, and have been hoping not to have to learn Java in order to use Scala. Although, unfortunately, from time to time, being Java-illiterate hits me in the face when trying to use Scala.

I don’t have any build.sbt file, but there is a project/build.properties.
The problem, as I understand it was that I had the Hello.scala file inside the source/scala directory rather than in the soure/main/scala directory.

In fact I just one one single scala file, but it seems I need this HUGE directory structure, which is unfortunately. And if the structure is wrong, lots of things get confused, and give incomprehensible error message. It would be great, if the tools would check for the directory structure they are assuming. sigh :frowning:

Question: are you new to Scala? If so: trying to learn Scala, sbt and Ensime all at the same time – I don’t know if I’d recommend that. (I find Ensime a bit intimidating, and I’ve been doing Scala for ten years.)

I’d strongly recommend getting the sbt part working first – unless you really know what you’re doing, you will want a build.sbt file. You don’t need to build that file, and the whole directory structure by hand, though – you should usually start with the sbt new command, which builds it out for you, and then place files in that structure…

1 Like

New? not sure how new is new. I’ve been playing with it for a while (2 or 3 years), but always in a project which someone else set up. However, I’m a long time emacs user (30? years). What I’m currently working on is a Common Lisp project where I’d like to test some performance of certain calculations using Scala vs Common Lisp.

I agree with you though that learning Scala is much easier than learning sbt, Java, IntelliJ and any other implicitly required tools. I’m sure these tools are great once they work, but getting them working is not easy. All the complicated tools make Scala look much more complicated than it really is.