-
Notifications
You must be signed in to change notification settings - Fork 337
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
improvement: add custom bsp as possible build tool #5791
Conversation
64eaad4
to
f64429e
Compare
eac1a09
to
7e18b77
Compare
metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala
Outdated
Show resolved
Hide resolved
override val executableName: String, | ||
override val projectRoot: AbsolutePath, | ||
) extends BuildTool { | ||
override def digest(workspace: AbsolutePath): Option[String] = Some("OK") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the digest of the json, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so as well. But then again on change we do workspaceReload
and that would require a reconnect to have the changes apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also do a custom logic if the current server's json changes to reconnect. Would that make more sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, I added this logic.
val bspFolder = workspace.resolve(".bsp") | ||
val root = customProjectRoot.getOrElse(workspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val bspFolder = workspace.resolve(".bsp") | |
val root = customProjectRoot.getOrElse(workspace) | |
val root = customProjectRoot.getOrElse(workspace) | |
val bspFolder = root.resolve(".bsp") |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we always create .bsp
in the root I assumed we search only there. The root
only says where the bsp command will be run. We can change this behaviour though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally, we would look for .bsp in the custom root also.
metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala
Outdated
Show resolved
Hide resolved
@@ -28,7 +28,6 @@ class PopupChoiceReset( | |||
val result = if (value == BuildTool) { | |||
scribe.info("Resetting build tool selection.") | |||
tables.buildTool.reset() | |||
tables.buildServers.reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reset the choice here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we only change the build tool? So either we trust the user to be reasonable and not chose mill
build tool for sbt
build server. I they do it is still mostly fine. If we reset buildServer choice we'd have to do full reconnect (quickConnect
& slowConnect
) to be connected to correct build server for metals state consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say that we have to servers in .bsp
without resetting we will have to manually do the switch to the other tool, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, since those "forceBuildServer", so it will switch automatically in slowConnect
.
@@ -918,8 +944,7 @@ class MetalsLspService( | |||
.sequence( | |||
List[Future[Unit]]( | |||
Future(buildTools.initialize()), | |||
quickConnectToBuildServer().ignoreValue, | |||
slowConnectToBuildServer(forceImport = false).ignoreValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how we should rename these methods. firstConnectToBuildServer
and connectToBuildServer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, though I'm not sure those names explain it much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do it later on if anyone has a good idea about the names
e5de41b
to
8e60ab1
Compare
8e60ab1
to
a6e1ac4
Compare
I wonder if this line:
chooseServer with anything else than md5 = "EXPLICIT" . I don't know what was the original reasoning behind this. I'm guessing it had something to do with discovering new .bsp configs.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love these changes!
About didChangeWatchedFiles
(in line 1357), do we still need this check for creating file in .bsp
directory, if it's already handled in the other didChangeWatchedFiles
method?
Also, I think we can remove starting fileWatcher
in supportedBuildTool
, since we now have .bsp
directory in Config
@@ -306,17 +305,6 @@ class TestingClient(workspace: AbsolutePath, val buffers: Buffers) | |||
// NOTE: (ckipp01) Just for easiness of testing, we are going to just look | |||
// for sbt and mill builds together, which are most common. The logic however | |||
// is identical for all build tools. | |||
def isSameMessageFromList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments, but otherwise looks good!
case buildTool: BuildServerProvider | ||
if buildTool.buildServerName.contains(buildServerName) => | ||
true | ||
case buildTool => buildTool.executableName == buildServerName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment when this would be different?
@@ -918,8 +944,7 @@ class MetalsLspService( | |||
.sequence( | |||
List[Future[Unit]]( | |||
Future(buildTools.initialize()), | |||
quickConnectToBuildServer().ignoreValue, | |||
slowConnectToBuildServer(forceImport = false).ignoreValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do it later on if anyone has a good idea about the names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Since scalameta#5791 Pants can be used as custom BSP. This should be more reliable, since most of the support was alredy removed.
Since #5791 Pants can be used as custom BSP. This should be more reliable, since most of the support was alredy removed.
Previously: For custom BSP we would still use some other build tool if discovered.
Now: Custom BSP is in itself treated as a build tool, we look for
.bsp
configs in:bspGlobalInstallDirectories
.As a followup we should deduplicate code in build servers and build tools discovery and selection:
BspServers.findAvailableServers
repeats a lot fromBuildTools.loadSupported
,