ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

LSP-metals

by scalameta ST3

Sublime Text package for Metals, a language server for Scala

Details

Installs

  • Total 257
  • Win 50
  • Mac 136
  • Linux 71
Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20
Windows 0 0 0 0 0 2 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 0 0 1 0 0 0 0 1 0 1 1 0 3 0 0 0 0 0 1 0 0 2
Mac 0 3 0 1 2 1 4 4 3 2 0 1 1 0 0 1 1 5 0 1 1 2 1 3 2 2 1 0 3 4 2 13 8 3 1 2 4 1 1 6 1 2 2 5 3 4
Linux 2 1 1 1 0 5 2 2 2 1 0 1 0 0 0 0 0 0 5 0 4 3 1 0 2 0 0 0 3 2 3 0 0 0 4 1 0 1 0 1 1 1 1 0 0 0

Readme

Source
raw.​githubusercontent.​com

LSP-Metals

lsp-metals

LSP-metals is the recommended Sublime LSP extension for Metals, the Scala language server. LSP-metals offers automated Metals installation, easy configuration, Metals-specific commands and many other small features.

Join the chat on Gitter

Table of Contents

Requirements

  • Sublime text 3 or above
  • LSP package: Command Palette (Cmd + Shift + P) > Install package > LSP
  • Java 8 or 11 provided by OpenJDK or Oracle. Eclipse OpenJ9 is not supported, please make sure the JAVA_HOME environment variable points to a valid Java 8 or 11 installation.

Installing LSP-metals

Once you have LSP installed, you can then install Metals via

Command Palette (Cmd + Shift + P) > Install package > LSP-metals

Importing a build

The first time you open Metals in a new workspace it prompts you to import the build. Click “Import build” to start the installation step.

Build Import

  • “Not now” disables this prompt for 2 minutes.
  • “Don't show again” disables this prompt forever, use rm -rf .metals/ to re-enable the prompt.
  • Run lsp toggle server panel in the command palette to watch the build import progress. You can optionally add a key binding for this command.
  • Behind the scenes, Metals uses Bloop to import sbt builds, but you don't need Bloop installed on your machine to run this step.

Once the import step completes, compilation starts for your open *.scala files.

Once the sources have compiled successfully, you can navigate the codebase with goto definition.

Speeding up import

The “Import build” step can take a long time, especially the first time you run it in a new build. The exact time depends on the complexity of the build and if library dependencies need to be downloaded. For example, this step can take everything from 10 seconds in small cached builds up to 10-15 minutes in large uncached builds.

Consult the Bloop documentation to learn how to speed up build import.

Importing changes

When you change build.sbt or sources under project/, you will be prompted to re-import the build.

Configuration

Configure the metals language server by accessing Preferences > Package Settings > LSP > Servers > LSP-metals.

config

Java version

The LSP-metals extension by default uses the JAVA_HOME environment variable (via environ). Otherwise, it uses which to locate the java executable.

If no JAVA_HOME is detected you can then open Settings by following the instructions in the displayed error message.

No Java Home

Server version

To use the latest Metals SNAPSHOT update the server_version setting to try out the latest pending Metals features. After updating the version, you need to restart sublime.

Workplace Diagnostic

To see all compilation errors and warnings in the workspace, run the following command Toggle Diagnostics Panel Or use the default mapping super+shift+M / ctr+alt+M

To cycle through the diagnostic use the default mapping Next F4 / Previous shift+F4

diagnostic

Run doctor

To troubleshoot problems with your build workspace, run Doctor run in the command pallet. This command opens a browser window.

Run Doctor Command

All Available Commands

Show document symbols

Run the Document Symbols command to show a symbol outline for the current file. You can also set a key binding for the lsp_document_symbols command

Document Symbols

Formatting on save

If you'd like to have LSP-metals format your file on document save then make sure to add this setting to your Sublime settings, Syntax-specific settings and/or in Project files.

"lsp_format_on_save": true,
...

Status Bar

Information about your workspace build like compilation errors count, build status, etc. are displayed by Metals in the sublime status bar.

Status bar info

Troubleshooting

If you have any questions or issues with LSP-metals, please submit an issue in this repository if it is related to the extension.

If the issue is general to Metals, please submit it in the Metals issue repo.

If you have any feature requests, we also have a feature request issue repo.