scalameta / metals-sublime

Sublime Text package for Metals, a language server for Scala
https://packagecontrol.io/packages/LSP-metals
Apache License 2.0
16 stars 10 forks source link

Is it possible to add the parent dir as the `rootUri` when opening a standalone Scala file. #30

Closed ckipp01 closed 3 years ago

ckipp01 commented 3 years ago

As a follow-up to https://github.com/scalameta/metals/pull/2391, the NPE should be avoided now and a message shown if a user just opens up a Scala file. However, without having any rootUri set, a lot of the functionality that is possible won't happen. I'm curios how much of the LSP api from the LSP package is exposed and if it's possible to detect if no root is there, just set the parent as the root. I know Neovim makes this super easy, as you can see here. Would this at all be possible in the Sublime extension until we do a proper refactoring on the Metals side to handle this case?

ayoub-benali commented 3 years ago

I would have to ping @rwols for this. Worse case we can do a check before the initialize request, I think

rwols commented 3 years ago

You can choose to not start the server subprocess by returning an explanatory string in AbstractPlugin.can_start (ST4 only)

Or you can mutate the workspace folders just before starting the subprocess in AbstractPlugin.on_pre_start (ST4 only)