Skip to main content

Metals v1.4.0 - Palladium

· 13 min read

We're happy to announce the release of Metals v1.4.0, with the main focus on introducing Bloop 2.0.0. Of course, this release also includes many improvements.

Commits since last release205
Merged PRs142
Contributors17
Closed issues54
New features2

For full details: https://github.com/scalameta/metals/milestone/72?closed=1

Metals is a language server for Scala that works with VS Code, Vim, Emacs, Zed, Helix and Sublime Text. Metals is developed at the Scala Center and VirtusLab with the help from contributors from the community.

TL;DR

Check out https://scalameta.org/metals/, and give Metals a try!

Bloop 2

Bloop is the default build server used by both Metals and Scala CLI, with the latter also serving as the default Scala command since Scala 3.5.0. However, for quite some time, Scala CLI was using a separate fork of Bloop, which occasionally led to users running two build servers simultaneously. This was far from ideal in terms of memory consumption. With Bloop 2.0.0, we have discontinued the fork, effectively resolving this issue.

This change also means that all the improvements made by Alexandre Archambault in the separate Bloop fork are now integrated into the main version. One of the most significant enhancements was the switch to Unix domain sockets, which should improve the reliability and speed of connections to the build server.

The above change has however made it necessary for us to adopt JDK 17 as the primary JDK for running Bloop and Metals. You should still be able to compile your code for earlier JDK versions without any issues; this will be handled by metals when you adjust the metals.javaHome setting to the desired Java version. That version is used to run the build tools and build servers, which then will be aware of it In case of Bloop it means that if no -release flag or similar is added, Bloop will add it automatically to make sure the code is compiled correctly on a given JDK version. Similarly, Metals will add that flag to get all the interactive features from the compiler.

The Java version used by Metals itself is managed separately and will be automatically detected or downloaded as needed.

Metals will also attempt to shut down the old Bloop server and you might see a notification about it. It should be perfectly safe to approve that action as the old server will no longer be used by any tool known to us.

Metals allows users to customize the default options for the Bloop build server. However, in most cases, it is best to use the defaults, which will be applied if the metals.bloopJvmOptions setting is missing or set to an empty array.

The new default JVM options for Bloop are as follows:

"metals.bloopJvmOptions" : [
"-Xss4m",
"-XX:MaxInlineLevel=20", // Specific option for faster C2, ignored by GraalVM
"-XX:+UseZGC", // ZGC returns unused memory back to the OS, so Bloop does not occupy so much memory if unused
"-XX:ZUncommitDelay=30",
"-XX:ZCollectionInterval=5",
"-XX:+IgnoreUnrecognizedVMOptions", // Do not fail if an non-standard (-X, -XX) VM option is not recognized.
"-Dbloop.ignore-sig-int=true"
]

If you are having any issues with the build server it might be worth experimenting with those defaults.

We also adjusted Metals default options similarly in VS Code to further minimize the amount of memory used overall.

Detect custom mains

Previously, we would only discover main classes defined in standard ways such as when:

  • using @main annotation for Scala3
  • extending App
  • explicit def main(args: Array[String]): Unit method
  • scripts

However, users might actually want to create more ways of defining them such as through compiler plugins. Turns out this is the same case we previously had with scripts. In this release, we extended that mechanism and any unknown main classes will be show with code lenses at the top of the file the same way as with scripts.

Miscellaneous

  • bugfix: disambiguate workspace completions for vals in Scala 3 kasiaMarek
  • bugfix: correctly handle odd formatting while indexing source jars kasiaMarek
  • improvement: Only compile current target when debugging or using scalafix tgodzik
  • fix: delete test suites for deleted build targets kasiaMarek
  • improvement: clear diagnostics in downstream targets kasiaMarek
  • improvement: Improve heuritics used for fallback symbol search tgodzik
  • bugfix: use semanticdb also for local symbols and when references not supported in PC kasiaMarek
  • bugfix: Add backticks for inferred type when needed tgodzik
  • bugfix: Use default bloop properties if provided empty array tgodzik
  • bugfix: Catch possible syntax errors tgodzik
  • bugfix: Make sure best effort works with verbose tgodzik
  • improvement: Don't allow empty sbtScript setting tgodzik
  • Disable OrganizeImports commands if they are not available wjoel
  • improvement: add coursier repositories instead of overwrite kasiaMarek
  • bugfix: completions for using directive deps in test scope kasiaMarek
  • feature: Add "opaque type" keyword completions tgodzik
  • bugfix: index top level with inner when apply with { } in method kasiaMarek
  • bugfix: Allow -release flag for Scala 3 to get proper completions tgodzik
  • fix: Get correct classpath for running debug using Mill BSP kasiaMarek
  • improvement: Include jvm opts and environment variables when running tests #6753 (masonedmison)
  • bugfix: Check if locally available sbt is actually a file and not a directory tgodzik
  • improvement: Fallback to last successful semantic tokens instead of throwing to avoid VS Code reproting server as unresponsive tgodzik
  • bugfix: Finer grained accessibility check for auto-imports that includes the private with qualifier masonedmison
  • chore: Freeze bloop plugin for versions of sbt lower than 1.5.8 tgodzik
  • bugfix: Make sure Bloop is always properly restarted tgodzik
  • bugfix: Exclude comma if included in symbol range for references tgodzik
  • bugfix: Stop Metals from saving shared JVM indexes with XDG path violation untainsYD
  • chore: Update scalafix to 0.13.0 to include Scala 3 inferred type bjaglin
  • bugfix: Don't hang when checking for cache folders on Windows tgodzik
  • improvement: Limit number of semanticdb files read at the same time to limit possibility of OOM tgodzik
  • improvement: Basic support for new .mill and .mill.scala source files lolgab
  • bugfix: Fix Metals hanging on Windows tgodzik

Contributors

Big thanks to everybody who contributed to this release or reported an issue!

$ git shortlog -sn --no-merges v1.3.5..v1.4.0
82 Tomasz Godzik
52 Scalameta Bot
13 Lorenzo Gabriele
13 kasiaMarek
10 dependabot[bot]
8 tgodzik
6 Mason Edmison
3 Alexandre Archambault
3 Anup Chenthamarakshan
3 Katarzyna Marek
2 Joel Wilsson
2 Kacper Korban
2 Yarosλaβ .
2 nocontribute
2 scarf
1 Brice Jaglin
1 Seth Tisue

Merged PRs

v1.4.0 (2024-10-23)

Full Changelog

Merged pull requests: