blob: 6a711c0171aebb99078b65ccb5a70629e7338629 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# Running Rustfmt from IntelliJ or CLion
## Installation
- Install [CLion](https://www.jetbrains.com/clion/), [IntelliJ Ultimate or CE](https://www.jetbrains.com/idea/) through the direct download link or using the [JetBrains Toolbox](https://www.jetbrains.com/toolbox/).
CLion and IntelliJ Ultimate [provide a built-in debugger interface](https://github.com/intellij-rust/intellij-rust#compatible-ides) but they are not free like IntelliJ CE.
- Install the [Rust Plugin](https://intellij-rust.github.io/) by navigating to File → Settings → Plugins and searching the plugin in the Marketplace

- Press "Install" on the Rust plugin

- Restart CLion/IntelliJ
## Configuration
### Run Rustfmt on save
- Open Rustfmt settings (File → Settings → Languages & Frameworks → Rust → Rustfmt) and enable "Run rustfmt on Save"

- IntellJ uses autosave, so now your files will always be formatted according to rustfmt. Alternatively you can use Ctrl+S to reformat file manually
### Bind shortcut to "Reformat File with Rustfmt" action
- Open the settings window (File → Settings) and search for "reformat"

- Right-click on "Reformat File with Rustfmt" and assign a keyboard shortcut

- Press "OK"

- Done. You can now use rustfmt in an opened *.rs file with your previously specified shortcut
|