Just finding out today that we now need to PAY for IntelliJ IDEA even just for private individual use. What other (hopefully freeware) options are available for Scala programming?
Uhm, I’m not sure about the IntelliJ thing.
But to answer your question, you can use metals to enhance multiple text editors with IDE-like capabilities.
Personally, I like to use VSCode + metals + sbt (as the BSP) as my default setup.
Hello,
I’m from the IntelliJ Scala team. IntelliJ IDEA Community Edition with the Scala plugin is free of charge, as always. I guess it might be a bit confusing, because on the main IntelliJ webpage only the Ultimate (paid) edition is being advertised. To download the Community edition, you need to either install JetBrains Toolbox first (JetBrains Toolbox App: Manage Your Tools with Ease) and find it in the list of JetBrains products there, or you can download the standalone version from here: Other Versions - IntelliJ IDEA .
VS Code + Metals + SBT is great!
If you don’t need a big project + complex build tool, you can also use VS Code + Metals + Scala-cli
After years of using Eclipse I switched to Sublime Text + Metals +SBT. It’s really easy to configure to your own liking. Because I never used IntelliJ I cannot compare it to that. Note that Sublime is not free, but can be evaluated as long as required, payment based upon trust
I just wished this other link was easier to find on Jetbrains page itself or via a search engine.
If you are on linux there is this unofficial ppa for the community version:
You can on linux/ubuntu/debian:
sudo add-apt-repository ppa:mmk2410/intellij-idea-community
sudo apt update
sudo apt install intellij-idea-community
If you want vscode + scala on linux/ubuntu/debian I can really recommend the combo sdkman + deb-get:
Whit sdk and deb-get on your path you can:
sdk install scala
sdk install scalacli
sdk install sbt
deb-get install code
code --install-extension scalameta.metals
The Scala website now has a canonical page on this topic: Scala IDEs | Scala Documentation
(thanks to @makingthematrix for writing it!)
emacs + metals is really great!
I’ve been using emacs forever, but I’ve never been able to successfully use a Scala IDE with it. Anything that involves editing the .emacs configuration file never seems to work for me. Is there an easy installation option for using metals with emacs?
-
In emacs >= 29.1, they natively provide eglot, a client for language server protocol (lsp). If you have lower version of emacs, you need to install eglot. So it will use metals as Scala LSP.
-
Install metals for emacs as followed.
coursier bootstrap \
--java-opt -XX:+UseG1GC \
--java-opt -XX:+UseStringDeduplication \
--java-opt -Xss4m \
--java-opt -Xms100m \
--java-opt -Dmetals.client=emacs \
org.scalameta:metals_2.13:1.3.5 -o metals -f
I learn this from the metals’ website here. It says that
The
-Dmetals.client=emacs
flag is important since it configures Metals for usage with Emacs.
But they did not add it into their formula, to my surprise. So I add it here.
-
Once you have installed metals, put it anywhere that PATH could find it.
-
Here is my Scala configuration. I also have some key bindings for eglot, which include the common commands I use often. When you open your Scala file, it should be under Scala-mode. And you can then
M-x eglot
to start metals automatically. -
If you want to use Ammonite as REPL, I have a script:
import os._
import ammonite.*
object AmmMain {
def main(args: Array[String]): Unit = {
ammonite.Main().run()
}
}
Then you can use SBT to run the main function AmmMain to enter Ammonite REPL.
Note that the latest Ammonite supports Scala 3.5.1, here is how I add it in my build.sbt
libbraryDependencies += "com.lihaoyi" % "ammonite" % "3.0.0" cross CrossVersion.full
Hope you can use metals successfully in your Emacs. Previously, before metals, I used ENSIME a lot. and it just worked and was really great! I am a big fan of ENSIME. But once it was archived, I tried to use it but failed lots of times. So now I use metals, which is also an amazing tool.
Thanks. I’ll give it a try.
vscode