Skip to main content

Metals v1.6.3 - Osmium

· 20 min read

We're happy to announce the release of Metals v1.6.3, which brings a number of improvements as well as interesting new features. This release has seen a lot of contributions from the community and we would like to thank everyone who helped with this release!

Commits since last release127
Merged PRs127
Contributors18
Closed issues33
New features8

For full details: https://github.com/scalameta/metals/milestone/82?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!

MCP: Scalafix rule generation

Metals now provides a new Model Context Protocol tool for generating Scalafix rules within the MCP server. This can be used to run refactorings generated by LLMs on your codebase.

Most of the work around publishing and running Scalafix rules is done by Metals itself, while the LLM is only responsible for generating the rule implementation and description.

This works best on smaller codebases, but can later be published and used in larger ones.

Each rule generated by the MCP server will be saved in the .metals/rules directory and is a self-contained Scala CLI project.

An example query that can be used and has been tested with is:

Using MCP, generate a scalafix rule that will change expressions with filter and map
such as `.filter(x => x > 1).map(x => x * 2)` into collect statements like `.collect{case x if x > 1 => x * 2}`

When used with Claude Code or Cursor (or your MCP-supporting LLM tool of choice), this will generate a finished rule in a few tries at a maximum.

The new tool is still experimental and there might be some rough edges, but we're happy to hear your feedback and suggestions! Some possible errors might involve not validating the inputs from the LLM properly or not returning an actionable enough error message.

Once generated, the rule can be run also using the metals.scalafix-run-only command in the same workspace or published from the rule directory if not already published when generating the rule.

Commands: Add a "copy fqn" command

Thanks to KacperFKorban we now have a new command that allows to copy the fully qualified name of a symbol to be used in places such as Scaladoc comments.

For example, if you have the following code:

package com.example
object Main {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}

You can copy the fully qualified name of the main method to obtain com.example.Main#main.

This command should be available in all editors that support 'workspace/executeCommand' LSP endpoint.

In Visual Studio Code, you can bind this command to a shortcut or invoke it from the dropdown menu with your cursor on the symbol and select Copy reference.

Inlay hints: Add closing labels

Another great feature added by KacperFKorban is the support for showing closing labels in inlay hints.

When this setting is enabled, each method/class/object definition that uses braces syntax will get a closing label hint next to the closing brace with the name of the definition.

For example:

object Main {
def main(args: Array[String]): Unit = {
println("Hello, world!")
} /*main*/
} /*Main*/

Where /*main*/ and /*Main*/ are the closing labels.

This can be enabled by setting the metals.inlayHints.closingLabels.enable setting.

The feature is currently available only for Scala 2, we are planning to add support for Scala 3 in the near future.

Let us know what you think!

Refactoring: Automatically add imports when copying between files

In this release, thanks to kasiaMarek there is a new paste command that allows to automatically add imports when copying between files. This command is enabled by default in Scala files within VS Code and requires the origin to be filed when adding in other editors.

paste-import

The change will currently only work for Scala 2, some further work is needed to add support for Scala 3.

Testing: Add cursor-based target discovery for running closest main or test

Another new code action, added by warcholjakub, is one that allows to run the closest main or test to the cursor.

This new command is available in Visual Studio Code via metals.run-closest in the command palette and can be assigned to a new shortcut.

run-closest

Testing: Test discovery for Bazel

Up until this release, discovering tests in your Bazel workspace was not supported. This was because Bazel BSP server itself doesn't provide any information about test suites as other build tools and servers are able to.

Metals will now use semanticdb to discover test suites and test cases for Bazel only. This means you need to have semanticdb enabled in your Bazel workspace for this to work.

Thanks to pielas for his great work!

Code actions: Convert infix to normal apply

Thanks to yoosefi12 we now have a new code action that allows to convert infix apply to normal apply.

This means that whenever you see an infix apply such as:

mystring startsWith "hello"

you can convert it to a normal apply by choosing the correct code action.

mystring.startsWith("hello")

This doesn't apply to infix apply that are symbolic operators, such as '+', '*', etc. which are expected to be infix.

Code actions: Implement Convert to collect code action

Another new code action added is one that allows to convert filter and map chains into collect statements.

For example with the following code:

List(1, 2, 3, 4).filter(x => x > 2).map(x => x * 2)

you can convert it to a collect statement by invoking the code action.

List(1, 2, 3, 4).collect {
case x if x > 2 => x * 2
}

Thanks to scarf005 for working on this!

Contributors

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

$ git shortlog -sn --no-merges v1.6.2..v1.6.3
54 Tomasz Godzik
43 scalameta-bot
6 Jakub Warchoł
5 Mateusz Piękos
2 Alec Theriault
2 Kacper Korban
2 Zieliński Patryk
2 dependabot[bot]
2 ormaniec
1 Alexandre Archambault
1 Ali Yoosefi
1 Connor Taffe
1 Jędrzej Rochala
1 Konrad Gądek
1 Matt Bovel
1 Panov Ivan
1 eugene yokota
1 scarf

Merged PRs

v1.6.3 (2025-10-16)

Full Changelog

Merged pull requests: