-
Notifications
You must be signed in to change notification settings - Fork 340
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
Use existing metals instance instead of starting new on goto file outside of workspace root #6665
Comments
I think this might be a false report. I wiped my |
Okay, I think that the reason that it worked in the first place with local third-party projects is because I have had a generated Can it be confirmed whether or not this is a feature in metals I am not meeting the requirements for, or something the editor LSP client should handle? |
The source files in the stack trace look weird a bit, they are located in the bazel cache: Are you opening the deps in the cache? Otherwise we might not be able to see if those are the same ones as in the child project. Specifically sources result points to the cache:
|
Yes. If the third-party sources are fetched from network they'll be in the bazel cache folder.
Are there any restrictions on the path of child project (shared root or similar)? I think I might have been ambiguous with my example folder structure, this is what I meant.
I can depend on the resulting child project's resulting |
We do try to support that case and there was a change as recent as #6563 Metals should not start a new connection if we detect that a current build server already works for that, but maybe there is still some issue. In particular, we do save in |
Other than the bsp trace, there's a {"project-ref":["../../.cache/bazel/_bazel_valde/mezel-b38cc3c8af6e82d3fafc60d8b18e56bc/external/hxl"]} I am not sure how you detect project handles, but the one in the settings file is relative but buildTarget is absolute. |
relative should be fine in this case (though will be a problem for windows) Let's add some debug messages so that it's easier to see on your side #6675
|
I tried your branch and followed the contributors guide for how to test locally. So I used vscode instead of my usual editor neovim. The feature seems to work fine in vscode, but doesn't in neovim. Is the LSP client supposed to support this feature? It is a while ago the neovim plugin has been updated https://github.com/scalameta/nvim-metals |
Honestly, I have no idea, you can create the lsp trace in .metals/lsp.trace.json and see if @ckipp01 might know more about nvim part. |
Thanks for the quick responses. Are there any flags I can give metals so it doesn't truncate the trace files? As soon as I goto definition the file is truncated since it thinks it is a new project. |
Nothing currently 🤔 We always truncate the files to avoid having infinately growing files. We can add a flag here no problem. I will add it to the same PR |
@ValdemarGr actually this is weird, we don't truncate the file when the same Metals instance is running. And if it's a new project, wouldn't it be a totally new directory with .metals being created there? |
It starts a new process, but the PWD is the same. |
You could just do |
It looks like the LSP client asks to initialize after getting the Edit; include what I think might be the relevant part:
|
Looks like a completely new Metals server is started in the new directory, which is why it has no knowledge of the previous BSP server. This doesn't look like something we can fix in Metals, wouldn't it be a neovim logic? |
It might be related to |
This seems to fix it scalameta/nvim-metals#671 (comment) . I suppose it would be ideal if the default semantics were the same as in vscode? |
I guess that depends, but in this case sure. I have very limited understanding of the neovim plugin though. |
I'm chiming in a bit late here, but nvim-metals works a bit different with multiple root projects since in neovim the idea of a "root" doesn't really exist. We sort of artificially determine where it should be in a single place. However when you have two different roots in a single "workspace", things get tricky. Therefore you'll want to use the |
Describe the bug
In a project with multiple workspaces where one or more child projects are not under the same .bsp folder, metals or the editor prompts to start a new server if a file is opened from in a folder that does not share the same workspace root, even if the current metals instance contains that file in a build target.
What should happen:
Parent's bsp server should handle both parent and child projects.
What happens:
Opening Parent.scala and then opening Child.scala causes a prompt to appear, asking if Child.scala's project should be imported.
Being able to have this folder structure is especially useful when compiling third party code from source.
I am unsure if this is an issue is related to the metals server or the LSP client? I use nvim-metals.
I suppose one of the BSP choices (maybe even the default?) should be to continue on the currently running BSP instance, in the case that the opened file is part of the already running metals instance's sources list.
Maybe I am missing something essential, since I am also developing the BSP server such that there is an additional axis of potential fault on my part, but here is the full trace, doctor and semanticdb of the child:
https://gist.github.com/ValdemarGr/ca1d4b3e5695da07c1e51c4dfe5753d6
The output was generated from the project in the example folder in this project, launched with the
.bsp/mezel-local.json
BSP configuration which uses a locally built serversbt assembly
.Expected behavior
No response
Operating system
Linux
Editor/Extension
Nvim (nvim-metals)
Version of Metals
v1.3.5
Extra context or search terms
No response
The text was updated successfully, but these errors were encountered: