rust-analyzer
rust-analyzer copied to clipboard
RustAnalzyer as rust formatter in vscode
Reproduce step
- open vs code
- copy and paste to new file (ctrl+n)
- make sure that selected language is rust in right bottom.
- run format (alt+shift+t)
Expected result
- format with rustfmt by rust-analzyer extension
Actual result
vscode doesn't think rust-analzyer is rust formatter.
The previous, deprecated Rust extension supported this formatting. So I hope rust analzyer do this too.
Rust analyzer does support formatting without requiring any configuration. The only times I have seen that error is when rust-analyzer crashed. Could you check the rust analyzer logs in the output pane to see if it crashed?
Rust analzyer is working with other files which I already saved.
I mean, when that error occurred , I didn't saved the file and just opened new file and then just run format.
Also, I couldn't find rust analzyer in vscode extensions marketplace with search category:formatters rust
Here is the video about error.
https://user-images.githubusercontent.com/3580430/181212560-0d230d4f-3dfc-4ba4-8f23-cc18a9029760.mp4
There are no output of Rust Analzyer Language Server and Rust Analzyer Client when I run format this time.
r-a doesn't have the formatters
tag on the marketplace so that is being filter out by that query
You are using the Rust (rust-lang.rust) extension? You need the rust-analyzer (rust-lang.rust-analyzer) extension. Don't search for the formatting category. The rust-analyzer extension doesn't have this category listed.
Ah, the issue is that you are trying to format a file that is not yet on disk, can reproduce that error then. Note that r-a doesn't work at all in files that are not part of the workspace.
You are using the Rust (rust-lang.rust) extension? You need the rust-analyzer (rust-lang.rust-analyzer) extension. Don't search for the formatting category. The rust-analyzer extension doesn't have this category listed.
I didn't search with that category, vscode suggested to me when I press install formatter...
button on error alert.
Ah, the issue is that you are trying to format a file that is not yet on disk, can reproduce that error then. Note that r-a doesn't work at all in files that are not part of the workspace.
That's what i'm saying exactly. Is it intended? There are no plan to support formatting a file which is not yet on disk?
I believe we should be able to support formatting non-indexed files, will have to check but it sounds like something that should be doable since we already format files be feeding rustfmt the source manually.
I just ran into this problem. rust-analyzer
was disabled when I hit "format file", and it didn't show up when I clicked "Install formatter..."
The top of the list is the deprecated Rust extension, much like @namse reported.