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

Rust Enhanced

by rust-lang ST3 Trending

The official Sublime Text 3 package for the Rust Programming Language

Details

Installs

  • Total 52K
  • Win 17K
  • OS X 18K
  • Linux 16K
Jan 20 Jan 19 Jan 18 Jan 17 Jan 16 Jan 15 Jan 14 Jan 13 Jan 12 Jan 11 Jan 10 Jan 9 Jan 8 Jan 7 Jan 6 Jan 5 Jan 4 Jan 3 Jan 2 Jan 1 Dec 31 Dec 30 Dec 29 Dec 28 Dec 27 Dec 26 Dec 25 Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6
Windows 4 20 25 30 10 8 8 8 15 15 9 9 7 6 7 3 8 5 8 4 6 9 10 13 15 6 6 9 4 10 8 11 11 7 13 10 15 10 9 4 14 10 9 14 10 6
OS X 6 11 22 21 12 10 4 8 3 10 5 8 3 9 7 13 8 8 7 5 6 5 3 7 11 10 11 6 11 7 11 10 7 12 6 10 13 10 3 4 15 9 15 12 15 5
Linux 5 24 25 38 12 5 18 15 10 5 9 8 12 10 5 14 9 7 10 4 10 13 12 10 10 9 12 10 9 7 7 11 8 6 16 7 6 11 11 17 16 13 8 16 10 12

Readme

Source
raw.​githubusercontent.​com

Rust Enhanced

About

This is a Sublime Text 3 package which supports Rust starting with version 1.0, it makes no attempt at supporting earlier incompatible versions.

This package used to be called 'Rust', but as of version 3, Sublime now comes with Rust built-in. The built-in version on Sublime is actually just a snapshot of this package with some fixes from quite some time ago. This package is still active and will continue to update and release, so if you want up to date features, and extra tools (such as syntax checking or building) we recommend using this package. It does not automatically override the built-in Rust package so you will have to disable it, and check “Rust Enhanced” is set. There is currently no plan to push upstream changes back into the Sublime Core Packages repo, and extra features will stay here.

For syntax highlighting for Cargo files. Its recommended installing this with the TOML package.

Running Tests with Rust EnhancedHighlighting errors and warnings with Rust Enhanced

Installation

Install the Package Control package if you haven't got it yet. Package Control is the best way to install packages for Sublime Text. See http://wbond.net/sublime_packages/package_control/installation for instructions.

Open the palette (control+shift+P or command+shift+P) in Sublime Text and select Package Control: Install Package and then select Rust Enhanced from the list. That's it. If you can't see Rust Enhanced its most likely because you're using Sublime Text 2.

It is possible that the built-in Rust package will cause conflicts with Rust Enhanced. If the default syntax for Rust documents is Rust instead of Rust Enhanced, then this is likely the case. A recommended solution is to disable the built-in Rust package. You can do so through Package Control: Disable Package -> Rust.

Features

Go To Definition

Cargo Build

Rust Enhanced has a custom build system tailored for running Cargo. It will display errors and warnings in line using Sublime's phantoms. It also supports a variety of configuration options to control how Cargo is run.

testingrust

See the build docs for more information.

Cargo tests with highlighting

Thanks to urschrei we have Highlighting for: - passed test - failed test - failed test source line (clickable) - total number of passed tests - total number of failed tests > 0 - total number of ignored tests > 0 - total number of measured tests > 0

Example:

highlight_rust_test

Syntax Checking

Rust Enhanced will automatically perform syntax checking each time you save a file. Errors and warnings are displayed in line the same way as the build system. This relies on Cargo and Rust (>= 1.8.0) being installed and on your system path. Plus Sublime Text >= 3118.

Settings for controlling the on-save syntax checking:

Setting Default Description
rust_syntax_checking true Enable the on-save syntax checking.
rust_syntax_checking_method "check" The method used for checking your code (see below).
rust_syntax_checking_include_tests true Enable checking of test code within #[cfg(test)] sections (only for no-trans method).
rust_syntax_hide_warnings false Don't show warnings when syntax checking

The available checking methods are:

Method Description
no-trans Runs the rustc compiler with the -Zno-trans option. This will be deprecated soon, however it has the benefit of supporting #[test] sections.
check Uses cargo check (requires at least Rust 1.16).
clippy Uses cargo clippy. This requires Clippy to be installed. This also may be a little slower since it must check every target in your package.

This will use the same configuration options as the “Check” and “Clippy” build variants (for example, extra environment variables, or checking with different features). See the build docs for more information.

Projects with multiple build targets are supported too (–lib, –bin, –example, etc.). If a cargo project has several build targets, it will attempt to automatically detect the correct target. In some rare cases, you may need to manually specify which target a file belongs to. This can be done by adding a “projects” setting in Rust.sublime-settings with the following format:

"projects": {
       // One entry per project. Keys are project names.
       "my_cool_stuff": {
           // Path to the project root dir without trailing /src.
           "root": "/path/to/my/cool/stuff/project",

           // Targets will be used to replace {target} part in the command.
           // If no one target matches an, empty string will be used.
           "targets": {
               "bin/foo.rs": "--bin foo",  // format is "source_code_filename -> target_name"
               "bin/bar.rs": "--bin bar",
               "_default": "--lib"         // or "--bin main"
           }
       }
   }

RLS

RLS (Rust Language Server) Support is experimental and won't be available just yet.
This is because the RLS Server is still in Alpha and the Sublime LSP plugin is work in progress. However, if you are interested in playing with RLS early, here are the steps.
* Setup Rust Language Server - Instructions here https://github.com/rust-lang-nursery/rls * Check its ready to use by running rustup run nightly rls --version if you get a version back its up and running. * Now install LSP https://github.com/tomv564/LSP (follow the git install option if it doesn't work from package control) * Once you’ve got LSP installed, go Sublime preferences —> Package settings —> LSP , and paste this into user settings (the right-hand pane): https://gist.github.com/urschrei/b0427f513dc78a9e32329e4bc8a65846 Soon this step won't be needed once our changes are merged in. * Once LSP is installed, enable it for Rust using LSP: Enable Language Server Globally | Project * You should see rls initialized in the status bar at the bottom, it should be working at this point.

Context Menu

The Sublime context menu includes a Rust entry with a variety of commands. See context menu docs for more information.

Settings

To customize the settings, use the command from the Sublime menu:

Preferences > Package Settings > Rust Enhanced > Settings - User

Additionally, you can customize settings per-project by adding settings to your .sublime-project file under the "settings" key.

Development

Development is quite simple, just check out this project to your Sublime Text 3 packages folder, and switch to using this one.
Syntax definitions are defined in the RustEnahcned.sublime-syntax file.

Credits

Created 2012 by Daniel Patterson, as a near complete from scratch rewrite of a package by Felix Martini.

This project is currently maintained by Jason Williams

License

This package is licensed under the MIT License.