Skip to content

feat(lsp): add Metals LSP support for Scala#12268

Open
YichenLi00 wants to merge 1 commit intoanomalyco:devfrom
YichenLi00:feat/scala-metals-lsp
Open

feat(lsp): add Metals LSP support for Scala#12268
YichenLi00 wants to merge 1 commit intoanomalyco:devfrom
YichenLi00:feat/scala-metals-lsp

Conversation

@YichenLi00
Copy link

Summary

  • Add Metals LSP support for Scala files (.scala, .sbt, .sc)

Closes #10685

Implementation Details

Aspect Decision
File extensions .scala, .sbt, .sc
Project detection build.sbt, build.sc, .scala-build, project/build.properties
Installation Auto-download Coursier, then cs install metals
Platforms macOS, Linux, Windows (x64 and arm64)
LSP command metals (no arguments needed)
Initialization options statusBarProvider: "log-message", isHttpEnabled: true

Why these decisions?

  1. Coursier over direct binary download - Metals is distributed via Coursier (the Scala artifact manager). This is the official installation method and handles JVM version compatibility automatically.

  2. Auto-download Coursier if missing - Follows existing patterns (gopls via go install, csharp-ls via dotnet tool install). Coursier binaries are available for all major platforms.

  3. Java 11+ requirement - Metals requires Java 11 or later. The implementation checks for Java availability before attempting installation.

  4. Project detection files - Covers SBT (build.sbt), Mill (build.sc), Scala CLI (.scala-build), and SBT version file (project/build.properties).

Files Changed

  • packages/opencode/src/lsp/language.ts - Add .sbt and .sc extensions
  • packages/opencode/src/lsp/server.ts - Add Metals LSP server
  • packages/web/src/content/docs/lsp.mdx - Update documentation

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

- Add .sbt and .sc extension mappings
- Auto-download Coursier if not present (macOS, Linux, Windows)
- Auto-install Metals via Coursier
- Requires Java 11+
- Respects OPENCODE_DISABLE_LSP_DOWNLOAD flag
@YichenLi00 YichenLi00 force-pushed the feat/scala-metals-lsp branch from 30cbb96 to 09b64e2 Compare February 5, 2026 09:46
@YichenLi00
Copy link
Author

The failing test (tool.registry) is unrelated to this PR - tracked in #12270. Will rebase once that's merged.

@YichenLi00
Copy link
Author

@thdxr This implements #10685. Ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add Metals as the Scala LSP

1 participant