Metals: Switching branch in git does not prompt for a re-import of the build

Created on 19 Feb 2019  路  9Comments  路  Source: scalameta/metals

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:

  • Operating system: Linux
  • Editor: Sublime
  • Metals version: 0.4.4+5-36ea431c-SNAPSHOT

NB. If I select Don't show again, there is no way to re-enable the importing.

All 9 comments

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

  • non-polling macOS file watching, the JDK file watcher uses polling on macOS and has delays up to 5s
  • non-recursive file watching, we use https://github.com/gmethvin/directory-watcher/ but it only supports recursive file watching. We cannot recursively file watch the workspace root directory since that does not scale for large workspaces with many files.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadeg picture vadeg  路  3Comments

romanowski picture romanowski  路  4Comments

tanishiking picture tanishiking  路  4Comments

iokacha picture iokacha  路  4Comments

laughedelic picture laughedelic  路  4Comments