Skip to main content

Metals v0.11.10 - Aluminium

· 20 min read

We're happy to announce the release of Metals v0.11.10, which brings in a lot of new contributions with exciting features as well as stability improvements, which will become the primary focus over the next releases.

Commits since last release249
Merged PRs195
Contributors21
Closed issues83
New features8

For full details: https://github.com/scalameta/metals/milestone/54?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 Lunatech along with contributors from the community.

TL;DR

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

Converting sbt style to mill style dependencies

Thanks to LaurenceWarne there is a new code action that allows users to automatically convert sbt style defined dependencies to Mill ones whenever pasting in scripts or mill files.

For example if we have an incorrect build.sc file:

object MyModule extends ScalaModule {
def ivyDeps = Agg(
"org.scalameta" %% "metals" % "1.0"
)
}

Metals will now suggest to convert the incorrect line with the dependency to a correct one when hovering or moving the cursor to its location. Afterwards to code will turn to:

object MyModule extends ScalaModule {
def ivyDeps = Agg(
ivy"org.scalameta::metals:1.0"
)
}

Similarly, it will also help with ammonite scripts and turn:

import $ivy."org.scalameta" %% "metals" % "1.0""

into:

import $ivy.`org.scalameta::metals:1.0`

Additional completions for dependencies

In the previous version of Metals additional library dependency suggestions were added in Ammonite scripts and worksheets. This version expands the number of places where you can use this feature:

  • Scala CLI scripts and files when writing //> using lib ...
  • When writing ivy"dependency..." in build.sc file
  • Inside sbt files when adding dependencies.

This feature allows you to explore the available libraries and their versions without leaving the comforts of your editor.

Thanks jkciesluk and LaurenceWarne for all the great work!

Actionable diagnostics for scala-cli

Actionable diagnostics is a new idea within the Scala tooling ecosystem that focuses on providing users with a potential fix for any errors or warnings that may show up. This reduces the amount of time users will spend on fixing their code and helps them be more productive in daily development.

The first experiment within that area was done by lwronski in Scala CLI. When using the newest Scala CLI you will see a warning whenever a library has a newer version available and you'll have a quick fix suggested via code action.

actionable These warnings can be disabled within ScalaCLi using:

scala-cli config actions false

NOTE: that if you do this, you'll turn off actionable diagnostics from scala-cli globally until this command is ran again with true.

There is ongoing work on adding more actionable diagnostics in the Scala 3 compiler as well, so look forward to more features like this in the future!

Expose Test Cases as Separate Lenses

Up until the current release it was only possible to run a single test case within Visual Studio Code and nvim-metals which use an additional Test Explorer that is not available for all the editors. However, thanks to (LaurenceWarne) Metals will now show lenses to run a single test case in case of all other editors.

NOTE: While Metals detects test suites for most of existing testing frameworks, support for recognizing individual tests is more limited. Metals supports the current set of test frameworks when it comes to individual test discovery:

  • Junit
  • MUnit
  • Scalatest

More details can be found in the PR #4569.

Add support for goto type definition

Users were able for a long time to navigate to the definition of a particular symbol, which can be a method, object, class etc. After that they could sometimes also find the definition of the type of that symbol. However, it's not always easy and convenient to do that. From now on Metals also allows users to use the go to type definition feature within all the supported editors. User will be able to go directly to the type of a particular symbol.

type-def

This feature might work a bit differently depending on the symbol you are checking:

  • for methods it will show the location of the return type
  • for any values, vars or parameters it will show the type of that symbol
  • for classes, object or types it will only find that particular type, which will work the same as go to definition

Run main classes in terminal when using code lenses

There are two ways of running main classes within Metals. You can decide to run them with or without debugging with the latter stopping at the breakpoints. These two types would both use the debug server with the first one just ignoring breakpoints. However, setting up the whole infrastructure for debugging, when users just want to run a main method, is adding a lot of unnecessary burden and takes longer than if you just run it within your terminal.

In this version we introduce the change to include information about the exact Java command to run within the code lenses, that can be used by the editors. It currently works with VS Code and it will run main classes within the task terminal.

run-main

In next release, we also plan to use the same mechanism for running main classes from all the other places. We also want to make tests runnable without the debugging infrastructure, but it's a bit more complicated than for main methods.

Allow rename for local names for non compiled code

Previously, whenever you wanted to rename anything, Metals would need to compile your entire workspace. The reason for that was twofold. First we needed the data from the compilation and second we wanted to make sure that will not break your code. This however is not needed for anything that is defined in a local scope, which can't be used outside the current file.

Metals will now allow users to rename any local code irrelevant of whether the workspace was compiled or not.

rename-local

When renaming symbols that might be use outside the current file the previous limitations will apply.

Enable run and debug in Scala CLI scripts in Metals

