-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preferred platform and Scala version in cross-built projects #13
Comments
Related discussion in https://gitter.im/scalameta/metals?at=5cc167b54b4cb471d953beaa on the expected behavior of "preferred platform" |
Previously, if two build targets in the repo were eligible for a source file, Metals would sometimes prioritize a target with an unsupported Scala version over a target with a supported Scala version. This resulted in completions/hover/parameterHints not to work while editing cross-built sources. This PR introduces a change to the logic where we select a build target for a given source file. Now we sort the elibible candidates by two criteria: the Scala version and the platform (JVM/JS/Native). This change takes the first step towards scalameta/metals-feature-requests#13, which is about making this logic configurable.
Previously, if two build targets in the repo were eligible for a source file, Metals would sometimes prioritize a target with an unsupported Scala version over a target with a supported Scala version. This resulted in completions/hover/parameterHints not to work while editing cross-built sources. This PR introduces a change to the logic where we select a build target for a given source file. Now we sort the elibible candidates by two criteria: the Scala version and the platform (JVM/JS/Native). This change takes the first step towards scalameta/metals-feature-requests#13, which is about making this logic configurable.
First step towards implementing this feature scalameta/metals#948. The next step would be to expose configuration to to customize the priority when selecting a single build target from multiple candidates. |
BackgroundI was having difficulty with the cross build for Dotty/JVM on https://github.com/ekrich/sconfig using
The problem here is there is no direct way to separate Making this work is done via the following method in WorkaroundThe method as recommended here works but is tricky. ☝️ April 17, 2020 7:32 AM You need to IdeaAllow the user to use a drop down to select the Platform and version when using Metals?
|
BSP is already able to represent cross-built projects. The reason you get "no build target" for Dotty sources is that Cross-building is arguably a power-user feature so I think the current situation with sbt where we only export one Scala version it not too bad. There are several available solutions:
|
I am totally happy with the ability to select a version in Any sort of feature that would allow the user to select a platform and version would be welcome of course so that metals would communicate to the build server to set the platform and version. This would also require some sort of UI work too. I do think that Metals should only work with one version at a time to minimize the work it needs to do. It would be neat if you could somehow select |
Cross-building remains a power-user feature so it's difficult to prioritize improvements to the UX in the scenario when there exists a decent workaround. I think the highest priority issue at the moment is to make Metals accessible to Scala beginners who may not be experienced developers, or familiar with sbt or the Scala tooling ecosystem. |
I totally agree, just wanted to mention it in case someone wanted to tackle it. |
I guess I have a contrarian view here, I work a fair bit with cross built projects amongst multiple Scala versions and especially when dealing with Scala 2/Scala 3 projects I do think that the default should be to create a bloop definition for all of the projects Scala versions. My argument for this is that otherwise the default user experience is quite terrible, for a while I thought my metal's install was broken when working on a cross Scala 2/ Scala 3 project until I happened to come across this issue (running At least to me, making bloop/metals support |
I have created a currently in draft PR at scalameta/metals#5637 to prototype the solution |
Currently, Metals uses a basic heuristic to select a default built target when multiple targets are associated with a single source file. For example, when a user edits a shared source file for Scala.js and JVM build targets Metals automatically picks the JVM build target and the users can't override/customize that choice.
It would be good if Metals exposed some control over the default heuristic via configuration, for example:
Users could reorder those lists to for example tell Metals to prefer JS on 2.11 over JVM 2.12.
The text was updated successfully, but these errors were encountered: