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 45K
  • Win 15K
  • OS X 16K
  • Linux 14K
Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9
Windows 0 9 8 10 13 7 12 4 8 9 16 5 9 13 8 9 14 8 16 11 11 7 6 15 8 8 10 7 12 16 13 5 4 9 6 11 11 10 10 12 6 13 11 12 8 17
OS X 0 9 6 8 14 3 12 9 4 8 5 8 8 9 4 7 5 12 7 6 12 7 5 11 4 7 9 12 7 9 3 4 7 12 9 9 9 10 8 11 6 11 7 13 10 11
Linux 0 11 3 15 16 4 13 2 6 12 11 11 9 9 4 14 12 14 11 2 11 6 7 11 13 13 7 6 9 7 7 8 9 10 11 6 6 14 5 12 8 16 13 6 10 5

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.

Features

Go To Definition

Build functionality

Rust Enhanced has the following build functions: - Cargo Run - Cargo Script Cargo Script is needed - Cargo Test - Cargo Bench - Cargo Clean - Cargo Release - Cargo Document - Cargo Clippy - Rust - Rust Run

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. This relies on Cargo and Rust (>= 1.8.0) being installed and on your system path. Plus Sublime Text >= 3118.

There are a variety of settings (see Settings) for controlling the syntax highlighting:

Setting Default Description
rust_syntax_checking true Enable the on-save syntax checking.
rust_syntax_checking_include_tests true Enable checking of test code within #[cfg(test)] sections.
rust_syntax_hide_warnings false If true, will not display warning messages.
rust_syntax_error_color "#F00" Color of error messages.
rust_syntax_warning_color "#FF0" Color of warning messages.

Here is an example: testingrust

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

You can customize the behaviour of sublime-rust by creating a settings file in your User package. This can be accessed from within SublimeText by going to the menu Preferences > Browse Packages…. Create a file named Rust.sublime-settings or alternatively copy the default settings file Packages/sublime-rust/Rust.sublime-settings to your User package and edit it to your liking.

Note: File names are case-sensitive on some platforms (e.g. Linux) so the file name should be exactly Rust.sublime-settings with capitalization preserved.

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.