scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.1k stars 332 forks source link

Allow multiple build targets for cross built project #2287

Open tgodzik opened 3 years ago

tgodzik commented 3 years ago

Describe the bug

Currently when a workspace is imported in sbt we only support one scala version, which might be problematic if we use different sources for each scala version. This becomes especially important for Scala 3, which can differ much from the Scala 2 code. In Metals we did a workaround by creating an additional non-publishable module. This however should not be needed.

We should be able to fix it possibly by:

To Reproduce

Steps to reproduce the behavior:

  1. Open scalameta/mdoc
  2. Import build
  3. Try navigating Scala 3 sources.

Expected behavior

Metals works in all sources in the workspace.

Installation:

Additional context

This came up as a follow up to https://github.com/scalacenter/scala-3-migration-guide/issues/111

Search terms

cross build targets

froth commented 2 years ago

Is there any progress on this? Currently working on projects that use 2.X and 3.X macros (via cross compile) is reminding me of the old days when I used vim and gcc ;)

tgodzik commented 2 years ago

@froth no progress currently, but using project-matrix can work around it.

froth commented 2 years ago

Thanks, for the info. I will have a look if project-matrix makes my life easier :)

SethTisue commented 2 years ago

Must I modify my build.sbt to have the scalaVersion I want to use in Metals, or can I switch on the fly somehow...? (I'm using sbt as my build server.)

SethTisue commented 2 years ago

I guess I can go to the Metals tab, click on "Terminal", then run sbt -client ++3.1.3 or whatever version I want, then click "Connect to build server"; that causes the Scala version shown in the Metals Doctor to update.

If there's a better way, lmk.

tgodzik commented 2 years ago

I guess I can go to the Metals tab, click on "Terminal", then run sbt -client ++3.1.3 or whatever version I want, then click "Connect to build server"; that causes the Scala version shown in the Metals Doctor to update.

If there's a better way, lmk.

For sbt that's probably the best way, we would need an additional endpoint for BSP to change it on the fly :thinking: