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

  • 0.1.3
  • github.​com
  • github.​com
  • 4 months ago
  • 15 minutes ago
  • 5 months ago

Installs

  • Total 525
  • Win 174
  • OS X 164
  • Linux 187
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 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7
Windows 2 0 1 1 2 1 3 5 2 0 1 0 2 2 3 1 0 0 1 1 0 0 1 3 0 1 4 4 1 2 0 2 2 1 0 2 0 4 1 4 1 1 1 0 0 0
OS X 0 2 0 2 0 4 1 1 4 5 1 1 2 3 6 2 2 2 0 1 4 0 2 0 2 2 3 3 1 2 1 3 0 1 1 3 3 2 0 5 0 0 1 2 1 0
Linux 2 0 2 2 1 0 1 2 0 3 1 0 5 5 5 2 4 2 5 3 0 1 0 3 0 0 0 1 1 1 0 4 5 4 2 2 3 1 8 1 2 1 1 1 0 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.

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, open Preferences -> Package Settings -> RustFmt -> Settings. Run which rustfmt and set the resulting path as the executable setting. On my MacOS system, the path looks like this:

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

The executable setting accepts either a string (as before) or a list of command line arguments:

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

Commands

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

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

Settings

Open Sublime Text menu -> Preferences -> Package Settings -> RustFmt -> Settings.

Error: language “sublime-settings” is not supported
{
  // Format files automatically when saving
  "format_on_save": true,
  // Path to formatter executable; set to absolute path if plugin can't find it
  "executable": "rustfmt"
}