-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Completing enum variants fills with parentheses #13767
Comments
IMO if snippets aren't enabled we shouldn't be adding any parentheses at all, as we do for function calls; if snippets are enabled, we should still have a setting like for function calls to control whether to add snippets, parentheses or nothing. Or maybe we should just respect the callable snippet setting. For functions this happens here:
note that this function already only gets called if snippets are enabled. The code that would need to be changed is here: rust-analyzer/crates/ide-completion/src/render/variant.rs Lines 45 to 65 in 4596847
|
I definitely agree. I have Thank you very much for the code pointers! I'll try to dive in later today. |
partially addresses rust-lang#13767
Sorry for the delay on this, I finally got some time to look into it. I added a commit that handles the very basic version of what I wanted, but it certainly doesn't cover everything we've talked about. I also couldn't figure out how to update the label on the completion, so it still says "Variant(...)" even though it only completes "Variant" as I wanted. I guess I will need to make the signature of |
I looked more closely and added another commit taking care of the label. I'm now happy with the changes for my use case at least. I think now the only part missing is handling the case with snippets enabled. |
Complete enum variants without parens when snippets are disabled This handles the portion of #13767 that bothered me, but I can try to work on the other parts we discussed if needed.
Currently, enum variants get completed with parentheses inside the variant. This completion also leaves the cursor after the closing parentheses, forcing me to move back into the parentheses, delete everything inside, and then type what I actually want in there.
I would much rather the completion stop at
Enum::Variant
, allowing me to type the parentheses and their contents, or at most, for the completion snippet to leave me inside the parentheses. Could some kind of configuration option be added for this? If someone could point me in the right direction, I would be glad to try to work on this myself too.I initially posted this as an Emacs lsp-mode issue but was pointed over here.
The text was updated successfully, but these errors were encountered: