-
-
Notifications
You must be signed in to change notification settings - Fork 896
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Add #[derive]
" missing from code actions with rust-analyzer
#1907
Comments
[#derive]
" missing from code actions with rust-analyzer#[derive]
" missing from code actions with rust-analyzer
Thank you for detailed report, I will take a look. |
@flodiebold I spent quite some time looking into this issue and in rust analyzer code and it seems like RA is just failing on calculating this quick fix and it is related to something else... |
I think the code action isn't generated because lsp-mode doesn't support the snippet TextEdit extension yet. Most code actions just return a non-snippet edit in that case, but this one doesn't generate, probably because it doesn't make that much sense if it can't position the cursor. |
Thank you for the pointer, I will add support for that. |
proposed fix at #1926 |
I was traveling and couldn't get back to you immediately – thanks for working on this. I just tested yyoncho's proposed fix: I first upgraded lsp-mode to the latest version 20200716.2052 on MELPA, deleted the .elc files and replaced the three files changed in the pull request. I then went through the same steps I originally reported for reproducing the issue. Looks like I'm still not getting the option for adding #[derive], though. |
@miikkas seems like melpa is not picking lsp-mode, the fix was submitted on 0717 but still there is no lsp-mode version with these changes. |
Sorry, I actually meant I applied your patch manually to the latest lsp-mode at the moment of writing my previous comment.
Looks like MELPA just finished with the latest update, and lsp-mode 20200718.1111 is now up. I tried that version now, but the code action for adding #[derive] still wasn't available. I dug around the workspace log from around where rust-analyzer is started and noticed the following under the "capabilities" section: "experimental": {
"snippetTextEdit": [
",",
"lsp-enable-snippet"
]
} Seems like the lsp-enable-snippet variable is not evaluated here: Line 572 in 52d5c94
I tried changing |
@miikkas You just need to change the first quote |
@miikkas sorry about that, I pushed a fix about that - I changed |
Thank you! |
Bug description
Code actions for structs don't have the "Add `#[derive]`" item, which used to be available when using older versions of rust-analyzer. The "Add `#[derive]`" item is available in vscode, though, but I can't seem to get it to appear in Emacs even when using the same version of rust-analyzer as with vscode.
To reproduce
cargo new lsp-ra-bug-repro
C-c l a a
having configured it thus){ |
at the beginning without any text between those characters, none of the actually usable code actions being currently selected:To be clear, pressing RET on that empty item in Ido mode will also yield the same wrong type argument error message.
Expected behavior
An option to "Add `#[derive]`" should be available. Here's how it appears in vscode (the item is highlighted because I had my mouse cursor on it, which isn't visible in the screenshot):
Environment
OS: Ubuntu 20.04
Emacs: GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debian
lsp-mode: 20200713.506 from MELPA (I've also tested on several other versions during the past month)
rust-analyzer: 5ca7cd9 (included with vscode), 4b1c372 (manually built today, 2020-07-13), also several others during the past month
LSP Mode workspace log
I captured this workspace log from pressing
C-c l a a
with the above file open and the cursor where stated in the above reproduction instructions.The text was updated successfully, but these errors were encountered: