currenthandle
currenthandle

Reputation: 1316

Prettier Not Working for Rust Visual Studio Code

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.

Upvotes: 1

Views: 2586

Answers (1)

NOP da CALL
NOP da CALL

Reputation: 931

Add this to settings.json

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

Upvotes: 5

Related Questions