Thanks to lwronski it's now possible to run and debug scripts when using Scala CLI.

script-debug

For running scripts without debugging we will also provide the possibility of using the explicit Java command to run from code lenses.

Refactor package definition when moving files between packages

One of the more requested features was the ability to automatically rename packages when moving files, which helps reduce the burden of reorganizing the code. Thanks to some amazing works from susliko this is now possible and should tackle most of the possible situations.

The feature will rename both the current package name as well as all the references to it in other files.

You can see some great examples of it in the #4655 PR that introduced the feature.

Scala debugger improvements

Metals v0.11.10 ships a new major version of the Scala Debug Adapter, featuring better debugging steps (step filter), conditional breakpoints, logpoints and more. See a full list of features in the release notes of the Scala Debug Adapter 3.0.1 and 3.0.3.

Miscellaneous

  • bugfix: Clean diagnostics after importing a script
  • bugfix: Properly show hover even if decoration spans multiple lines
  • chore: Support for Scala versions 2.13.10, 3.2.1.
  • bugfix: Don't backtick Scala 3 soft keywords in imports. susliko
  • bugfix: Highlight transparent inline usages correctly.
  • bugfix: Don't show case completions if already in case body. jkciesluk
  • improvement: Sort versions in reverse for coursier completions. LaurenceWarne
  • bugfix: [Scala 3] Properly index top level extension method to allow navigation and completions.
  • bugfix: Don't show type parameter in outgoing calls. riiswa
  • bugfix: Prepend package in case of conflicts in match case completions. dos65
  • bugfix: Fix exhaustive match completion when using TypeA with TypeB to not show TypeA or TypeB as possible cases. jciesluk
  • bugfix: Also rename companion when renaming renamed import.
  • feat: capture and forward diagnosticCode. ckipp01
  • bugfix: Fix go to in external classes in jars with special chars. narma
  • bugfix: add special case for auto import inside already existing to add the needed prefix inline. dos65
  • bugfix: Fix detecting companions for classes defined directly in method for document highlight and rename.
  • bugfix: exhaustive match when using renamed symbol. jkciesluk
  • bugfix: Retry starting Ammonite when the script file changed and was fixed.
  • bugfix: Properly highlight package object name.
  • bugfix: Properly highlight named arguments in case class constructors. jkciesluk
  • fix: automatically import companion object instead of apply method. jkciesluk
  • feature: Add showing semanticdb for sbt files and worksheets. jkciesluk
  • bugfix: Correctly display statuses for Ammonite scripts in Doctor.
  • bugfix: Don't show string code actions when they are enclosed within selected range.
  • bugfix: [Scala 3] Allow to automatically complete already overridden symbols. jkciesluk
  • bugfix: [Scala 3] Make implementAll work properly with type aliases and higher. kind typejkciesluk
  • bugfix: [Scala 3] use braces for match completion with -no-indent option. jkciesluk
  • bugfix: Take into account the length of interpolator for code actions related. to string interpolation.
  • bugfix: Make multistage Mill scripts work.
  • bugfix: implement methods with path-dependent type arguments.
  • bugfix: Properly reindex build after reloading sbt.
  • bugfix: Recommend newer RC Scala versions when project is using a RC rkrzewski
  • chore: Try and print all dependencies used by Metals.
  • bugfix: [Scala 3] Fix highlight for extension methods. jkciesluk
  • improvement: Improve behaviour of Initial ivy Completions when backticks are not added. LaurenceWarne
  • bugfix: Call hierarchy incoming calls includes also incoming calls of super. methods kasiaMarek
  • feature: Show @main lenses with scala cli scripts. LaurenceWarne
  • bugfix: Don't encode paths on Windows to fix issues with dependencies in directories with non alphanumeric characters.
  • bugfix: Fix document highlighting mechanism for Java files. MaciejG604
  • improvement: Better folding of definitions and overall improvements to folded regions. MaciejG604
  • bugfix: stop watching generated files to avoid compilation loop. adpi2

Contributors

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

$ git shortlog -sn --no-merges v0.11.9..v0.11.10
67 Tomasz Godzik
51 scalameta-bot
40 Jakub Ciesluk
15 Laurence Warne
15 Chris Kipp
6 Adrien Piquerez
5 kmarek
4 Łukasz Wroński
4 Kamil Podsiadlo
3 Maciej Gajek
3 Vadim Chelyshov
2 Sergey Rublev
2 Shardul Chiplunkar
2 Waris Radji
2 dependabot[bot]
2 susliko
1 Eugene Bulavin
1 Rafał Krzewski
1 Seth Tisue
1 Vasiliy Morkovkin
1 mattkohl-flex

Merged PRs

v0.11.10 (2023-01-02)

Full Changelog

Merged pull requests: