Skip to main content

Metals v0.5.0 - Mercury

· 7 min read

We are excited to announce the release of Metals v0.5, codename "Mercury" 🎉 This release introduces new features, performance improvements and bug fixes with highlights including:

  • code completions
  • parameter hints
  • show type at point
  • code folding
  • document highlight

Metals is a language server for Scala that works with VS Code, Atom, Vim, Sublime Text and Emacs. Metals is developed at the Scala Center along with contributors from the community.

In this milestone we merged 76 PRs and closed 26 issues, full details: https://github.com/scalameta/metals/milestone/4?closed=1.

Code completions​

It's now possible to use code completions to explore APIs, implement interfaces, generate exhaustive pattern matches and more.

2019-04-12 14 19 39

  • Auto-import: symbols that are not in scope are automatically imported locally. Imports still need to be organized manually, we are exploring ways to automate this workflow in the future.
  • Override def: implement methods from the super class.
  • Exhaustive match: generate an exhaustive pattern match for sealed types.
  • String interpolator: automatically convert string literals into string interpolators.
  • Filename: complete classnames based on the enclosing file.
  • Documentation: read the docstring for method symbols by pressing ctrl+space in VS Code.

Hover (aka. type at point)​

It's now possible to see the expression type and symbol signature under the cursor.

  • Expression type: shows the non-generic type of the highlighted expression.
  • Symbol signature: shows the generic signature of symbol under the cursor along with its docstring, if available.

Signature help (aka. parameter hints)​

It's now possible to view a method signature and overloads as you fill in arguments.

Code folding​

It's now possible to fold ranges such as large expressions, import groups and comments.

Big thanks to @marek1840 for contributing this feature!

Document highlight​

It's now possible to highlight references to the same symbol in the open file.

Big thanks to @tgodzik for contributing this feature!

Previously, fuzzy symbol search (workspace/symbol in LSP) always returned results from both the workspace and library dependencies. Now, fuzzy symbol search returns only results from the workspace unless the query contains a semicolon character ;. For example:

  • query "Future": workspace only, with fallback to library dependencies if workspace contains 0 results
  • queries "Future;" or ";Future" or "Fut;ure": workspace + library dependencies.

This change improves the quality for the search results since most often you want to navigate to symbols defined in the workspace. A nice side-effect is that workspace-only searches are faster because we avoid redundant work by not looking at library dependencies.

In addition, this release introduces a new in-memory index for workspace-only symbol queries resulting in even better performance compared to the last release.

Goto definition for in-memory edits​

Previously, goto definition worked only for identifiers that had been saved and successfully compiled in the build tool. Now, you can use goto definition for symbols that you just typed even if the source file hasn't been saved or contains type errors.

Standalone Scala files outside a build tool​

Previously, semantic features like goto definition worked only for sources that belong to a build project. Now, Metals provides completions, parameter hints, hover and definition for local symbols in standalone Scala files. The classpath for standalone Scala files includes the JDK and the Scala standard library so features like completion will not understand symbols from external library dependencies.

Known limitation: only syntax errors are published for standalone Scala files, the file must belong to a build in order to see type errors.

New collaboration with VirtusLab​

