Stream: t-compiler/wg-rls-2.0

Topic: Require user selection from an action


Kirill Bulatov (Dec 29 2019 at 21:19, on Zulip):

One more thing related to the https://github.com/rust-analyzer/rust-analyzer/issues/2180 implementation I would like to discuss.

There can be multiple items with the same name to import in the project, so we need to provide some kind of a dialogue for a user with all possible import options (that's what intellij-rust does now).

Is there anything I can use for that?
If not, IMO it makes sense to make it possible before implementing the auto import functionality and I would appreciate any guidance.

matklad (Dec 29 2019 at 21:52, on Zulip):

Now, we don't but we badly need this for many assists. I am not sure if this can be implemented via the LSP

Kirill Bulatov (Dec 29 2019 at 22:08, on Zulip):

I am not sure if this can be implemented via the LSP

That sounds a bit sad, especially for auto import case where false-positive rate is really high.

Should we reconsider the approach to auto import then and make it something else but an action?
We have some way to interact with VS Code UI at least, since there's Show Syntax Tree functionality that is able to open an external window.

matklad (Dec 29 2019 at 22:19, on Zulip):

I wish I knew any place to ask LSP-related guys about that functionality, that would be so much better direction to move forward.

THe best way is to just re-check how LSP speck says actions should work, and if we can use them. At worst, we can do what run configurations do: hand-crafted cleint-side option picker

Kirill Bulatov (Dec 30 2019 at 11:42, on Zulip):

At worst, we can do what run configurations do: hand-crafted cleint-side option picker

I've looked through the spec and so far it looks like this is the only way we can do it currently: we need to register a custom command and do the magic there.

matklad (Dec 30 2019 at 12:41, on Zulip):

IIRC, it's possible to return a command name & args from an action, so I think our intentions should return smth like this:

{
  "command": "ra-lsp.choose-action",
  "args": [[["import foo", SOurceChange1], ["import bar", SOurceChange1]]]
}
Kirill Bulatov (Dec 30 2019 at 13:29, on Zulip):

Yep, that's what I was planning to do either.
I'll come up with something later.

Kirill Bulatov (Dec 31 2019 at 21:09, on Zulip):

I think I've found a way to do this without any extra commands created: https://github.com/rust-analyzer/rust-analyzer/pull/2716

The only issue with this PR is that the CI fails to run cargo test and does not show me logs.
It passes for me locally, so I have no idea what's wrong.

Last update: Sep 18 2020 at 20:45UTC