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

Rust​Auto​Import

by trishume ST3

Automatically add use statement imports for Rust from ST3

Details

Installs

  • Total 257
  • Win 137
  • OS X 65
  • Linux 55
Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 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
Windows 2 0 0 2 1 1 0 0 1 0 2 0 1 1 0 3 0 2 2 1 0 2 0 0 1 1 2 0 3 1 0 1 1 0 0 2 0 1 0 0 2 1 0 1 0 2
OS X 0 2 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 1 0 0
Linux 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0

Readme

Source
raw.​githubusercontent.​com

Sublime Rust Auto-Import

This is a Sublime Text 3 plugin for automatically creating imports in Rust. It provides the rust_auto_import command which you can bind to a key (or use from the context menu or command pallete). When used with the cursor on an identifier, it automatically uses the (hopefully) correct path at the top of the file.

Features

  • Uses Sublime's index to find the module for items in the current crate
  • Has a pre-programmed list of common std imports like HashMap
    • Even some traits like std::str::From with your cursor on from_str
  • Places new imports under the existing import with the most similar prefix
  • Adds in brackets if an import from that module already exists
  • Adds the old position to the jump stack so you can hit ctrl+- to jump back to where you were

Demo GIF

Demo GIF

Installation

Install RustAutoImport from Package Control.

Then add a keybinding of your choice for the rust_auto_import command, by adding a line like this to your keybindings file:

{ "keys": ["ctrl+a"], "command": "rust_auto_import" },

You can also try it out immediately by choosing “Rust: auto-import” from the context menu or command pallete.

Disclaimers

Feel free to send a PR if you want to fix one of these.

  • Currently uses the 2018 edition import style with no setting to change it
  • Only includes a limited set of standard library includes
  • Uses hacky regexes instead of real parsing
  • Doesn't fully support nested braced imports
  • Can only add to top-level imports not imports in a test module