Metals extension for Visual Studio Code
The following table shows the status of various features.
Java 8 or 11 provided by OpenJDK or Oracle. Eclipse OpenJ9 is not supported,
please make sure the
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.25.0-RC2, 0.24.0 and 0.24.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
Install the Metals extension from the Marketplace.
Next, open a directory containing a
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.
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
Update the "Sbt Script" setting to use a custom
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
Manually trigger build import
To manually trigger a build import, execute the "Import build" command through
the command palette (
Execute the "Run Doctor" through the command palette to troubleshoot potential configuration problems in your workspace.
Configure Java version
The VS Code plugin uses by default the
If this setting is defined, the VS Code plugin uses the custom path instead of
To globally configure
If you prefer to manually configure Java home through VS Code, run the following command to copy the Java 8 home path.
Custom artifact repositories (Maven or Ivy resolvers)
Use the 'Custom Repositories' setting for the Metals VS Code extension to tell Coursier to try to download Metals artifacts from your private artifact repository.
Metals uses Coursier to download
artifacts from Maven Central. To use Metals behind an HTTP proxy, configure the
Using latest Metals SNAPSHOT
Update the "Server Version" setting to try out the latest pending Metals features.
See https://scalameta.org/metals/docs/editors/vscode.html#using-latest-metals-snapshot to find the latest SNAPSHOT version.
Run the "Reload Window" command after updating the setting for the new version to take effect.
Files and Directories to include in your Gitignore
The Metals server places logs and other files in the
Show document symbols
Run the "Explorer: Focus on Outline View" command to open the symbol outline for the current file in the sidebar.
Run the "Open Symbol in File" command to search for a symbol in the current file without opening the sidebar.
As you type, the symbol outline is also visible at the top of the file.
Enable on type formatting for multiline string formatting
To properly support adding
This needs to be done in settings by checking
Enable formatting on paste for multiline strings
Whenever text is paste into a multiline string with
To enable this feature you need to enable formatting on paste in Visual Studio
Code by checking
Coming from IntelliJ
Install the IntelliJ IDEA Keybindings extension to use default IntelliJ shortcuts with VS Code.