Mike Slinn

Installing Scala for Visual Studio Code

— Draft —

Published 2024-07-18.
Time to read: 2 minutes.

Visual Studio Code is a free, very capable, and well-designed IDE. Although its refactoring capabilities are weak, it works very well on all platforms, including Windows Subsystem for Linux (WSL).

Scala support for Visual Studio Code has the following limitations. IntelliJ IDEA does not have these limitations, and it is very good at refactoring code.

  1. Scala 2.11.x support is deprecated; it will be removed in future releases. Older versions of Scala are not supported.
  2. JDKs older than v11 are not supported. If no compatible version of Java is found, a compatible JDK will automatically be downloaded.
  3. Traditionally, Scala worksheets had .sc filetypes. VS Code requires a .worksheet.sc filetype.

Setup

  1. Install Visual Studio Code and run it.
  2. Click on the extensions view icon on the left.
  3. Type @popular scala into the text field at the top of the extensions view.
  4. Uninstall these extensions if they are present – these old extensions are no longer available:
    1. Scala Language Server
    2. Scala (sbt)
    Uninstall these extensions because they are no longer needed:
    1. vscode-dotty-syntax
    2. Sbt
  5. Install these extensions for Scala:
    1. Scala Syntax (official)
    2. Scala (Metals)
    3. Extension Pack for Java
    You do not need to install any other VS Code extensions for running Scala; Metals does that.
  6. Are these extensions useful?
    1. Graph Buddy
    2. Extension Pack for Java Auto Config
    3. Scaladex search
    4. Scala Snippets
    5. Interactive Scala
    6. IntelliCode
    7. Code Inspector
    8. DeepSource Autofix™ AI

In a VSCode project, the file .vscode/extensions.json contains the recommended list of extensions. Following are the contents of .vscode/extensions.json that I use for this course’s GitHub projects. You might want to use a similar file for your VSCode Scala projects.

{
  // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
  // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

  // List of extensions which should be recommended for users of this workspace.
  "recommendations": [
    "scala-lang.scala",
    "scalameta.metals",
    "vscjava.vscode-java-pack",
    "devonray.snippet",
    "timonwong.shellcheck",
  ],
  // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
  "unwantedRecommendations": [
    "dragos.scala-lsp",
    "lightbend.vscode-sbt-scala",
    "lampepfl.dotty-syntax",
    "itryapitsin.Sbt"
  ]
}

Metals

The Metals documentation for VS Code is pretty good.


* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.