RustFmt
Sublime Text plugin that formats Rust code with rustfmt
Details
Installs
- Total 14K
- Win 4K
- Mac 4K
- Linux 5K
| Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | Oct 6 | Oct 5 | Oct 4 | Oct 3 | Oct 2 | Oct 1 | Sep 30 | Sep 29 | Sep 28 | Sep 27 | Sep 26 | Sep 25 | Sep 24 | Sep 23 | Sep 22 | Sep 21 | Sep 20 | Sep 19 | Sep 18 | Sep 17 | Sep 16 | Sep 15 | Sep 14 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Windows | 2 | 0 | 0 | 3 | 2 | 2 | 0 | 1 | 0 | 2 | 0 | 0 | 2 | 2 | 2 | 1 | 3 | 6 | 0 | 3 | 1 | 0 | 3 | 0 | 1 | 1 | 0 | 3 | 3 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 3 | 5 | 6 | 1 | 0 |
| Mac | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 0 | 0 | 1 | 0 | 2 | 0 | 0 | 1 | 0 | 2 | 1 | 0 | 1 | 0 |
| Linux | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 1 | 2 | 3 | 0 | 1 | 2 | 2 | 2 | 0 | 1 | 0 | 0 | 0 | 1 | 2 | 2 | 0 | 2 | 1 | 1 | 2 | 0 | 0 | 1 | 0 | 2 | 3 | 2 | 1 | 0 | 1 | 5 | 2 | 0 | 1 | 2 |
Readme
- Source
- raw.githubusercontent.com
Overview
RustFmt is a Sublime Text 3 plugin that auto-formats Rust code with rustfmt or another executable.
Unlike BeautifyRust, it's fast and works on buffers that have yet not been saved as files. Unlike RustFormat, it preserves the buffer scroll position. It also supports rustfmt.toml.
Dependencies
Requires Sublime Text version 3124 or later.
Requires rustfmt to be on PATH). Installation:
rustup component add rustfmt
Installation
Package Control
- Get Package Control
- Open command palette:
Shift+Super+PorShift+Ctrl+P Package Control: Install PackageRustFmt
Manual
Clone the repo:
git clone https://github.com/mitranim/sublime-rust-fmt.git
Then symlink it to your Sublime packages directory. Example for MacOS:
mv sublime-rust-fmt RustFmt
cd RustFmt
ln -sf "$(pwd)" "$HOME/Library/Application Support/Sublime Text 3/Packages/"
To find the packages directory, use Sublime Text menu → Preferences → Browse Packages.
Usage
By default, RustFmt will autoformat files before saving. You can trigger it
manually with the RustFmt: Format Buffer command in the command palette.
If the plugin can't find the executable:
- run
which rustfmtto get the absolute executable path - set it as the
executablesetting, see Settings below
On MacOS, it might end up like this:
"executable": ["/Users/username/.cargo/bin/rustfmt"]
Can pass additional arguments:
"executable": ["rustup", "run", "nightly", "rustfmt"]
Settings
See RustFmt.sublime-settings for all available settings. To override them, open:
Preferences → Package Settings → RustFmt → Settings
RustFmt looks for settings in the following places:
"RustFmt"dict in general Sublime settings, possibly project-specificRustFmt.sublime-settings, default or user-created
The general Sublime settings take priority. To override them on a per-project basis, create a "RustFmt" entry:
"RustFmt": {
"format_on_save": false
},
Commands
In Sublime's command palette:
RustFmt: Format Buffer
Hotkeys
To avoid potential conflicts, this plugin does not come with hotkeys. To hotkey
the format command, add something like this to your .sublime-keymap:
{
"keys": ["ctrl+super+k"],
"command": "rust_fmt_format_buffer",
"context": [{"key": "selector", "operator": "equal", "operand": "source.rust"}]
}