-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Feature Request] format range support #7580
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
Comments
I'd consider it a UX issue or misconfiguration in coc.nvim that it tries to do this when it's not supported. That said, in principle I think range formatting is something we should support; I'm not sure what the status of that in rustfmt is though. If it's supported by rustfmt by now, it shouldn't be too hard to implement. Otherwise it will have to wait for our own formatting infrastructure (#1665 / #4182). |
Rustfmt has experimental support for range formatting on the nightly channel:
|
I wonder if it would be possible to do some processing on selected syntax to make it valid rust syntax and then run it through rustfmt as if it was a file and at the end strip off the added syntax. At first glance, the processing needed would be to expand or shrink the selection to a valid let a=2; With fn fmt_dummy_name() {
a=2
} -> rustfmt fn fmt_dummy_name() {
a = 2
} -> a = 2 This may be a bit hacky, but it works on stable 😁. Of course ra-format or rustfmt support would be better. |
I keep getting this error messages recently. It seems RA will send
formatSelected
notification when the width of current line becomes greater thanrustfmt.toml
'smax_width
.And in this case coc.nvim throw out an error that RA doesn't support range formatting.
I'm wondering if it's possible to support range formatting in RA? Or shall I consider this as a coc.nvim's UX issue?
The text was updated successfully, but these errors were encountered: