Stream: t-compiler/rust-analyzer

Topic: multiple snippet edits


Manmeet Mann (Apr 29 2021 at 16:37, on Zulip):

Looks like multiple edits with snippet edits are not supported by vscode, lsp-mode, +maybe more

Manmeet Mann (Apr 29 2021 at 16:40, on Zulip):

I just wanted make extract to function better

fn foo() {
    let x = $0"text"$0;
}

to

fn foo() {
     let x = ${0:fun_name};
}

fn ${0:fun_name}() {
    "text"
}
Jonas Schievink [he/him] (Apr 29 2021 at 16:42, on Zulip):

yeah, this is missing in the LSP unfortunately

Manmeet Mann (Apr 29 2021 at 16:43, on Zulip):

so this is a lsp limitation?

Jonas Schievink [he/him] (Apr 29 2021 at 16:43, on Zulip):

yes

Jonas Schievink [he/him] (Apr 29 2021 at 16:44, on Zulip):

I believe it only supports snippets in completion, not assists

Jonas Schievink [he/him] (Apr 29 2021 at 16:44, on Zulip):

our use of snippets in assists is an extension

Manmeet Mann (Apr 29 2021 at 16:44, on Zulip):

lsp-mode is supporting it too, but only one snippet at a time

Jonas Schievink [he/him] (Apr 29 2021 at 16:45, on Zulip):

yeah, same as our client-side implementation in VS Code

Jonas Schievink [he/him] (Apr 29 2021 at 16:47, on Zulip):

I think in order to fix this, a full client implementation needs to be upstreamed into VS Code, and its editor might need to be changed for that (it only allows using a single TextEdit with multiple snippets, not snippets in multiple TextEdits)

Jonas Schievink [he/him] (Apr 29 2021 at 16:47, on Zulip):

And then the LSP extension should be relatively easy to build on top of that

Manmeet Mann (Apr 29 2021 at 16:47, on Zulip):

I wonder how easy will be hacking this together in emacs :sweat_smile:

Florian Diebold (Apr 29 2021 at 16:55, on Zulip):

this will be pretty complicated if you want to have connected fields between different text edits, I think

Manmeet Mann (Apr 29 2021 at 16:59, on Zulip):

I would assume IntelliJ already has some like this

Jeremy Kolb (Apr 29 2021 at 17:21, on Zulip):

You might be able to get around it with a combination of snippets and textDocument/linkedEditingRange but that would involve a separate request

Last update: Jul 28 2021 at 03:00UTC