Metals works with Atom thanks to the
Java 8 or 11 provided by OpenJDK or Oracle. Eclipse OpenJ9 is not
supported, please make sure the
JAVA_HOME environment variable
points to a valid Java 8 or 11 installation.
macOS, Linux or Windows. Metals is developed on macOS and every PR is tested on Ubuntu+Windows.
Scala 2.13, 2.12, 2.11 and Scala 3. Metals supports these Scala versions 2.13.3, 2.12.12, 2.12.11, 2.12.10, 2.13.1, 2.13.2, 2.11.12, 2.12.8, 2.12.9, 2.13.0, 0.26.0, 0.27.0-RC1, 0.25.0 and 0.26.0-RC1. Note that 2.11.x support is deprecated and it will be removed in future releases. It's recommended to upgrade to Scala 2.12 or Scala 2.13
Installing the packages
Once the requirements are satisfied, we can now proceed to install the following packages:
ide-scala: Protocol client to communicate with Metals. Install the package by searching for "ide-scala" or run the following command.
apm install ide-scala
language-scala: for syntax highlighting Scala and sbt source files.
Importing a build
The first time you open Metals in a new workspace it prompts you to import the build. Click "Import build" to start the installation step.
- "Not now" disables this prompt for 2 minutes.
- "Don't show again" disables this prompt forever, use
rm -rf .metals/to re-enable the prompt.
tail -f .metals/metals.logto watch the build import progress.
- Behind the scenes, Metals uses Bloop to import sbt builds, but you don't need Bloop installed on your machine to run this step.
Once the import step completes, compilation starts for your open
Once the sources have compiled successfully, you can navigate the codebase with goto definition.
Custom sbt launcher
By default, Metals runs an embedded
sbt-launch.jar launcher that respects
However, the environment variables
JAVA_OPTS are not respected.
Update the server property
-Dmetals.sbt-script=/path/to/sbt to use a custom
sbt script instead of the default Metals launcher if you need further
customizations like reading environment variables.
Speeding up import
The "Import build" step can take a long time, especially the first time you run it in a new build. The exact time depends on the complexity of the build and if library dependencies need to be downloaded. For example, this step can take everything from 10 seconds in small cached builds up to 10-15 minutes in large uncached builds.
Consult the Bloop documentation to learn how to speed up build import.
When you change
build.sbt or sources under
project/, you will be prompted to
re-import the build.
Manually trigger build import
To manually trigger a build import, execute the "Import build" command through
the command palette (
Cmd + Shift + P).
Execute the "Run Doctor" through the command palette to troubleshoot potential configuration problems in your workspace.
Using latest Metals SNAPSHOT
Update the "Metals version" setting to try out the latest pending Metals features.
|0.9.4||21 Sep 2020 15:38|
|0.9.4+20-2589a6bd-SNAPSHOT||28 Sep 2020 09:56|
Files and Directories to include in your Gitignore
The Metals server places logs and other files in the
.metals directory. The
Bloop compile server places logs and compilation artifacts in the
directory. The Bloop plugin that generates Bloop configuration is added in the
metals.sbt file, which is added at
project/metals.sbt as well as further
project directories depending on how deep
*.sbt files need to be supported.
To support each
*.sbt file Metals needs to create an additional file at
./project/project/metals.sbt relative to the sbt file.
Working with Ammonite scripts will place compiled scripts into the
It's recommended to exclude these directories and files
from version control systems like git.
# ~/.gitignore .metals/ .bloop/ .ammonite/ metals.sbt
Worksheets are a great way to explore an api, try out an idea, or code up an example and quickly see the evaluated expression or result. Behind the scenes worksheets are powered by the great work done in mdoc.
Getting started with Worksheets
To get started with a worksheet you can either use the
command and select Worksheet or create a file called
This format is important since this is what tells Metals that it's meant to be
treated as a worksheet and not just a Scala script. Where you create the
script also matters. If you'd like to use classes and values from your
project, you need to make sure the worksheet is created inside of your
directory. You can still create a worksheet in other places, but you will
only have access to the standard library and your dependencies.
After saving you'll see the result of the expression as a comment as the end of the line. You may not see the full result for example if it's too long, so you are also able to hover on the comment to expand.
Keep in mind that you don't need to wrap your code in an
object. In worksheets
everything can be evaluated at the top level.
Using dependencies in worksheets
You are able to include an external dependency in your worksheet by including it in one of the following two ways.
// $dep.`organisation`::artifact:version` style import $dep.`com.lihaoyi::scalatags:0.7.0` // $ivy.`organisation::artifact:version` style import $ivy.`com.lihaoyi::scalatags:0.7.0`
:: is the same as %% in sbt, which will append the current Scala binary version to the artifact name.