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

Rust Enhanced

by rust-lang ST3

The official Sublime Text 3 package for the Rust Programming Language

Details

Installs

  • Total 49K
  • Win 16K
  • OS X 17K
  • Linux 15K
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 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10
Windows 4 13 11 12 10 10 11 11 4 18 20 24 6 1 4 9 6 3 9 2 7 9 6 7 10 5 4 4 6 3 7 9 6 5 3 2 6 5 10 8 9 4 4 10 5 13
OS X 8 10 15 9 8 12 8 12 6 18 28 28 4 4 4 6 7 3 3 4 3 5 7 6 10 6 1 2 1 2 5 8 7 10 7 6 4 6 3 6 11 5 3 5 11 5
Linux 9 9 7 8 17 21 6 14 14 14 24 32 5 8 8 7 9 8 10 9 9 8 12 13 6 7 6 3 9 9 7 5 11 5 9 2 9 12 7 10 8 6 6 4 6 6

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.

As of version 1.0.0 this package will no longer support Sublime Text 2. At the time of writing, ST3 is almost reaching stable, and we recommend migrating to that version if you need Rust Support.

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. 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 should override the default Rust within Sublime. Syntax changes which happen here will eventually be pushed upstream into Sublime Core Packages repo, but extra features will stay here.

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

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).

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"
           }
       }
   }

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

The files are written in the JSON format supported by the Sublime Text package AAAPackageDev, because the format is much easier to read / edit than the xml based plist format.

So install that package and then work on the .JSON-* files. There is a build system that comes with that package, so if everything is set up right, you should just be able to trigger the build (F7) and get the corresponding .tmLanguage / .tmPreferences files. It will also display errors if you have not formatted the file correctly.

One impact of using this indirect format is that you usually have to double escape anything in the match patterns, ie, “\(” has to be “\(” as otherwise it will try to interpret '\(' as a JSON escape code (which doesn't exist).

We have just moved to the new .sublime-syntax file, which only supports ST3 and upwards. Any PR's should be updating this file and not the old tmLanguage 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.