Metals v0.8.0 - Cobalt
We are excited to announce the release of Metals v0.8.0, codename Cobalt. This release includes a large number of new features and improvements, which have been under development since September 2019.
Commits since last release | 772 |
Merged PRs | 214 |
Contributors | 19 |
Closed issues | 84 |
New features | 8 |
For full details: https://github.com/scalameta/metals/milestone/9?closed=1
Metals is a language server for Scala that works with VS Code, Vim, Emacs, Sublime Text, Atom and Eclipse. Metals is developed at the Scala Center and VirtusLab along with contributors from the community. Recently, Metals has also gained support from Lunatech with the contributions from @ckipp01. We are extremely grateful for the growing support from the community and businesses alike, which shows in the number of new contributions and their quality.
TL;DR
Check out https://scalameta.org/metals/ and give Metals a try!
- run and debug for tests and main methods
- go to implementations
- rename symbol
- first code action - import missing symbol
- worksheet support
- improvements for Bloop integration
- better support for Vim via coc-metals
- completion to add all abstract members
- scaladoc auto completion on type
/**
Debugging
It is now possible to run and test directly from VS Code using the new "Run", "Test", "Debug" and "Debug test" buttons. The debug buttons support debugging with breakpoints. It's possible to insert breakpoints in Java and Scala sources for both workspace sources as well as library dependency sources.
To support other editors please take a look into the documentation on the Metals website.
Known breakpoints limitations we are working on:
- debugging is only supported in VS Code at this moment, we hope to increase the editor support in the future. To support debugging, editors need to implement the Debug Adapter Protocol
- breakpoints may not work as expected in all source locations (example: inner classes, ambiguous names, lambdas). Please share your feedback by reporting issues!
Navigation
Go to implementations
Metals now implements the textDocument/implementations LSP endpoint, which enables all supported editors to display a list of all implementations of abstract classes or members.
Finding implementations also works for symbols outside of the workspace, at the price of a small performance penalty for the first invocation.
The work done for this feature was also instrumental for implementing the Rename refactor (see below).
Refactor
Refactoring support is one of the most requested features in Metals. In this release, we started by implementing the most commonly used refactors: rename and import missing symbol.
We plan to add more common refactors along the way. Make sure to check out the ones that have already been proposed and consider suggesting other refactors that are essential in your development workflow.
Rename symbol
Thanks to the implementation of the Go to implementations
feature, we were
able to work on a proper rename for any workspace symbol that will rename all
occurrences of a symbol even if that symbol is a part of a class hierarchy.
There are a couple of cases in which rename might behave differently based on the particular symbol being renamed:
- renaming an overriden symbol will rename all occurrences for both parent and all children overriding that symbol
- java symbols are not renamed
- renaming "hashCode", "unapply", "unary_!", "!" is not supported, since they change the semantics
- methods starting with
:
can only be renamed to ones with the same first character to make sure code compiles afterwards - renaming apply will change all occurrences with just
()
to a full name.newname()
- if renaming a class with the same name as the file, the file's name will also be renamed
- companion objects will also be renamed along with their companion classes
Import missing symbol
Another refactor that is commonly requested is the ability to fix a compilation error by auto-importing a symbol present on the classpath.
This was previously possible in Metals only during completions, but we were lacking what LSP calls a code action.
Code actions are context-sensitive actions that are proposed to the user in order to fix an error or to perform a relevant refactor.
Thanks to the work of @gabro we now have a basic architecture in place for supporting code actions and we were able to implement this feature.
Worksheet support
Thanks to great work by @olafurpg and some additional refinements by @alekseiAlefirov, worksheets are now available in all supported editors.
Worksheets are a way to evaluate code in real time to test and prototype any new
features in a simple way. To create a worksheet all that is needed is to create
a file with the extension .worksheet.sc
within the source directory of your
workspace (like /src/main/scala
) and Metals will take care of the rest.
There are two ways worksheets are implemented for different editors. One is with
an additional extension to LSP called Decoration extension
and it's used by
Visual Studio Code and coc-metals.
Visual Studio Code:
The other way worksheets are implemented for all other editors that don't
support the Decoration extension
is using workspace/applyEdits and comments
with hover for larger results.
Sublime:
Build tools
In order to make the integration between Bloop and Metals a smoother experience, several new improvements are included in this release. There're based on feedback from users as well us our own experiences while working with Metals and should make the overall experience of importing the build and compiling much better.
SemanticDB is resolved inside Bloop
Metals requires the SemanticDB compiler plugin for a number of features to function properly. Because of that it was quite difficult to add it automatically in all supported build tools even if those supported Bloop itself. Perfect examples are Seed and Fury, which use Bloop to compile code, however adding a plugin automatically would require changes to their core code.
Currently, thanks to recent changes, Metals can send information about the SemanticDB version, which Bloop uses to automatically download and configure the SemanticDB scalac plugin. Thanks to that no changes in the build tool itself are needed. Particular changes in regards to build tools are:
- Gradle - predef script code used in automatic import is now simplified a lot
and works with even more customized workspaces. The only thing it needs to do
is add the Bloop plugin and run
bloopInstall
, which can easily also be done manually by the user. - Maven - no manual configuration is now needed. To import automatically just the plugin is needed to be invoked with a setting for downloading sources.
- Sbt - the
metals-sbt
plugin is now removed and the Bloop plugin is now added via automatically generated./project/metals.sbt
file and ran when imported automatically. Thanks to this solution it should be possible to reuse Metals compilation in the upcoming feature for offloading compilation in Sbt. - Mill - logic for adding semanticDB plugin is removed from Mill.
- Fury, Seed - no changes were needed for the semanticDB integration and should work out of the box.
Switch to to using Bloop Launcher
Instead of using internal Metals logic, we now use the Bloop Launcher, which enables us to either connect to an existing Bsp server or start a new Bloop instance with the specified version if none is running. This greatly simplified the connection to Bloop and enabled us to work on further improvements.
Restart Bloop automatically if newer version is needed
Whenever Metals is started and connects to the Bloop build server it receives information about the version it is running. We compare that version to the one needed by Metals to make sure everything is properly working. If the current running version is older we offer to automatically restart it with the newer version. However, this may not work if Bloop was installed manually.
Automatically reconnect to Bsp/Bloop if connection is broken
There were numerous issues reported that the connection to Bps or Bloop was being lost, which causes Metals to behave erratically due to no compilation being run. To solve this, we now detect if the connection is closed and offer the user the option of automatic reconnection. This works both when the build server was down and when the connection was just interrupted. It should also solve the issues on MacOs with dropped connection.
Completions
Completion to add all abstract members
In the past when you were implementing an abstract member in a concrete class, you'd see the completion option to override the member. However, if you wanted to implement all of the abstract members, you'd need to do each one individually. Now you'll see a new completion option in the scenario to Implement all members which will implement all the members at once.
Support scaladoc auto completion on type /**
Thanks to recent work by tanishiking Metals
now supports auto completing scaladoc for method definition and class definition
on typing /**
. More details about it can be found in
the pull request.
Better support for Vim via coc-metals
In order to better support the Vim experience with Metals, coc-metals extension was created which is an extension for coc.nvim, the most popular LSP client for Vim and Neovim. With this new extension comes a whole bunch of new features for Metals + Vim users.
- automated installation
- easier configuration options
- easier workspace commands
- embedded doctor
- input box support
- implementation of the decoration protocol (Neovim only)
Support for java 11
Thanks to @isomarcte we now also run all tests on JDK 11, which enables us to be more confident about the support for it. With some additional changes to the documentation we now can fully claim that support for JDK 11 is available.
Other changes
This version includes approximately 25% of the Metals git commit log, which makes it impossible to explain every possible improvement in these release notes. Some other features and fixes that we should mention are:
- fix for handling abstract var overrides
- add an empty line after the package declaration before import
- sort auto-completed exhaustive matches by declaration order
- encode the workspace path directory in build digests
- tone down "No SemanticDB" warning
- send Tree View update notification on first no-op compilation.
- enable
goToDefinition
when cursor is at end of symbol - prioritize build targets with supported Scala versions.
- add automatic formatting of multi-line
stripMargin
strings on paste - remove support for 2.12.7
Contributors
Big thanks to everybody who contributed to this release!
We had a lot of new contributors that provided us with some amazing new features and with some amazing quality.
$ git shortlog -sn --no-merges v0.7.6..v0.8.0
Ólafur Páll Geirsson
Tomasz Godzik
Marek Żarnowski
Scala Steward
Gabriele Petronella
Chris Kipp
Rikito Taniguchi
Szymon Świstun
David Strawn
Ayoub Benali
Aleksei Alefirov
Ashwin Bhaskar
Alexandre Archambault
Andy Czerwonka
Enrique Molina
Marc A. Saegesser
Soham Rohankar
Chris Birchall
kostafey
Merged PRs
v0.8.0 (2020-01-10)
Merged pull requests:
- Silence noisy FlywayDB logs #1293 (olafurpg)
- Support scaladoc auto completion on type
/**
#1250 (tanishiking) - Add ability to cancel build server connection #1292 (tgodzik)
- Update utest to 0.7.3 #1291 (scala-steward)
- Update ujson to 0.9.7 #1290 (scala-steward)
- Update pprint to 0.5.8 #1288 (scala-steward)
- Compute 'Import missing symbol' code actions for all diagnostics in range #1286 (gabro)
- Change namespace to scalameta #1285 (ckipp01)
- Allow only to dismiss build server reconnection for 5 minutes #1282 (tgodzik)
- Automatically restart bsp connection when connection socket is closed #1266 (tgodzik)
- Use scala.sys.Process for BloopPants command-line. #1280 (olafurpg)
- Improve IntelliJ application detection when launching Pants bui… #1279 (olafurpg)
- Further polish to --vscode flag. #1274 (olafurpg)
- Add --vscode flag to Pants export tool. #1274 (olafurpg)
- Minor Pants fixes . #1273 (olafurpg)
- More small changes to the Pants export. #1271 (olafurpg)
- Use unique name for synthetic Pants projects. #1269 (olafurpg)
- Update coursier to 2.0.0-RC5-6 #1267 (scala-steward)
- Several improvements to Pants export #1265 (olafurpg)
- Add separate "debug" code lens #1200 (marek1840)
- Support breakpoints in java static methods and nested classes #1214 (marek1840)
- Update flyway-core to 6.1.4 #1264 (scala-steward)
- Upgrade Pants sbt testing interface. #1257 (olafurpg)
- Update coursier to 2.0.0-RC5-5 #1261 (scala-steward)
- Update undertow-core to 2.0.29.Final #1262 (scala-steward)
- Restart Bloop automatically if newer version is needed #1256 (tgodzik)
- typo - evaluating #1255 (ckipp01)
- Failing test case for #1253 #1254 (gabro)
- Slightly more compliant initialization of codeActionProvider #1251 (gabro)
- add in another test for multi-line string formatting #1249 (ckipp01)
- Update geny to 0.4.2 #1248 (gabro)
- Fix multi-line range formatting when on first line #1245 (ckipp01)
- Update sbt-mdoc to 2.1.1 #1247 (scala-steward)
- Update mdoc-interfaces to 2.1.1 #1243 (gabro)
- Remove duplicated Arr in doctor json #1241 (ckipp01)
- Disable flaky test cases #1238 (olafurpg)
- Add in server property for doctor-format and implement json format #1235 (ckipp01)
- Discard 'code' from BSP diagnostics #1232 (gabro)
- Updates to vim section #1227 (ckipp01)
- Update sbt-ci-release to 1.5.0 #1230 (scala-steward)
- Update sbt, scripted-plugin to 1.3.6 #1228 (scala-steward)
- Remove showMessage and showMessageRequest configuration options #1222 (gabro)
- Update ujson to 0.9.6 #1224 (scala-steward)
- Update mdoc-interfaces, sbt-mdoc to 2.1.0 #1225 (scala-steward)
- Update guava to 28.2-jre #1223 (scala-steward)
- Update Sublime settings regarding window/showMessage #1218 (ayoub-benali)
- Update ujson to 0.9.5 #1221 (scala-steward)
- Update flyway-core to 6.1.3 #1216 (scala-steward)
- Remove unreachable code #1217 (ckipp01)
- Update pprint to 0.5.7 #1219 (scala-steward)
- Update coursier to 2.0.0-RC5-4 #1215 (scala-steward)
- Fix scaladoc for methods in Completions #1213 (tanishiking)
- Continued improvements to Pants export #1210 (olafurpg)
- add in documenation for coc-metals #1197 (ckipp01)
- Don't create Bloop projects for Pants targets of type "files". #1211 (olafurpg)
- Set the working directory to the workspace in Pants export. #1209 (olafurpg)
- Further polish to the Pants export. #1207 (olafurpg)
- Update cats-core to 2.1.0 #1206 (scala-steward)
- Add breakpoint support while debugging #1163 (marek1840)
- Update ujson to 0.9.0 #1205 (scala-steward)
- Several more improvements to the Pants export #1203 (olafurpg)
- Include jdk in the job name #1202 (marek1840)
- Avoid re-compilation when restarting Bloop in Pants workspace #1201 (olafurpg)
- Several improvements to Pants export step #1198 (olafurpg)
- Update bloop-config, bloop-launcher to 1.3.4+298-2c6ff971 #1192 (scala-steward)
- Update The Getting Started Documentation For Java 11 #1194 (isomarcte)
- Update flyway-core to 6.1.2 #1193 (scala-steward)
- Remove Usage Of Deprecated
lines
Method #1171 (isomarcte) - Sort auto-completed exhaustive match'es by declaration order #1174 (tanishiking)
- Update bloop-config, bloop-launcher to 1.3.4+297-48a21249 #1187 (scala-steward)
- Hopefully fix flaky test failure #1186 (olafurpg)
- Fix renames for edited companion objects and case class apply #1186 (tgodzik)
- Implement code action for importing missing symbols #1065 (gabro)
- Update bloop-config, bloop-launcher to 1.3.4+271-42941449 #1184 (scala-steward)
- Improve Pants to Bloop export step. #1181 (olafurpg)
- Update bloop-config, bloop-launcher to 1.3.4+260-896345c2 #1180 (scala-steward)
- Update flyway-core to 6.1.1 #1179 (scala-steward)
- Ignore flaky BspSwitchSuite and reenable FoldingRangeSuite on Windows. #1177 (tgodzik)
- Update utest to 0.7.2 #1178 (scala-steward)
- Update scalafmt-core, scalafmt-dynamic to 2.3.2 #1173 (scala-steward)
- Minor tweaks to CI jobs names #1176 (gabro)
- Disable EOL Conversion On /.jvmopts #1170 (isomarcte)
- Fix Runtime Error In Metals Bench #1165 (isomarcte)
- Try fixing the Windows CI #1164 (gabro)
- Upgrade to Scalafmt v2.3.1 #1162 (olafurpg)
- Update interface to 0.0.16 #1159 (scala-steward)
- Update ujson to 0.8.0 #1157 (scala-steward)
- Update lz4-java to 1.7.0 #1167 (scala-steward)
- Update qdox to 2.0.0 #1166 (scala-steward)
- Use atomic file move operations. #1155 (olafurpg)
- Worksheets support for non-VS Code editors #1089 (alekseiAlefirov)
- Update import documentation for Emacs #1156 (tgodzik)
- Add basic support for the Pants build tool #935 (Sohamr)
- Cleanup MarkdownGenerator #1152 (isomarcte)
- Remove Unused
packagePriority
Parameter From ClasspathSearch #1149 (isomarcte) - Internal refactorings to prepare for Pants support #1145 (olafurpg)
- Remove Unnecessary
asInstanceOf
And Unused Values #1151 (isomarcte) - Remove Unused Local Variable
count
#1150 (isomarcte) - Remove Two More Usages Of Deprecated
lines
Method #1148 (isomarcte) - Update interface to 0.0.15 #1147 (scala-steward)
- Update coursier to 2.0.0-RC5-3 #1146 (scala-steward)
- Revert "Update directory watcher to 0.9.6" #1144 (olafurpg)
- Update directory watcher to 0.9.6 #1135 (tgodzik)
- Update scribe to 2.7.10 and remove duplicate newline #1137 (tgodzik)
- Use git fetch --unshallow to restore version number #1143 (olafurpg)
- [DAP-tests] Adapt new lines to the underlying OS #1124 (marek1840)
- Remove Deprecated Usage Of String#lines Method #1139 (isomarcte)
- Update better-monadic-for to 0.3.1 #1104 (scala-steward)
- Update mdoc-interfaces, sbt-mdoc to 2.0.3 #1141 (scala-steward)
- Update flyway-core to 6.1.0 #1132 (scala-steward)
- Update xnio-nio to 3.7.7.Final #1140 (scala-steward)
- Update sbt to 1.3.4 and fix flaky 2.13.0 test #1138 (tgodzik)
- Avoid renaming synthetic occurrences #1077 (gabro)
- Update coursier interface to 0.0.14 #1136 (tgodzik)
- Upgrade to h2 v1.4.200. #1133 (olafurpg)
- Revert "Update jna, jna-platform to 5.5.0" #1134 (olafurpg)
- Fix renames in case of macro annotations #1095 (tgodzik)
- Revert "Update directory-watcher to 0.8.3" #1126 (olafurpg)
- Update xnio-nio to 3.6.9.Final #1113 (scala-steward)
- Update simulacrum to 1.0.0 #1099 (scala-steward)
- Update jna, jna-platform to 5.5.0 #1131 (scala-steward)
- Update sbt-jmh to 0.3.7 #1121 (scala-steward)
- Update org.eclipse.lsp4j, ... to 0.8.1 #1111 (scala-steward)
- Update utest to 0.7.1 #1129 (scala-steward)
- Update jsoup to 1.12.1 #1114 (scala-steward)
- Update sbt-ci-release to 1.4.31 #1125 (marek1840)
- Upgrade to latest Bloop. #1096 (olafurpg)
- Update cats-core to 2.0.0 #1120 (scala-steward)
- Update jna, jna-platform to 4.5.2 #1110 (scala-steward)
- Update directory-watcher to 0.8.3 #1108 (scala-steward)
- Update guava to 28.1-jre #1100 (scala-steward)
- Update paradise to 2.1.1 #1116 (scala-steward)
- Update scalameta, semanticdb-scalac, ... to 4.3.0 #1119 (scala-steward)
- Update sbt-mdoc to 2.0.2 #1117 (scala-steward)
- Update flyway-core to 5.2.4 #1112 (scala-steward)
- Update undertow-core to 2.0.28.Final #1109 (scala-steward)
- Update qdox to 2.0-M10 #1106 (scala-steward)
- Update utest to 0.6.9 #1103 (scala-steward)
- Update pprint to 0.5.6 #1102 (scala-steward)
- Update sbt-scalafix to 0.9.11 #1097 (scala-steward)
- Delay renaming in closed files until the first save is run #1094 (tgodzik)
- Update sublime documentation #1093 (ayoub-benali)
- Decode for better readability #1092 (ckipp01)
- Fix cross macro tests for older Scala versions #1091 (tgodzik)
- Fix issue with no source dependencies being downloaded by Bloop #1090 (tgodzik)
- Update to the latest setup-scala. #1087 (olafurpg)
- add in more documentatin for vim setup #1082 (ckipp01)
- Update documentation #1080 (ckipp01)
- Replace coursier-small with coursier-interface #1080 (sswistun-vl)
- Use exact match when computing file renames #1075 (gabro)
- Force sequential publishLocal for mtags 2.11/2.13. #1073 (olafurpg)
- Update emacs docs to include yasnippet #1068 (ckipp01)
- Update Sublime settings since it does have auto-indent #1064 (ckipp01)
- Respect client capabilities for completion item snippets #1057 (gabro)
- Disable flaky test on Window #1060 (olafurpg)
- Add completion to add all abstract members #1031 (ckipp01)
- Welcome Chris to the team! #1059 (olafurpg)
- Implement textDocument/rename #1048 (tgodzik)
- Handle abstract var overrides #1056 (gabro)
- Add an empty line after the package declaration before import #1051 (ckipp01)
- Implement basic worksheet mode using mdoc and text decorations #1041 (olafurpg)
- Give Bloop more visibility on the website. #1053 (olafurpg)
- Only run tests on master branch or in PRs #1044 (tgodzik)
- Update sbt version to 1.3.2 #1043 (tgodzik)
- Update sample Emacs configuration to avoid AutoSave files in src dir #1032 (marcsaegesser)
- Update SemanticDB version to 4.2.5 and enable previously broken test #1033 (tgodzik)
- Add type annotations for public members with Scalafix #1034 (olafurpg)
- Delegating client should not always call configure #1039 (tgodzik)
- Suppress model-refresh if debugging is unsupported #1019 (marek1840)
- trace the debug adapter protocol messages #1023 (marek1840)
- Reenable and fix tests on Windows #1020 (tgodzik)
- Add guards against nulls that happened in the HoverProvider code #1025 (tgodzik)
- Move all tests into github actions #1018 (tgodzik)
- Upgrade to Bloop v1.3.5. #1017 (olafurpg)
- Encode the workspace path directory in build digests #1015 (olafurpg)
- Resolve problem with coc.nvim installation #1013 (sswistun-vl)
- Suppress code lenses if debugging is not supported #1012 (marek1840)
- Switch to to using Bloop Launcher #1004 (tgodzik)
- Keep code lenses after error until next successful compilation #994 (marek1840)
- Send Tree View update notification on first no-op compilation. #997 (olafurpg)
- Fix current CI flakiness with DiagnosticLspSuite and LensesLspSuite #1000 (tgodzik)
- Switch shutdownNow to shutdown due to excessive exceptions being logged #1003 (tgodzik)
- Strip "metals." prefix from
workspace/executeCommand
requests. #998 (olafurpg) - Strip library version when comparing expected output in TreeViewLspSuite. #999 (olafurpg)
- Install bloop server in CI #982 (sswistun-vl)
- A documentation change in support of Java 11 configuration #995 (andyczerwonka)
- Make find implementation run on a separate thread for each file #989 (tgodzik)
- Fix issue when on type formatting threw an exception on last newline #990 (tgodzik)
- Re-introduce Azure pipelines for more stable CI. #988 (olafurpg)
- Add automatic formatting of multi-line
stripMargin
strings on paste #968 (ckipp01) - Clarify Emacs installation instructions #985 (sswistun-vl)
- Add system property to disable project/metals.sbt generation #979 (olafurpg)
- Fix typo: Occurence -> Occurrence #987 (tanishiking)
- Add link to new Discord server in the website footer. #981 (olafurpg)
- (Spac)Emacs continuously crashing due to compilation of swap files #986 (quiquedev)
- Remove automatic gitignoring. #983 (tgodzik)
- Refactor slow suite name #977 (ckipp01)
- Tone down "No SemanticDB" warning #973 (olafurpg)
- Print summary of test failures at the end of the logs. #972 (olafurpg)
- Enable goToDefinition when cursor is at end of symbol #965 (ashwinbhaskar)
- Test code lenses within packages #971 (marek1840)
- Add .bloop and .metals paths to gitignore automatically #967 (ashwinbhaskar)
- Fall back to mtags position occurrences #962 (gabro)
- Bump server version in template #964 (gabro)
- Change manual instalation section for sbt, gradle and maven #963 (tgodzik)
- Warn if bloop version is older than 1.3.3 #957 (tgodzik)
- Use consistent naming for metals experimental feature: debugging provider #960 (marek1840)
- Add support for running and testing via Debug Adapter Protocol #942 (marek1840)
- Add goto implementation #934 (tgodzik)
- Improve SemanticDB integration using Bloop's newest features #852 (tgodzik)
- Avoid race conditions during slow/test command. #951 (olafurpg)
- Don't file watch inside jar files. #950 (olafurpg)
- Don't propose completions for null or nothing #949 (tgodzik)
- Prioritize build targets with supported Scala versions. #948 (olafurpg)
- Replace Azure pipelines with GitHub Actions #947 (olafurpg)
- Replace mvn and mvn.cmd script with jar invocation #944 (tgodzik)