-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Default to parent directory if opening a single Scala file. #67
Conversation
In order to make sure Metals will work in any scenario, this small change just grabs the parent directory of the opened file if it can't find any of the root patterns. Closes scalameta#66 Relates to scalameta/metals#2384
Hi. I'm now the official nil workspace police 👮🏽♂️. You have been warned. |
Hi @oblitum, I'm not fully sure I understand your concern. On the Metals side, Metals actually needs a workspace to be set in order for this to work. So in the case of opening a single file, the parent directory actually needs to be set as the |
I understand your condition, but your innocent solution may lead to problematic outcomes. The spec defines this about workspaces, emphasis mine:
(1) This implies that a conforming server should handle From what I could infer, this is the least problematic contract that the LSP could have reached for having LSP features in a standalone file authoring situation. Meaning, e.g., one to be able to edit a file of a given type standalone and LSP being able to provide code completion for system/globally installed libraries/modules/packages without the involvement of some workspace at all. In the many possible situations of opening files for editing, say, a scratch file on When you fix the situation the way you're fixing it, what I'm seeing happening is not only the server not supporting (1), but the client enforcing "project dev" on anything. I see that the spec didn't go that contract because it can be potentially problematic, like, leading servers to scan large and deep directories because the parent directory happens to be If the server is unable to handle So, if you still go the route of implicitly creating workspaces out of thin air, you should realize all that. |
I don't think you fully do understand our condition, and I also think you're misinterpreting the spec a bit.
Like many things inside of the spec, it's quite vague. There is no wording here or in the
Again, this isn't an implicit creation, but rather a very explicit one. If we don't find a build file as we traverse down, then we explicitly want the directory that the file was opened in to be the parent dir. It's intentional. |
Any intention in quoting a deprecated section? Also, I don't see what value it can bring, that's also why I refer to the actual one. The spec states "It can be
All I see here is some implementation very-specific detail which seems to be taken so strongly as to overrule even the spec if necessary. Personally, that it must create a directory on the same path I open some file, is invasive. On spec's side, what's happening here is that this server does not support working without workspaces, and is implicitly configuring them, even when, ideally, would be best not to.
That kind of behavior can never be inferred by reading the spec, so, how is that explicit? Do you warn users that that is going to happen or something in that sense? Is it culturally assumed in metals-land? Alternate discussion here just seems to land at simply not implicitly creating a workspace at all and warning users of that. |
@oblitum If you're actually a Metals user and have some concerns with the way we handle this, feel free to open up an issue in the main Metals repo. |
In order to make sure Metals will work in any scenario, this small
change just grabs the parent directory of the opened file if it can't
find any of the root patterns.
Closes #66
Relates to scalameta/metals#2384