|
| 1 | +--- |
| 2 | +layout: blog-detail |
| 3 | +post-type: blog |
| 4 | +by: Ólafur Páll Geirsson, Gabriele Petronella, Jorge Vicente Cantero |
| 5 | +title: "Write Scala in VS Code, Vim, Emacs, Atom and Sublime Text with Metals" |
| 6 | +--- |
| 7 | + |
| 8 | +We are excited to announce the release of |
| 9 | +[Metals v0.5](https://scalameta.org/metals/blog/2020/04/12/mercury.html). Metals |
| 10 | +is a Scala language server that supports code completions, type at point, goto |
| 11 | +definition, fuzzy symbol search and other advanced code editing and navigation |
| 12 | +capabilities. Metals can be used in VS Code, Vim, Emacs, Atom and Sublime Text |
| 13 | +as well as any other |
| 14 | +[Language Server Protocol](https://microsoft.github.io/language-server-protocol/) |
| 15 | +compatible editor. Metals is developed at the |
| 16 | +[Scala Center](https://scala.epfl.ch/) along with contributors from the |
| 17 | +community. |
| 18 | + |
| 19 | +## Features |
| 20 | + |
| 21 | +This post we are going to demonstrate how to use Metals with VS Code. To get |
| 22 | +started, install the |
| 23 | +[Scala (Metals)](https://marketplace.visualstudio.com/items?itemName=scalameta.metals) |
| 24 | +extension on the VS Code Marketplace and open an sbt project directory. The |
| 25 | +Metals extension will prompt you to import the build. |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +The build import is handled by [Bloop](https://scalacenter.github.io/bloop/), a |
| 30 | +Scala build server. Adding support for other build tools is possible through the |
| 31 | +[Build Server Protocol](https://github.com/scalacenter/bsp/blob/master/docs/bsp.md). |
| 32 | + |
| 33 | +Importing the project can take a while to run, once complete you can enjoy the |
| 34 | +features of Metals. |
| 35 | + |
| 36 | +### Diagnostics |
| 37 | + |
| 38 | +Syntax errors update as you type and type errors are published on file save. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +A |
| 43 | +[separate `bloop` command-line interface](https://scalacenter.github.io/bloop/setup) |
| 44 | +can be installed to test and run programs from a terminal using the same |
| 45 | +compilation as Metals. |
| 46 | + |
| 47 | +### Type at point |
| 48 | + |
| 49 | +Hover over an identifier to see its expression type, symbol signature and |
| 50 | +documentation. |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +Observe how the active expression is highlighted as the cursor moves. |
| 55 | + |
| 56 | +### Code completions |
| 57 | + |
| 58 | +As you type, code completions are suggested for a range of use-cases such as |
| 59 | +overriding a method from a superclass or generating an exhaustive pattern match |
| 60 | +for a sealed type. |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +Observe that imports are automatically inserted as you complete symbols that are |
| 65 | +not present in the scope. |
| 66 | + |
| 67 | +### Parameter hints |
| 68 | + |
| 69 | +When writing arguments for a method call, use parameter hints to see the method |
| 70 | +signature and available method overloads. |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +### Goto definition |
| 75 | + |
| 76 | +Jump to symbol definitions in your project sources and Scala/Java library |
| 77 | +dependencies. |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +### Find references |
| 82 | + |
| 83 | +Find all usages of a symbol in the workspace, including implicits and `apply` |
| 84 | +methods. |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +### And more |
| 89 | + |
| 90 | +Visit the |
| 91 | +[Metals documentation](https://scalameta.org/metals/docs/editors/overview.html) |
| 92 | +to learn more about other supported features. The website also includes |
| 93 | +instructions for how to use Metals with the editors Vim, Emacs, Atom and Sublime |
| 94 | +Text. However, note that the best supported editor is VS Code. |
| 95 | + |
| 96 | +## Collaboration with VirtusLab |
| 97 | + |
| 98 | +As part of a new collaboration between the Scala Center and |
| 99 | +[VirtusLab](https://virtuslab.com/), VirtusLab will be contributing engineers to |
| 100 | +work on Metals over the coming months. The VirtusLab engineers |
| 101 | +[Marek Żarnowski (@marek1840)](https://github.com/marek1840) and |
| 102 | +[Tomasz Godzik (@tgodzik)](https://github.com/tgodzik) have already contributed |
| 103 | +several impressive pull requests: |
| 104 | + |
| 105 | +- `textDocument/foldingRange` |
| 106 | + ([#632](https://github.com/scalameta/metals/pull/632)): code folding that |
| 107 | + understands Scala syntax. |
| 108 | +- `textDocument/documentHighlight` |
| 109 | + ([#621](https://github.com/scalameta/metals/pull/621)): highlight occurrences |
| 110 | + of a symbol in the current file. |
| 111 | +- `textDocument/completion` |
| 112 | + ([#640](https://github.com/scalameta/metals/pull/640)): override def |
| 113 | + completions from without the need to type "override def ". |
| 114 | + |
| 115 | +It is our pleasure to welcome Marek and Tomasz to the team and we look forward |
| 116 | +to working together with them to improve the Scala code editing experience. |
| 117 | + |
| 118 | +## Share your feedback |
| 119 | + |
| 120 | +Please give Metals a try and share your feedback on |
| 121 | +[Gitter](https://gitter.im/scalameta/metals) or by reporting issues to the |
| 122 | +[Metals GitHub repository](https://github.com/scalameta/metals/). |
| 123 | + |
| 124 | +## Credits |
| 125 | + |
| 126 | +Code completions, type at point and parameter hints are implemented using the |
| 127 | +Scala presentation compiler, which is maintained by the Scala compiler team at |
| 128 | +Lightbend. |
| 129 | + |
| 130 | +Metals started as a fork of the |
| 131 | +[dragos-vscode-scala](https://github.com/dragos/dragos-vscode-scala) repository |
| 132 | +in late 2017 and has since then grown into a project with over 40 contributors: |
| 133 | +Ólafur Páll Geirsson, Gabriele Petronella, Alexey Alekhin, Marek Żarnowski, |
| 134 | +Iulian Dragos, JesusMtnez, Johan Muedsam, Ben Hutchison, Jonathan Shen, Martin |
| 135 | +Duhem, PanAeon, Ayoub Benali, Gabriel Volpe, Shane Delmore, Tomasz Godzik, fc, |
| 136 | +Carlo Sana, Jakub Kozłowski, Eugene Melekhov, Jesús Martínez, Corey O'Connor, |
| 137 | +Eugene Burmako, Pavel Logvinov, Yashwanth Yadavalli, Arnout Engelen, Carlos |
| 138 | +Quiroz, Chris, Cody Allen, David Strawn, Edoardo Vacchi, Eric Peters, Evgeniy |
| 139 | +Tokarev, Joe Ferris, Jozef Koval, Martijn Hoekstra, Michael Pollmeier, Rory |
| 140 | +Graves, Ross A. Baker, Tim Nieradzik, Alexandre Archambault, keiSunagawa. |
0 commit comments