-
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: auto detect project root #5576
Conversation
76a34da
to
e18df79
Compare
metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala
Outdated
Show resolved
Hide resolved
@@ -2012,7 +2054,13 @@ class MetalsLspService( | |||
&& buildTools.loadSupported.isEmpty | |||
&& folder.hasScalaFiles | |||
) { | |||
scalaCli.setupIDE(folder) | |||
languageClient |
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.
The change doesn't seem to be related? The automatic fallback to Scala CLI didn't seem to cause any issues.
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.
It's a bit related. When you have a custom root in e.g. workspace/myProject/myProject2/
, it won't be automatically detected. In that case you don't want to import as scala-cli, instead you want set the correct root in settings.
Do you think that asking the user is a worse solution? I can revert to doing that automatically.
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 the automatic detection is actually pretty nice and I don't think we need to ask. If people encounter issues we can rethink it, but from what I noticed the responses were positive (or people didn't notice which is perfect)
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.
Okay, I reverted that.
if ( | ||
path.isDirectory && !path.toNIO.filename.startsWith( | ||
"." | ||
) && path.toNIO.filename != "project" |
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 can imagine someone having a project
directory, why is this needed?
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 in "project" we have .bloop
for meta build and we don't want to detected it. Especially if something goes wrong and we have .bloop
only in "project". I guess we can do it differently avoid going deeper if there is some top-level build tool (I feel like there was an argument against that approach but I can't remember now).
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 wouldn't go to project/.bloop
since we would already have .bloop
in the main dir, 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.
In the happy path, yes. But if something goes wrong and .bloop
in main directory isn't created, the one in project/
still will be (we even have a test for this scenario).
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 changed that do discovering bloop is correlated with the chosen build tool.
metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala
Outdated
Show resolved
Hide resolved
@@ -313,6 +314,19 @@ object UserConfiguration { | |||
|launcher, not available in PATH. | |||
|""".stripMargin, | |||
), | |||
UserConfigurationOption( | |||
"projects-roots", |
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 if need the setting if this is done automatically. Seems a bit complex and people might never use workspaces, which makes this setting their roots more difficult
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.
As above: automatically it's only for shallow levels. Yeah... This setting is a bit far from perfect. But for most users it won't be needed.
As I mentioned in the feature request, we should probably switch to workspace/configuration (from didChangeConfiguration) in the long run. It allows for scoping settings, so making settings per workspace folder will be much more intuitive.
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.
Per workspace would be ideal here, we can introduce the setting with that change then, maybe? OTherwise we will be stuck with this much more complex setting
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 deleted the setting for now and left only auto detection.
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 remove it from UserConfiguration for now also?
metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala
Outdated
Show resolved
Hide resolved
e18df79
to
cb307fa
Compare
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! If you could just remove the added setting from UserSettings
@@ -313,6 +314,19 @@ object UserConfiguration { | |||
|launcher, not available in PATH. | |||
|""".stripMargin, | |||
), | |||
UserConfigurationOption( | |||
"projects-roots", |
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 remove it from UserConfiguration for now also?
Although it looks like you need to fix the tests first 😞 |
99d3885
to
6694a54
Compare
6694a54
to
f74bdd6
Compare
Do you want to take another look @tgodzik? It seems there were quite a few changes with the test fixes since your approval. |
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.
Looks good! You might need to rebase and we can merge
f74bdd6
to
d71caf4
Compare
Automatically detected project root with search depth of 2 levels meaning if it's:
connected to: #5907