ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Rust​Fmt

by Nelo Mitranim ST3

Sublime Text plugin that formats Rust code with rustfmt

Labels rust, fmt, format, beautify

Details

Installs

  • Total 2K
  • Win 488
  • OS X 527
  • Linux 568
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 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11
Windows 2 0 4 2 1 2 1 0 1 0 1 0 0 3 3 2 0 4 0 0 3 0 0 1 2 0 2 0 3 2 0 1 3 1 6 2 2 1 2 4 5 4 0 3 3 3
OS X 0 3 1 4 3 1 0 0 3 0 2 4 1 1 5 0 2 0 2 3 4 1 0 0 3 1 0 3 3 0 1 3 0 2 3 6 3 5 0 1 2 3 3 1 0 1
Linux 1 2 4 2 2 1 1 0 4 1 0 3 1 2 2 6 2 0 1 2 1 0 4 1 1 2 5 1 1 4 4 6 3 3 4 2 2 1 2 4 0 3 2 2 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). Install it with Cargo:

cargo install rustfmt

Installation

Package Control

  1. Get Package Control
  2. Open command palette: Shift+Super+P or Shift+Ctrl+P
  3. Package Control: Install Package
  4. RustFmt

Manual

  1. Open Sublime Text menu → Preferences → Browse Packages. This should open the packages folder in your OS file manager.

  2. Clone repo:

git clone https://github.com/Mitranim/sublime-rust-format.git RustFmt

Usage

By default, RustFmt will autoformat files before save. You can trigger it manually with the Ctrl+Super+k hotkey or 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 my MacOS system, the path looks like this:

Error: language “sublime-settings” is not supported
"executable": "/Users/username/.cargo/bin/rustfmt"

executable also accepts a list of command line arguments:

Error: language “sublime-settings” is not supported
"executable": ["rustup", "run", "nightly", "rustfmt"]

Settings

See RustFmt.sublime-settings for all available settings. To see and override the settings in Sublime, open:

Preferences → Package Settings → RustFmt → Settings

RustFmt looks for settings in the following places:

  • "RustFmt" dict in general Sublime settings, possibly project-specific
  • RustFmt.sublime-settings, default or user-created

The general Sublime settings take priority. To override them on a per-project basis, create a "RustFmt" entry:

Error: language “sublime-settings” is not supported
"RustFmt": {
    "format_on_save": false
  }

Commands

Open the command palette with Shift+Super+P or Shift+Ctrl+P.

  • RustFmt: Format Buffer (Ctrl+Super+k)