Describe the bug
When I modify build.sbt, there is a prompt windows that asks me: Import changes, Not now, Don't show again. However, if I change the branch with git, I don't see the prompt. More importantly, there is no way for me to ask to re-import the build.
Expected behavior
Metals should watch for build.sbt, project/**.scala. A change to those files should prompt the re-import dialog.
Installation:
NB. If I select Don't show again, there is no way to re-enable the importing.
More importantly, there is no way for me to ask to re-import the build.
@MasseGuillaume You can check the doc to import build manually
Thanks @ayoub-benali! The command is really usefull.
I think intellij has nailed this already. You can auto-import when the build changes.
I don't know if metals has built-in file matching capability but I think it is relying on the editor to be informed when a file changes.
Metals file watches source directories, which is required for critical functionality like goto definition, and delegates non-critical file watching (*.sbt and project/*.{sbt,scala}) to the editor client. See https://scalameta.org/metals/docs/editors/new-editor.html#workspace-didchangewatchedfiles
The Sublime LSP client does not implement didChangeWatchedFiles so please open a feature request in that package. Metals does not file watch $workspace/*.sbt because I'm not aware of a JVM library that supports
@olafurpg how is VS code plugin (or other clients) handling didChangeWatchedFiles ?
Does it watch all the files of the workspace? or does Metals first inform the client which files it should watch on its behalf ?
Metals uses client/registerCapability to register file watchers patterns https://scalameta.org/metals/docs/editors/new-editor.html#client-registercapability
If I understand this correctly, this is due to Sublime Text not sending notifications for the build definition files (build.sbt and friends).
If that's the case, who is triggering the "build changed, please re-import" notifications on Sublime in the normal case? I'm referring to
When I modify build.sbt, there is a prompt windows that asks me: Import changes, Not now, Don't show again.
from the original post
Sublime sends textDocument/didSave notifications, but these don't trigger when you checkout a different branch from the terminal.
Thanks @olafurpg for the explanation.
@ayoub-benali created the ticket for the sublime integration: https://github.com/tomv564/LSP/issues/516
The sublime command is good enough for me.