Skip to main content

Metals v1.3.0 - Thallium

· 14 min read

We're happy to announce the release of Metals v1.3.0, which brings several big features and multiple bugfixes. One of the main things to take a look at is the Java home changes, let us know if it caused any issues for you! Another big change is the improved debugger, which is a fruit of a lot of hard work. As always we are striving to improve our stability, so if you notice an issues or any errors popping up in .metals/.reports do let us know!

Commits since last release132
Merged PRs105
Contributors16
Closed issues53
New features8

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

Metals is a language server for Scala that works with VS Code, Vim, Emacs 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!

New Scala versions support

Metals now supports 2.12.19, 2.13.13 and 3.3.3 Scala versions. That support was also back-ported to the previous Metals v1.2.2.

Starting with 3.3.5 version all newer Scala releases will not require specific support in Metals thanks to additional inclusions of presentation compiler module within the compiler.

Java Home improvements

Starting with this version of Metals, JDK used for running Metals and the one used for your project can now be separate. This allows us to simplify setting up JDK for running Metals, which will be automatically downloaded using coursier if not detected on your machine.

This means we have two settings for Java:

  • metals.javaVersion - version of Java to be used for running Metal language server, used within Visual Studio Code. Users can choose from 11, 17 and 21. Java 8 is deprecated and will be dropped with the next release.
  • metals.javaHome - Java used for your project, Metals will try to add all the appropriate flags so that language features are consistent with the version of Java you are using. Will always support JDK 8 and higher.

Automatic imports setting

Thanks to keirlawson it's now possible to make Metals automatically import any workspace. This takes a shape of a new setting metals.autoImportBuild which has three options:

  • off - users will always be asked whether they want to import their workspace either initially or after changes.
  • initial - when users first open a new workspace Metals will automatically import the workspace, but will still ask about reimporting after changes.
  • all - Metals will always automatically import and reimport your workspace. This might make more sense when using other build tools than Bloop as it might take a while to run the import.

Preferred build server setting

Thanks to kasiaMarek it's now possible to default to the BSP server instead of Bloop for all your workspaces using metals.defaultBspToBuildTool setting. This will work with Mill and sbt, which support both.

Inlay hints support

After a huge amount of work by jkciesluk Metals will now use the standard LSP way of showing decorations via Inlay Hints instead of a custom solution. Thanks to this, the decorations behave much more naturally like usual code, you can navigate to definition and get proper hovers. It will also allow all editors to support decorations without implementing the additional extension to the protocol.

inlay-hints

Additionally, together with inlay hints we reworked all the decoration settings to be included in a single object and two new ones were added:

  • metals.inlayHints.typeParameters.enable - when this option is enabled, each place where a type parameter is applied has it displayed either as additional decorations if they are supported by the editor or shown in the hover.
  • metals.inlayHints.hintsInPatternMatch.enable - when this option is enabled, each place when a type is inferred in a pattern match has it displayed either as additional decorations if they are supported by the editor or shown in the hover.

There is a small issue within VS Code, which might be fixed in the future, and it makes it impossible to hover on multiple parts of a particular type consecutively. Users have to move the cursor away from the type and again onto the part of the type they want to learn more about.

Inlay hints will also not work 100% for any older deprecated Scala 2 versions and Scala 3 versions 3.4.0, 3.4.1, 3.3.0, 3.3.1, 3.3.2, 3.3.3. For those versions Metals uses a fallback that translates the older decorations to the new inlay hints, but without go to definition and hover.

Exhaustive matches for union types

Another great new feature done by jkciesluk enables users to get a suggestion that will complete a pattern match with all types within a union type.

union

Debugger improvements

The Scala debugger adapter library, which is responsible for providing debugging experience in Metals, has been released recently under v4.0.0 with a lot of great improvements. These include:

  • Pretty stacktraces (Scala 3 Only) - improved stack trace names that are easier and more useful to read for the users.

pretty

  • Runtime evaluator - allows evaluating Java-like expression in Scala and Java source files without using the compiler. It is faster, it can access private members, and it does not require casting to access members of runtime types.
  • Hot-code replace - The hot-code replace feature allows to change the behavior of a running program. It is now possible to change the body of a method, and to reload it in the debugged program. After the hot-code replacement, any call to the modified method will execute the new implementation, even on former instances of the changed class. This feature is particularly useful to track a bug and fix it in a single debug session.

hot-code

  • Collapse skipped frames - the debugger indicated frames which are not useful for the users, Metals will now collapse them by default.

collapse

