Skip to main content

Metals v0.4.0 - Tin

Β· 7 min read

We are excited to announce the release of Metals v0.4, codename "Tin" πŸŽ‰ 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 with contributors from the community.

Metals server​

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

Upgraded Bloop​

This release upgrades from Bloop v1.1.2 to v1.2.5, which includes several improvements to diagnostics and compilation performance. See release notes for more details and upgrade guide.

Major props to @jvican for his great work on Bloop. Bloop does the heavy lifting around build import and compilation for Metals.

Syntax errors as you type​

Previously, Metals only published compile errors from the build on file save. Now, a syntax error is also published as you type making it easier to catch common errors like unclosed string literals and missing parentheses.

Syntax errors as you type

This change has an additional benefit in editors like Vim where compile errors would previously disappear if you for example inserted a newline above an error. Now, Metals updates the positions of errors as you type.

Faster and more reliable clearing of fixed compile errors​

A bug where red squiggles for fixed errors would occasionally not be cleared has now been fixed.

Also red squiggles for fixed errors disappear faster thanks to an improvement in Bloop. Previously, diagnostics were cleared after the bytecode generation phase in the compiler and now they are cleared after the typer phase.

More detailed compilation progress​

The status bar now includes information which individual build targets are being compiled along with a percentage estimate for how much remains of the compilation.

Detailed compile progress

Cascade compile command​

Use the new "Cascade compile" command to trigger compilation in downstream build targets in the workspace. For example, if you have made changes in the main sources of you project you can run cascade compile to trigger compilation in the test sources.

Cascade compile

Formatting with Scalafmt​

It's now possible to format code with Scalafmt.

Formatting with scalafmt

It's possible to use different version of Scalafmt between different workspaces. To configure which Scalafmt version to use for a given workspace update the version setting in .scalafmt.conf.

# .scalafmt.conf
version = "1.5.1"

Symbol outline​

It's now possible to browse the symbol outline of a source file.

Document Symbols

Metals returns a hierarchical outline for editor that support it (like Visual Studio Code, Atom, Emacs) and otherwise returns a flat outline.

Find symbol references​

It's now possible to look up all usages of a given symbol in the workspace.

Find symbol references

It's now possible to look up a symbol definition in the workspace or library dependencies by typing its name. All-lowercase queries are treated as case-insensitive searches.

Fuzzy symbol search example

This feature is not supported yet in Sublime Text.

Blog post on low-memory symbol indexing with Bloom filters​

Read the post "Low-memory symbol indexing with bloom filters" to learn how Metals implements indexing for the features "fuzzy symbol search" and "find symbol references".

Visual Studio Code​

Full changelog: https://github.com/scalameta/metals-vscode/blob/master/CHANGELOG.md

Lower default memory settings​

The extension now starts Metals with the JVM option -Xms100M instead of -Xms1G. The exact memory usage of Metals depends on the size of the project and whether Bloop is installed on the computer or not, but only 50-100Mb can be sufficient memory for Metals in many cases.

Improved Java home detection​

The extension now chooses the latest available JDK home for Java 8. Previously, the extension sometimes picked the JRE over JDK or an older version of Java 8 when newer security updates were installed on the computer.

.jvmopts detection​

The extension now uses JVM options from .jvmopts when launching Metals so it's possible to configure HTTP proxy settings without custom configuration. Memory options like -Xms100M are ignored in .jvmopts, use the "Server Properties" setting to customize memory settings.

Vim​

It's recommended to update vim-lsc to the latest version, full changelog: https://github.com/natebosch/vim-lsc/blob/master/CHANGELOG.md

Update log_level setting​

A recent change in how log messages are displayed makes the status bar updates from Metals disappear unless you set the default log_level setting to Log. Update .vimrc as follows:

 let g:lsc_server_commands = {
- \ 'scala': 'metals-vim'
+ \ 'scala': {
+ \ 'command': 'metals-vim',
+ \ 'log_level': 'Log'
+ \ }
+ \}

