Skip to main content

Metals v1.2.0 - Bismuth

· 14 min read

We're happy to announce the release of Metals v1.2.0, which continues to improve reporting mechanisms and reached full feature parity between Scala 2 and 3. This means that most new releases will focus on stability instead of adding new features, unless those features contribute to making Metals more reliable.

Commits since last release149
Merged PRs115
Contributors14
Closed issues41
New features5

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

Use presentation compiler for synthetic decorations

Up until this release Metals would use the semanticdb information for displaying synthetic decorations such as inferred types or implicit conversions. This was not ideal as it meant that the information was not always up to date and could be inconsistent with the current state of code.

synthetics

To fix that jkciesluk switched to using the presentation compiler for this information. This means that each time code changes the decorations will be refreshed. This also added a number of new decorations that were not previously available for Scala 3 and it will be on par with the Scala 2 ones.

This also makes the decorations show proper names in case of name conflicts. So for example if you have two classes with the same name within a single scope, they will have a proper prefix shown to help differentiate it.

Base Metals view on indexing information

Metals tree view enables users to navigate their workspace in a more structured way by directly showing the build modules and their packages, classes, objects etc. It would also allow users to navigate their dependency jars. Previously, this was based on special Scala 2 signature information, which means it wouldn't work in Scala 3.

From this release we changed it to use the same information that is used for indexing in case of jars and semanticdb for local workspace files. This means that Scala 3 is fully supported and this has been the last big feature missing for full parity between Scala 2 and 3.

tree-view

All the existing features should now work for Scala 3 as well. This includes the reveal command which allows to quickly reveal the current file in the tree view including inside jars.

tree-view-reveal Additionally, we improved icons used by the tree view. They will now use the default VS Code icons for the most part, which should make them more consistent with the rest of the editor.

Go to definition for scaladoc

When writing scaladoc for your methods or classes you can use links, which are of a form [[name.name.ClassName]]. Thanks to kasiaMarek Metals will now allow you to navigate to the target of the link via normal go to definition.

scaladoc-def

To learn more about linking in scaladoc check out the Scala documentation

Custom project root setting

Metals currently will try to find the proper build tool root for your project, which is useful especially if you open a parent directory that doesn't contain a build tool configuration. However, this can be problematic if you have a less traditional setup and you need to be able to control the root directory. For example if you have an sbt source dependency and you still want to have that dependency open in the same window.

To help with that we added a new setting metals.customProjectRoot that allows you to specify the root directory for your project. This setting is available in the settings UI and can be set to a path relative to the workspace root.

custom-root

Another amazing feature from kasiaMarek

Bsp errors in status

In the previous release Metals started showing more errors from the build server with the intention on making it clearer to the user what is going on. However, showing a message request for the user could be quite invasive and not always relevant.

To help with that kasiaMarek added a new status bar item that will show the number of errors in the build server. This will be shown only if there are any errors and will be hidden once the reports connected to them are removed.

bsp-status

Add back unintentionally removed support for 2.11.x

For the most of the releases Scala 2.11.12 support was not being actively tested, which led to some of the features not working properly. This release brings back the support for 2.11.12 and adds a CI job to make sure it is working properly. The support is still on the best effort basis, so we highly recommend to migrate to newer versions of Scala, which feature numerous bugfixes and security fixes.

It's highly possible that we will stop supporting new features for 2.11.x in the near future, but it seems for the time being there is still a number of contributors that require it.

Changes for plugin authors

Tree view icons changed and use a number of default VS Code ones. If previously icons were show in other editors, this change could cause them to stop being shown properly. Full list of icon names can be found here.

Another change is the addition of the custom project root setting metals.customProjectRoot, which should be accounted for in the user facing editor interface.

Contributors

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

$ git shortlog -sn --no-merges v1.1.0..v1.2.0
43 Tomasz Godzik
30 Jakub Ciesluk
29 Katarzyna Marek
26 Scalameta Bot
7 Jędrzej Rochala
3 dependabot[bot]
2 Chris Kipp
2 Karan Ahlawat
2 Lucas Nouguier
1 Arthur McGibbon
1 Jamie Thompson
1 Lorenzo Gabriele
1 Seth Tisue
1 naferx

Miscellaneous

This Metals version includes a large number of fixes and improvements and a lot of them could improve your experience significantly. We highly recommend looking at the list below to see what changed. Please remember that you can always reach out to us and we will will try to fix any issues you might have.

  • improvement: Only re-index workspace on onBuildTargetChanged instead of reconnecting. tgodzik
  • [Scala 2] bugfix: Remove custom metals types that could break more complicated completions. tgodzik
  • bugfix: Don't show semanticdb warning when using Mill BSP. lolgab
  • bugfix: Add multiline comment completion. kasiaMarek
  • bugfix: Choose correct workspace folder for jars and build target files. kasiaMarek
  • bugfix: Fix SymbolNotFound regex used for suggesting import symbol code action. KaranAhlawat
  • improvement: show correct bsp status for focused workspace folder. kasiaMarek
  • [Scala 2] bugfix: workaround for printing Tuple1 kasiaMarek
  • bugfix: Use platform Java from BSP instead of default used by metals tgodzik
  • improvement: recompile focused file if depends on last compiled build target kasiaMarek
  • bugfix: Properly backtick named arguments if needed. jkciesluk
  • bugfix: report compile progress when using sbt BSP. bishabosha
  • bugfix: Fix document highlight on named arguments jkciesluk
  • improvement: Try to use Scala CLI's scalafmt config if it exists. tgodzik
  • [Scala 3] improvement: Completions should prepend instead of replace to match Scala 2 behaviour. rochala
  • bugfix: Properly show case completions for tuple type. jkciesluk
  • [SCala 3] bugfix: Rename end marker for local definitions. kasiaMarek
  • [Scala 3] bugfix: Completions for named args in wrong order jkciesluk
  • bugfix: Add output classes directory to classpath for PC to help with Mill BSP issues. jkciesluk
  • bugfix: Show build target information for mill-build. #5816 (jkciesluk)
  • improvement: Forward debug errors properly to the user editor. tgodzik
  • improvement: Color vals of module type as classes jkciesluk
  • [Scala 2] bugfix: Fix document highlight on anonymous function parameters in #5876 (jkciesluk)
  • [Scala 2] bugfix: hover for select chains ending with function kasiaMarek
  • bugfix: Adjust auto import position for shebang jkciesluk
  • [Scala 2] bugfix: Fix inconsistent highlight on class constructor jkciesluk
  • improvement: add semantic tokens for escape sequences kasiaMarek
  • [Scala 3] Extract member action for opaque type kasiaMarek
  • bugfix: Fix go to definition for extension methods in the same scope kasiaMarek
  • bugfix: Don't add import for extension if there is a same named value in scope jkciesluk

Merged PRs

v1.2.0 (2023-12-11)

Full Changelog

Merged pull requests: