scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.07k stars 323 forks source link

Switching branch in git does not prompt for a re-import of the build #533

Closed MasseGuillaume closed 5 years ago

MasseGuillaume commented 5 years ago

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.

ayoub-benali commented 5 years ago

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

MasseGuillaume commented 5 years ago

Thanks @ayoub-benali! The command is really usefull.

I think intellij has nailed this already. You can auto-import when the build changes.

ayoub-benali commented 5 years ago

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.

olafurpg commented 5 years ago

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

ayoub-benali commented 5 years ago

@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 ?

olafurpg commented 5 years ago

Metals uses client/registerCapability to register file watchers patterns https://scalameta.org/metals/docs/editors/new-editor.html#client-registercapability

gabro commented 5 years ago

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

olafurpg commented 5 years ago

Sublime sends textDocument/didSave notifications, but these don't trigger when you checkout a different branch from the terminal.

MasseGuillaume commented 5 years ago

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.