View multi-line error messages​

Run the new :LSClientLineDiagnostics command to display all diagnostics on the current line and to un-truncate multi-line error messages. Big thanks to @ayoub-benali for contributing several improvements to LSP.

Sublime Text​

It's recommended to upgrade to LSP v0.8.1, full changelogs:

Built-in "import build" dialogue​

It's now possible to respond to the "Import build" dialogue from Sublime Text without using the HTTP server.

Manual "import build" command​

It's now possible to manually trigger a build import from the command palette.

Import build command

See manually trigger build import for instructions how to configure this command.

Emacs​

The Emacs installation instructions have been improved thanks to @JesusMtnez.

Merged PRs​

  • Trigger didFocus when current compile may affect focused buffer. #500 (olafurpg)
  • Several polish improvements to workspace symbols #498 (olafurpg)
  • Update sublime doc for manual build import trigger #495 (ayoub-benali)
  • Handle sbt pluginsDirectory as symbolic link #417 (gabro)
  • Update feature_request.md #491 (gabro)
  • Avoid redundant didFocus compiles, fixes #483. #488 (olafurpg)
  • Polish before v0.4 release. #485 (olafurpg)
  • Update Emacs docs #484 (JesusMtnez)
  • Upgrade to Bloop v1.2.4 #481 (olafurpg)
  • Clean up indexing pipeline. #480 (olafurpg)
  • Avoid duplicate classpath indexing. #477 (olafurpg)
  • Support navigation for visited dependency sources via workspace/symbol. #476 (olafurpg)
  • Limit classpath search to jars. #475 (olafurpg)
  • Small fixes to workspace symbol #472 (olafurpg)
  • Implement workspace/symbol to search symbol by name. #471 (olafurpg)
  • Implement fast, low-overhead and synthetics-aware find references. #469 (olafurpg)
  • Add "Cascade compile" and "Cancel compile" tasks. #467 (olafurpg)
  • Improve "No SemanticDB" error message #466 (olafurpg)
  • Improve the status bar redirection to window/logMessage #465 (olafurpg)
  • Lower recommended memory settings. #464 (olafurpg)
  • Disable SbtSlowSuite in Appveyor CI. #460 (olafurpg)
  • Improve diagnostic reporting. #459 (olafurpg)
  • Add test case for "missing scalafmt version" #458 (olafurpg)
  • Use scalafmt-dynamic module to simplify formatting implementation. #452 (olafurpg)
  • Improve compilation tracking in the status bar. #451 (olafurpg)
  • Improve eglot documentation #450 (JesusMtnez)
  • Feature/appveyor memory limits #449 (PanAeon)
  • Preinit sbt on appveyor, because it usually fails the first time #448 (PanAeon)
  • Add note to Emacs docs about Eglot usage #446 (olafurpg)
  • Removed ansi colors & fixed TimerSuite for non standard locales #445 (entangled90)
  • Update sublime doc to reflect the changes in the LSP plugin #443 (ayoub-benali)
  • Upgrade to mdoc v1.0.0 #442 (olafurpg)
  • Add snapshot resolver since we're publishing snapshots #441 (mpollmeier)
  • Document textDocument/documentSymbol and textDocument/formatting #440 (gabro)
  • Remove -Dmetals.documentSymbol in favor of client capabilities #439 (gabro)
  • Fix wrong log #437 (gabro)
  • Add log when skipping formatting of a file due to Scalafmt configuration #436 (gabro)
  • Don't attempt build import if sbt version is < 0.13.17 #434 (gabro)
  • Implement textDocument/formatting using Scalafmt #429 (gabro)
  • Move critical file watching in-house. #427 (olafurpg)
  • Implement textDocument/documentSymbols #424 (gabro)
  • Add test to CreateDirectoriesSuite #421 (gabro)
  • Improve Emacs docs #419 (JesusMtnez)
  • Fix incorrect docs #418 (olafurpg)
  • Add more steps to release process. #414 (olafurpg)