As part of a new collaboration between VirtusLab and the Scala Center, Marek Żarnowski (@marek1840) and Tomasz Godzik (@tgodzik) will be contributing to Metals development for the coming months. They have already contributed several impressive pull requests:

  • textDocument/foldingRange (#632): code folding that understands Scala syntax.
  • textDocument/documentHighlight (#621): highlight occurrences of a symbol in the current file.
  • textDocument/completion (#640): override def completions from without the need to type "override def ".

It is our pleasure to welcome them to the team and we look forward to working together with them to improve the Scala editing experience :)

Contributors​

Big thanks to everybody who contributed to this release! In particular, big thanks to @jvican and @gabro for invaluable feedback both online and offline.

$ git shortlog -sn --no-merges v0.4.4..v0.5.0
Ólafur Páll Geirsson
Marek Żarnowski
Johan Muedsam
JesusMtnez
Tomasz Godzik
Tim Nieradzik
Ayoub Benali
Eric Peters
Alexey Alekhin
keiSunagawa

Merged PRs​

  • Implement goto definition fallback with the presentation compiler. #645 (olafurpg)
  • Generate exhaustive pattern match for sealed types. #643 (olafurpg)
  • Improve quality and performance of workspace/symbol, fixes #639. #642 (olafurpg)
  • Enable workspace query to match package object #641 (mudsam)
  • Make completions work on overr<COMPLETE> and def<COMPLETE> #640 (tgodzik)
  • Give CompletionPosition finer control over sorting, fixes #619. #638 (olafurpg)
  • Several UX improvements #637 (olafurpg)
  • Use fallback presentation compiler for missing build target. #634 (olafurpg)
  • Fix six bugs #633 (olafurpg)
  • Implement textDocument/foldingRange #632 (marek1840)
  • Provide fuzzier type member matching and more polished sorting. #629 (olafurpg)
  • Sort symbols defined in the current file to the top, fixes #618. #628 (olafurpg)
  • Render @see as links. Improve inline link handling and update test cases. #627 (mudsam)
  • Disable macro-paradise compiler plugin, fixes #622. #625 (olafurpg)
  • Improve completion snippets, fixes #610. #623 (olafurpg)
  • Implement textDocument/documentHighlight #621 (tgodzik)
  • Handle exceptions when computing completion position. #616 (olafurpg)
  • Don't eagerly load presentation compiler during tests. #614 (olafurpg)
  • Eagerly load presentation compiler for open buffers. #605 (olafurpg)
  • Eagerly load Scalafmt during initialized #604 (olafurpg)
  • Complete filename when defining toplevel class/trait/object #603 (olafurpg)
  • Remove signature help fallback in hover. #602 (olafurpg)
  • Fix #599, don't insert import above generated parameter accessors #600 (olafurpg)
  • Several small fixes #597 (olafurpg)
  • Support navigation for library dependencies in Scala versions. #596 (olafurpg)
  • Implement hover (aka. type at point). #595 (olafurpg)
  • Fix auto-import position around definition annotations, fixes #593 #594 (olafurpg)
  • Provide completions on case for valid subclasses. #592 (olafurpg)
  • Polish snippets when completing with existing parentheses and braces #590 (olafurpg)
  • Handle generic unapply signatures in signature help. #589 (olafurpg)
  • Explicitly set filter text for all completions. #588 (olafurpg)
  • Add server property config to disable features. #587 (olafurpg)
  • Add support for non-Lightbend compilers #586 (tindzk)
  • Fix signature help bug for tuple patterns. #585 (olafurpg)
  • Escape keyword identifier in packag prefixes. #584 (olafurpg)
  • Filter out ensuring and -> extension methods from Predef. #583 (olafurpg)
  • Include method signature in completion item label. #581 (olafurpg)
  • Two completion improvements #579 (olafurpg)
  • Insert local import when completing workspace symbol. #578 (olafurpg)
  • Update Sublime Text doc regarding Goto symbol in workspace #577 (ayoub-benali)
  • Include case completion when writing partial function on tuples. #576 (olafurpg)
  • Restart the presentation compile more aggressively. #575 (olafurpg)
  • Fix #573, provide unique filter text for each interpolator completion item #574 (olafurpg)
  • Fix #569, remove completion items with \_CURSOR\_ name. #572 (olafurpg)
  • Implement override def completions. #570 (olafurpg)
  • Make bloop server startup more robust, reuse sockets wherever possible. #566 (mudsam)
  • Implement type member selection in string interpolators. #563 (olafurpg)
  • Update Atom info #561 (laughedelic)
  • Improve string interpolator completions #560 (olafurpg)
  • Remove root package from completion results. #559 (olafurpg)
  • Resolve mtags from Sonatype Snapshots, fixes #554. #558 (olafurpg)
  • Disable \( as commit character. #557 (olafurpg)
  • Wrap identifiers in backticks when necessary. #556 (olafurpg)
  • Trigger parameter hints command after completion, if supported. #552 (olafurpg)
  • Cross-publish mtags for all supported Scala versions. #541 (olafurpg)
  • Implement completions and signature help. #527 (olafurpg)