Closed ckipp01 closed 1 year ago
Thanks for reporting! When I create a file in Metals it's correctly picked up and compiles fine. I can see 2022.12.19 15:46:44 INFO Refreshed build after change
in the logs. Are you sure you are using the newest scala-cli? Maybe you scala-cli setup-ide Main.scala
?
Weird that's not what I'm seeing at all for example, here is the LSP trace
This is from the moment I select to create a new case class, save it, etc. Is there maybe a notification missing from the nvim-metals
side that Metals is expecting here? What is actually triggering the reload for scala-cli
?
Here is what I'm using:
- Metals Server version: 0.11.9+211-b679d25f-SNAPSHOT
- Build server currently being used is scala-cli v0.1.18.
Weird that's not what I'm seeing at all for example, here is the LSP trace
Full trace This is from the moment I select to create a new case class, save it, etc. Is there maybe a notification missing from the
nvim-metals
side that Metals is expecting here? What is actually triggering the reload forscala-cli
?
That should be entirely on the Metals side, there is onBuildTargetChanged notification, but that is never forwarded to clients.
Interesting so I see inverseSources
requests but no onBuildTargetChanged
happening in the BSP logs. For example here is from the original diagnostic through me created and saving Foo.scala
:
In conclusion:
scala-cli setup-ide .
the files are discovered correctly.scala-cli run Main.scala
the files are not discovered, which is not technically a bug but can be confusing. It is even more confusing since running scala-cli run .
will not update the config. So if no build target is found for a file for scala-cli we should ask the user if they want to amend the config and restart the build server?So if no build target is found for a file for scala-cli we should ask the user if they want to amend the config and restart the build server?
Ideally yes, I wonder whether even to do it automatically :thinking:
Turns out @ckipp01 is right. If you do scala-cli setup-ide .
new files are not properly registered if you use new scala file...
. Build targets are not found for those newly created files, which makes sense, since Source Directories
for scala-cli
will be a list of the files in that build target. However, if you add a file using a different method than new scala file...
it will cause scala-cli bsp to reconnect and recreate build targets, so they contain also the new file. Which makes is look like things work properly. @tgodzik, any thoughts?
That's super weird, this should work the same irrelevant of how the file is created :thinking:
After some digging. It seems it's not metals
that causes the recreation of the build targets but the build server. And refresh in metals is just the consequence of bs changes. You can see it when you start scala-cli
bsp from terminal and add a new scala
file. So I'm thinking that whatever action the build sever reacts to is not triggered when metals
is the one to create the file. So, yeah @tgodzik from metals point of view the way you create the file doesn't matter.
This should ork correctly with the amend options.Closing for now, do let u know if it breks again.
Just confirming that I did just try the same workflow as I did when I reported this and it does indeed work 🎉
Describe the bug
I'm not 100% sure if this is something we can solve on our end or if there would need to be changes in
scala-cli
but one thing I noticed today was the following.Let's say you have a
Main.scala
that you've already ransetup-ide
for viascala-cli setup-ide .
Then inside of that file you try to useFoo
, butFoo
doesn't exist yet. So Metals offers to create this newFoo
for you and you choose a case class for it. Metals then facilitates the create ofFoo
, but yourMain.scala
still doesn't detect it. Also when you look at theSource Directories
you still only see main:Expected behavior
I'd expect that if a user is using Metals to create a new file it should be able to "reload" the build or let
scala-cli
know that there is another source. Either that orscala-cli
should know that another source was added to the workspace.Operating system
macOS
Editor/Extension
Nvim (nvim-metals)
Version of Metals
0.11.9+211-b679d25f-SNAPSHOT
Extra context or search terms
No response