Stream: t-compiler/rust-analyzer

Topic: Auto-insert matching braces


Jonas Schievink [he/him] (Dec 15 2020 at 23:37, on Zulip):

VS Code does not auto-close braces in use statements, which leads to loads of parse errors when going from use the::Thing; to use the::{Thing;.

Is there a way for rust-analyzer to do better here, by automatically closing the use item, or does LSP not support something like that?

Lukas Wirth (Dec 15 2020 at 23:47, on Zulip):

You can select Thing, then typing { should wrap it for you in braces, but aside from that I don't think LSP allows you to change that behaviour

matklad (Dec 16 2020 at 07:59, on Zulip):

@Jonas Schievink re-install the extension from source, we accidently ignored the relevant config file in the latest release

matklad (Dec 16 2020 at 07:59, on Zulip):

this is handled by regexes on the client side, which is wrong

matklad (Dec 16 2020 at 08:00, on Zulip):

we should implement this server-side, in principle, but neither VS Code nor LSP have APIs fro that

Jeremy Kolb (Dec 16 2020 at 13:07, on Zulip):

Maybe we should propose something. Actually... I think we could use textDocument/onTypeFormatting since it sends back TextEdit[]

Jeremy Kolb (Dec 16 2020 at 15:15, on Zulip):

In thinking about it more I think we could do this from the server side if we made { a trigger char for type formatting. Alternatively we could kick off a workspace edit from didChange but that would be more complicated.

Last update: Jul 26 2021 at 13:15UTC