-
Notifications
You must be signed in to change notification settings - Fork 346
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
Allow to choose Bloop or BSP in case of build tools supporting both #2049
Comments
Additional problem is reloading sbt server, but that should be solved with sbt/sbt#5783 Or we could run manually |
Another issue will be getting semanticdb to work with sbt. There is a new setting for sbt:
we should at least display in the doctor to add it it build.sbt. Alternatively, we could try to work on something similar to Bloop, where we create a new file Edit: |
From a UX point of view, I'm a bit worried that this will confuse users. Most users consider bloop as a Metals implementation details, so they wouldn't know what to choose between sbt and bloop. I'm assuming this scenario happens when an existing Metals user upgrades to sbt 1.4.0? What's the status of BSP in sbt? Is it on-par with bloop? What are the advantages of one over the other? I think the ideal scenario would be for Metals to pick one and use the other as a fallback, because I don't think most users will have enough information to answer a "bloop vs sbt" question when prompted. |
Note that this is different than the multiple build tools scenario, since users of repos with multiple build tools (such as a Mill + Sbt project) are generally aware of this and can choose appropriately. The specific BSP implementation is instead a much more obscure detail, that's "IDE-specific" |
This was actually what I was thinking as well. I would argue that from a purely UX viewpoint, Metals should sort of choose the better (maybe a bit subjective) option automatically, while still allowing the user to use an alternative if they want. For an sbt build, if the choice to use sbt also as a build server is the smoothest option for the user, then I'd just automatically choose that and start the build import process. Vice versa, if the process with Bloop is smoother, then I'd go that route. |
I personally think the Bloop UX is currently better and should remain the default. For the sbt integration to reach parity we should at least investigate how to
I want to stress that I am very excited about having native BSP support in sbt and I'm very much looking forward to use it :) A lot of work has gone into the current Bloop integration and we should be careful not to rush and switch until we can provide similar quality. |
Good points! So currently Bloop is a smoother option and it supports run/debug, which sbt's BSP does not. However, I noticed Bloop is having some issues with Scala 3 and it's sometimes hanging (people need to kill the Bloop server manually) and I haven't been able to figure it out. In that case people might want to use sbt bsp support. We could do it a bit differently then:
This will make it available for the power users, but not confuse other. What do you think about it?
There is a new setting in sbt
I agree, it seems weird sbt doesn't send us targets for the meta builds. But that needs a bit more work still.
I would do that when we implement the additional command or user configuration.
I think this is still a bit buggy, so best to keep Bloop as default.
User config could be a good alternative to running an sbt command to enable it. I think it might be better.
I agree, I just want to provide an easy way for people to start testing it without tinkering too much. |
TLDR; Let's keep Bloop default, add an option to run sbt. |
It's not safe to enable the global option for any arbitrary build since the user may be on an unsupported Scala version. An sbt-metals plugin can override
If you think it helps, we can have a command to enable/disable the user option. But I think it's best to keep the user option as the single source of truth whether the user prefers sbt BSP. |
Okay we would like for now to favor bloop and allow users to explicitly enable sbt (maybe for testing, maybe because bloop gives them problems, scala3 works better?). Right now we will use BSP that we were previously using(we store that in db) which is most likely bloop and we are okay here. But for unimported project our logic is to favor If you import project in metals before you start sbt we should be okay. But then if you let's say clone a scala project, start sbt then open it in VSCode - we will use sbt bsp. As you said later we can prompt user for a choice if both bsps provide the same functionality but for now we need to resolve this. Does that make sense?: |
About using
After talking with @tgodzik wanted to try give it a go but I need better understanding what expectations would be to not waste my time coding something that would not work as we expect |
Just to repeat the comment above, it's not safe to set |
okay so
Maybe some of the work can be done directly in sbt? |
We should reuse the earlier metals-sbt plugin, which already added all the needed parameters. This time we can easily add it in |
I we should refactor the logic to have two working modes:
b) should also be remembered in the settings, so that users who want it will not need to connect manually each time and we should also be able to reset that settings.
The sbt b) option should only be allowed on >= 1.4.0
We should do it the same way we did it with the previous plugin, but within metals.sbt file.
Might be good to run the server by ourselves. |
Okay for me to keep track of what we have: previous current sbt plugin:
Okay so the idea would be to not rely on sbt plugin but use our own and |
I think that's what Olaf suggested, yes. |
This is of course purely anecdotal, but I'm having a better experience with SBT. With bloop I've always had problems with metals randomly becoming unresponsive, but I haven't so far had that with SBT. This no doubt reflects something I'm doing wrong with Bloop, but with SBT it just works. |
Thanks for mentioning it! It's always good to hear some feedback. Sbt doesn't yet support everything out of the box, but once it's at the same level we will most likely offer both tools. What kind of problems did you have with Bloop? Was it using CPU too much or was there any errors in the logs? It would also be nice to see if we could fix that. |
Could this be configured via BSP? ie, the BSP client, Metals, asks the BSP server, sbt, to enable the semantic db. I’m not sure this would be easy to do on the sbt/mill/server side, though :)
Which completions do we talk about? |
I think it's a good idea, but also not 100% sure how hard it will be to do it in every build tool.
Bloop generates a separate target for each sbt meta build, thanks to which we are able to get the right classpath with sbt dependencies and give that to the presentation compiler. Without that, completions will only work for basic Scala things, not things like for example |
The matter of enabling semanticdb in sbt for Metals has already been discussed here: sbt/sbt#5616 It has appeared that using BSP to enable semanticdb or even the Also the I personally think a
|
I was prompted to do that when trying sbt 1.4.0's BSP support with Intellij. The following message popped up in sbt's stdout on my terminal:
When I added that line to the end of |
@DestyNova Hmm... I don't think Intellij needs semanticdb plugin, could maybe raise it in sbt or scala plugin? |
Thanks @tgodzik. I removed that line and sbt is behaving the same, so it's probably something else (although it was working earlier... 😕 ) -- sorry for the noise. |
@DestyNova |
With sbt 1.4.0 we will get an automatic generation of
.bsp/sbt.json
file in case of running sbt. This will cause Metals to only pick up sbt in case of no.bloop
files or only choose Bloop if those exist.I propose:
.bloop
and.bsp/sbt.json
files we show a message request with a choice and remember it as it is in case of multiple build toolsIt would be best to do it all before the release of sbt 1.4.0, since we current behavior might not work well there.
Thoughts? Ideas?
The text was updated successfully, but these errors were encountered: