Metals – Scala language server with rich IDE features

Virtuslab in cooperation with Scala Center and the Scala community is working on a unique open source solution – Metals. It’s a Language Server Protocol (LSP) implementation that enables users of many different text editors to enjoy rich IDE features.

metals_cover-min_
Scope
Tooling
Technology
Scala
Virtuslab in cooperation with Scala Center and the Scala community is working on a unique open-source solution – Metals. It’s a Language Server Protocol (LSP) implementation that enables users of many different text editors to enjoy rich IDE features.

Contributing to open source

In 2019 VirtusLab joined Scala Center as the first contributor member, which means one of the company’s developers would dedicate their time to working on Scala open source. It was the obvious next step as we love and support the Scala programming language and already have a very proficient tooling division. #VLteam does its best to contribute to open source projects and enhance software that is used by developers around the world.

The idea

We were asked to help out with one of the newer developer solutions worked on in the Scala Center – the Metals language server. It was obvious that an LSP server was needed for the language to stay relevant and reach more users, who might either not know Intellij or not like to use it. Such technology also paves the way for easier online workspaces or using alternatives editors such as Vim or Emacs.

The solution

Metals is a language server for Scala that works with VS Code, Vim, Emacs, Sublime Text, Atom, Eclipse, as well as any other Language Server Protocol compatible text editor. It turns them into powerful but still fast and lightweight IDEs. Metals also works out of the box with such build tools as Sbt, Gradle, Maven and Mill. It’s also possible to use any build tool with support for Bloop like Fury or Seed. The LSP protocol itself works by decoupling the graphical client, which knows how to present information to the user, from a specific language knowledge, which is provided by a separate LSP server, by communicating via a strictly specified protocol. This greatly simplifies the development of any particular language compared to all previous solutions, which highly coupled the language semantics with its presentation.

image for article: Metals – Scala language server with rich IDE features

Technologies in Metals

There is a number of interesting technologies used in Metals, some of which are:

  • LSP protocol itself implemented by the Eclipse Foundation
  • Scalameta tooling ecosystem including SemanticDB, which is able to provide comprehensive information about the code, and an independent Scala parser, which works without starting the compiler
  • Bloop, which is a build server allowing multiple Metals server to use it in order to compile user’s code.

VirtusLab’s contribution to Metals

We worked on many features and bug fixes since we joined the project. VirtusLab (thanks to the work of Tomek Godzik, Marek Żarnowski and Krzysiek Bochenek) quickly became the most active maintainer of the project.

Here are some features we delivered:

  • Automatically import workspaces using Gradle, Maven and Mill, which enables the same LSP experience for users of those build tools.
  • Rename symbols within the user’s code, which enables easy refactors within all editors.
  • Find implementations of any class or its methods within the workspace.
  • Adapt the Debug Adapter protocol to enable running applications or tests within editors supporting this solution.
  • Support workspaces written with Scala 3 to improve developer’s experience over the existing Dotty language server.
  • Provide an option to fold any continuous part of code.
  • Highlight all identical names within a single document.

 

image for article: Metals – Scala language server with rich IDE features

Metals at VirtusLab

The team working on Metals is one of the VL’s tooling teams delivering solutions for boosting devs’ efficiency. The project is still ongoing. Metals has a constantly growing base of satisfied users and gets more and more features. Now it’s the 2nd most widely used IDE for Scala.

Based on the number of downloads, we can estimate that we currently have about 10k active users, a number which is increasing since we started working with Metals. I think VirtusLab really contributes to improving this solution!
image Tomasz Godzik Software Engineer at VirtusLab | One of the main Metals maintainers

Highly expertized in tooling

Since 2010 VirtusLab’s teams have been working with many clients from various industries. We optimize the software development process and apply innovative dev tooling solutions to help companies’ developers focus on their business domain and save time. Our work resulted also in many, other than Metals, open-source contributions, including Scala compiler itself, IntelliJ or Scala IDE. For sure, VL teams like challenges. If you want to collaborate with us, do not hesitate – we’ll definitely handle your project too!

Work with the strongest team out there!