RustFmt
Sublime Text plugin that formats Rust code with rustfmt
Details
Installs
- Total 12K
- Win 4K
- Mac 4K
- Linux 5K
Jul 26 | Jul 25 | Jul 24 | Jul 23 | Jul 22 | Jul 21 | Jul 20 | Jul 19 | Jul 18 | Jul 17 | Jul 16 | Jul 15 | Jul 14 | Jul 13 | Jul 12 | Jul 11 | Jul 10 | Jul 9 | Jul 8 | Jul 7 | Jul 6 | Jul 5 | Jul 4 | Jul 3 | Jul 2 | Jul 1 | Jun 30 | Jun 29 | Jun 28 | Jun 27 | Jun 26 | Jun 25 | Jun 24 | Jun 23 | Jun 22 | Jun 21 | Jun 20 | Jun 19 | Jun 18 | Jun 17 | Jun 16 | Jun 15 | Jun 14 | Jun 13 | Jun 12 | Jun 11 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 1 | 2 | 3 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 3 | 2 | 2 | 1 | 2 | 2 | 3 | 0 | 2 | 2 | 2 | 0 | 3 | 4 | 4 | 3 | 2 | 3 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 2 |
Mac | 2 | 3 | 0 | 3 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 2 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 2 | 3 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 3 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 2 | 0 | 1 | 1 |
Linux | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 1 | 1 | 2 | 2 | 0 | 3 | 2 | 2 | 1 | 1 | 0 | 3 | 0 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 0 | 2 | 1 | 5 | 0 | 0 | 2 | 1 | 1 | 2 | 1 | 2 | 0 | 1 | 2 | 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+P
orShift+Ctrl+P
Package Control: Install Package
RustFmt
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 rustfmt
to get the absolute executable path - set it as the
executable
setting, 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"}]
}