This all was done thanks to the hard work of adpi2, iusildra and other contributors.

You can read more on the v4.0.0 release page

Go to implementations for dependency sources

Previously, it was only possible to search for implementations inside dependencies as Metals didn't index type hierarchy. Thanks to kasiaMarek it's now possible to do that in both Scala and Java files with an exception of JDK to avoid additional cost of indexing it in every workspace. The latter will be fixed later on.

implementations

As with inlay hints, this feature will not work when using older deprecated Scala 2 versions and some of the older Scala 3 3.3.x and 3.4.x versions.

Completions for implicit classes

Another feature implemented by kasiaMarek is adding support for completions of old style extension methods that were declared within implicit classes. This will work similar to extensions method completions for Scala 3.

implicit

Plugin author changes

Doctor format version changed to 6 due to the added project Java information.

Miscellaneous

  • bugfix: Fix insert position for auto imports in worksheets in Scala 3 jkciesluk
  • bugfix: Show docs for classes with static members and scala objects tgodzik
  • bugfix: Use text document version for initial package edit kasiaMarek
  • bugfix: Fix restarting Bazel between CLI and Metals tgodzik
  • improvement: Regenerate Bazel files if any are missing tgodzik
  • bugfix: Don't calculate inlay hints with disabled synthetics jkciesluk
  • improvement: Properly show when semanticdb is missing while using Bazel tgodzik
  • improvement: Bump giter8 and make sure it gets updated automatically tgodzik
  • bugfix: Fix document highlight on simple extension method jkciesluk
  • bugfix: Fix parsing of enum in DAP messages adpi2
  • bugfix: Don't show unhelpful renames in hover jkciesluk
  • bugfix: workaround for missing line number in qdox java record fields kasiaMarek
  • bugfix: make symbol search prefer results with scala version of document in focus kasiaMarek
  • improvement: Better inlay Hints for anonymous implicits jkciesluk
  • improvement: Unify connecting to bazelbsp with other build servers jkciesluk
  • bugfix: emit as extension method if member of implicit class with val in constructor kasiaMarek
  • improvement: Check if compiled unit is available before using tgodzik
  • improvement: Remove Bazel specific directories when running full clean tgodzik
  • improvement: Allow running organize imports on scripts tgodzik
  • bugfix: fix worksheets with 3.4.0 kasiaMarek
  • bugfix: Fix issues with bazelmod alongside WORKSPACE tgodzik
  • bugfix: go to implementations for multi-module projects kasiaMarek
  • improvement: Request jvmRunEnvironment lazily tgodzik
  • improvement: Use dependencyModule for resolving sources tgodzik
  • improvement: support "behavior of" syntax in ScalaTest's FlatSpec style piter75
  • bugfix: Don't ask for override completions on null type jkciesluk
  • bugfix: Add additional check for InterpolatorSplice substring jkciesluk
  • bugfix: Case completions in summonFrom jkciesluk
  • fix: take last change in didChange kasiaMarek
  • improvement: Simplify resolving presentation compiler tgodzik
  • improvement: turn off formatting for metals.sbt kasiaMarek
  • improvement: add timeout to worksheet evaluation kasiaMarek
  • improvement: add project's java info to doctor kasiaMarek
  • bugfix: allow for mixed multiple custom and known build servers kasiaMarek
  • improvement: Also start Scala CLI if the focused file was Scala and no build tool is available. tgodzik
  • bugfix: CompletionPosition inferStart should not crash jkciesluk
  • fix: check that implicit method owner is static in completions kasiaMarek
  • bugfix: Incorrect position in import missing symbol jkciesluk
  • bugfix: Arg completions on null symbol in Scala 2 jkciesluk
  • bugfix: Incorrect inlay hints inside quotes jkciesluk
  • improvement: Expand Selection in comments for Scala 2 doofin
  • bugfix: deduplicate auto connect for scala-cli kasiaMarek
  • fix: don't remove package when target outside of root kasiaMarek

Contributors

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

$ git shortlog -sn --no-merges v1.2.2..v1.3.0
33 Jakub Ciesluk
31 Tomasz Godzik
26 Katarzyna Marek
8 Keir Lawson
5 Scalameta Bot
4 scalameta-bot
4 tgodzik
3 Adrien Piquerez
3 dependabot[bot]
2 Lucas Nouguier
2 adpi2
1 Alex Boisvert
1 Chris Kipp
1 Jędrzej Rochala
1 Piotr Szczepanik
1 eason du

Merged PRs

v1.3.0 (2024-04-15)

Full Changelog

Merged pull requests: