Prettier Not Working for Rust Visual Studio Code

1.3k Views Asked by At

I installed the Rust Prettier extension: https://github.com/jinxdash/prettier-plugin-rust but it is not formatting my rust files when I save.

I see this icon in VS Code in the Status Bar at the bottom-right indicating that Prettier is disabled when I click on a rust file: prettier disablied

This is usually what it looks like for me like if I click on a JavaScript file: enter image description here

I also ran npm install --global prettier-plugin-rust prettier per the docs.

This is just showing the VS Code extension I've installed: enter image description here

From VS Code Output

["INFO" - 10:35:08 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 10:35:08 PM] Extension Version: 9.10.3.

What's going on? Why is Prettier disabled on Rust files?

Could Rust files need to be enabled in the VS Code or Prettier settings?

Please let me know if I am missing any relevant information in the comments, thank you.

1

There are 1 best solutions below

1
On

Add this to settings.json

{
    "[rust]": {
        "editor.formatOnPaste": true,
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "jinxdash.prettier-rust"
    }
}