[PR #12268] feat(lsp): add Metals LSP support for Scala #14142

Open
opened 2026-02-16 18:18:57 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12268

State: open
Merged: No


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12268 **State:** open **Merged:** No --- ## 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
yindo added the pull-request label 2026-02-16 18:18:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14142