Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support snippet text edit #4494

Merged
merged 6 commits into from May 19, 2020
Merged

Support snippet text edit #4494

merged 6 commits into from May 19, 2020

Conversation

matklad
Copy link
Member

@matklad matklad commented May 17, 2020

bors r+
馃

bors bot added a commit that referenced this pull request May 17, 2020
4494: Add AssistConfig r=matklad a=matklad



bors r+
馃

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 17, 2020

Build failed:

@matklad
Copy link
Member Author

matklad commented May 17, 2020

bors r+

bors bot added a commit that referenced this pull request May 17, 2020
4494: Add AssistConfig r=matklad a=matklad



bors r+
馃

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 17, 2020

Build failed:

@matklad
Copy link
Member Author

matklad commented May 17, 2020

bors r+

bors bot added a commit that referenced this pull request May 17, 2020
4494: Add AssistConfig r=matklad a=matklad



bors r+
馃

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 17, 2020

Build failed:

@matklad matklad changed the title Add AssistConfig Support snippet text edit May 17, 2020
@matklad
Copy link
Member Author

matklad commented May 18, 2020

bors r+

bors bot added a commit that referenced this pull request May 18, 2020
4494: Support snippet text edit r=matklad a=matklad



bors r+
馃

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 18, 2020

Build failed:

// We intentionally don't support command-based actions, as those either
// requires custom client-code anyway, or requires server-initiated edits.
// Server initiated edits break causality, so we avoid those as well.
if !world.config.client_caps.code_action_literals {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @kjeremy

I think, given that pure commands require us to implement client-specific logic anyway, I figured that we might as well just not support them? This is related to the caps PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's only true until we support workspace/executeCommand.

Copy link
Member Author

@matklad matklad May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's only true until we support workspace/executeCommand.

I personally think that we should not support this :-) The only command that the server can execute is sending workspace edit to the client, but that's strictly worse than just sending it with edit.

Ie, I think it is confirming to the protocol and a good tradeoff to just not support clients that can do commands with edits.

@matklad
Copy link
Member Author

matklad commented May 19, 2020

bors r+

bors bot added a commit that referenced this pull request May 19, 2020
4494: Support snippet text edit r=matklad a=matklad



bors r+
馃

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 19, 2020

Canceled.

@matklad
Copy link
Member Author

matklad commented May 19, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented May 19, 2020

@bors bors bot merged commit 1bc1f28 into rust-lang:master May 19, 2020
@matklad matklad deleted the snippets branch May 19, 2020 18:57
```

When applying such code action, the editor should insert snippet, with tab stops and placeholder.
At the moment, rust-analyzer guarantees that only a single edit will have `InsertTextFormat.Snippet`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @fannheyward @brotzeit, we are going to replace rust-analyzer.applySourceChange command with something which hopefully will make it into the procotol.

Specifically, if client does not specify experimental.snippetTextEdit, we'll use just the stock CodeActions with edits.

If client sets this capablity though, we will be sending snippets in edits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #4604 as a more structured way to send pings :D

@fannheyward
Copy link
Contributor

coc-rust-analyzer has added snippet text edit support. fannheyward/coc-rust-analyzer#252, anyone can give this a test?

fannheyward added a commit to fannheyward/coc-rust-analyzer that referenced this pull request May 25, 2020
* feat(cmds): support snippet text edit

rust-lang/rust-analyzer#4494

* feat(cmds): improve snippet text edit

* feat(cmds): snippet textedit
keeneyetact added a commit to keeneyetact/rust-see that referenced this pull request May 9, 2023
* feat(cmds): support snippet text edit

rust-lang/rust-analyzer#4494

* feat(cmds): improve snippet text edit

* feat(cmds): snippet textedit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants