scalameta/metals-sublime

Metals Doctor opens regularly

mrdziuban opened this issue · 5 comments

I just installed and configured Metals in Sublime Text yesterday and I've found that Metals Doctor opens far more frequently than I'd expect. I'm not exactly sure what triggers it to open, but it often seems to happen after switching between git branches or after opening a .scala file in a different SBT sub-project.

Is there anything I can do to prevent this from opening except when I explicitly choose to run it from the command palette?

The windows is open because Metals is sending a notification to the editor. I am not aware of a ways to disable that with Metals. I could introduce a settings in the plugin but maybe @ckipp01 @tgodzik could help here.

The windows is open because Metals is sending a notification to the editor.

I'm assuming you're referring to the executeClientCommand being metals-doctor-run? Metals shouldn't really send this unless it was asked to via a doctor-runserver command, or there is some sort of an issue with that command attached to it. Is this a known issue that happens frequently when using Sublime @ayoub-benali, or is this the first you're hearing of it?

Either way, one way to really make sure is to look at the lsp-trace.json file that you can create showing the lsp communication. You should be able to see exactly what is happening then, and we can troubleshoot from there.

Metals shouldn't really send this unless it was asked to via a doctor-runserver command

for example when you edit build.sbt, Metals re-imports the builds and then sends metals-doctor-run to the editor. The same happens when you change branch like mentioned by @mrdziuban.
It is a known behavior from Metals.

for example when you edit build.sbt, Metals re-imports the builds and then sends metals-doctor-run to the editor.

Do you mean metals-doctor-reload? For example I just tested this and that was the behavior. If that's the case, the reload shouldn't ever open the doctor, only refresh it if it's already open.

Even better is if you make the client a doctorVisibilityProvider meaning that in the scenario where the doctor isn't open, you're not going to be send a reload. The doctorVisibilityProvider was very recent and isn't in the latest stable yet. You can see the pr for it here: scalameta/metals#3768.

yeah metals-doctor-reload, in sublime we can't edit the doctor window so I guess there is a bug here: https://github.com/scalameta/metals-sublime/blob/master/core/handle_execute_client.py#L23
metals-doctor-reload should simply be ignored by this plugin.

I guess I should add doctorVisibilityProvider as well