Skip to content

Commit 65a5c32

Browse files
ehussjasonwilliams
authored andcommitted
Add compiler suggestions and message themes. (#267)
1 parent eb7783f commit 65a5c32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1502
-659
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ It is possible that the built-in `Rust` package will cause conflicts with Rust E
3030
## Features
3131
### Go To Definition
3232
### Cargo Build
33-
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.
33+
Rust Enhanced has a custom build system tailored for running Cargo. It will display errors and warnings in line using Sublime's phantoms (see [Messages](docs/messages.md) for settings to control how messages are displayed). It also supports a variety of configuration options to control how Cargo is run.
3434

3535
![testingrust](https://cloud.githubusercontent.com/assets/43198/22944409/7780ab9a-f2a5-11e6-87ea-0e253d6c40f6.png)
3636

@@ -119,7 +119,7 @@ To customize the settings, use the command from the Sublime menu:
119119
Additionally, you can customize settings per-project by adding settings to your `.sublime-project` file under the `"settings"` key.
120120

121121
## Development
122-
Development is quite simple, just check out this project to your Sublime Text 3 packages folder, and switch to using this one.
122+
Development is quite simple, just check out this project to your Sublime Text 3 packages folder, and switch to using this one.
123123
Syntax definitions are defined in the `RustEnhanced.sublime-syntax` file.
124124

125125
## Credits

RustEnhanced.sublime-settings

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// If true, will not display warning messages.
1515
"rust_syntax_hide_warnings": false,
1616

17-
// Color of messages.
17+
// Color of messages for "clear" theme.
1818
// These use CSS colors. See
1919
// https://www.sublimetext.com/docs/3/minihtml.html for more detail.
2020
"rust_syntax_error_color": "var(--redish)",
@@ -46,6 +46,11 @@
4646
// "none" - Do not place icons in the gutter.
4747
"rust_gutter_style": "shape",
4848

49+
// Style for displaying inline messages. Can be:
50+
// "clear" - Clear background with colors matching your color scheme.
51+
// "solid" - Solid background color.
52+
"rust_message_theme": "clear",
53+
4954
// If your cargo project has several build targets, it's possible to specify mapping of
5055
// source code filenames to the target names to enable syntax checking.
5156
// "projects": {

cargo_build.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import functools
44
import sublime
55
import sublime_plugin
6+
import sys
67
from .rust import (rust_proc, rust_thread, opanel, util, messages,
78
cargo_settings, target_detect)
89
from .rust.cargo_config import *
@@ -486,3 +487,34 @@ def is_applicable(cls, settings):
486487
def on_hover(self, point, hover_zone):
487488
if util.get_setting('rust_phantom_style', 'normal') == 'popup':
488489
messages.message_popup(self.view, point, hover_zone)
490+
491+
492+
class RustAcceptSuggestedReplacement(sublime_plugin.TextCommand):
493+
494+
"""Used for suggested replacements issued by the compiler to apply the
495+
suggested replacement.
496+
"""
497+
498+
def run(self, edit, region, replacement):
499+
region = sublime.Region(*region)
500+
self.view.replace(edit, region, replacement)
501+
502+
503+
def plugin_unloaded():
504+
messages.clear_all_messages()
505+
try:
506+
from package_control import events
507+
except ImportError:
508+
return
509+
package_name = __package__.split('.')[0]
510+
if events.pre_upgrade(package_name):
511+
# When upgrading the package, Sublime currently does not cleanly
512+
# unload the `rust` Python package. This is a workaround to ensure
513+
# that it gets completely unloaded so that when it upgrades it will
514+
# load the new package. See
515+
# https://github.com/SublimeTextIssues/Core/issues/2207
516+
re_keys = [key for key in sys.modules if key.startswith(package_name + '.rust')]
517+
for key in re_keys:
518+
del sys.modules[key]
519+
if package_name in sys.modules:
520+
del sys.modules[package_name]

changelog/2.11.0.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Rust Enhanced 2.11.0
2+
3+
You must restart Sublime after installing this update.
4+
5+
## New Features
6+
- Added `"rust_message_theme"` configuration setting for choosing different
7+
styles of inline messages. Currently two options are available: "clear" and
8+
"solid". See
9+
https://github.com/rust-lang/rust-enhanced/blob/master/docs/build.md#general-settings
10+
for examples.
11+
12+
- If the Rust compiler provides a suggestion on how to fix an error, the
13+
inline messages now include a link that you can click to automatically apply
14+
the suggestion.
15+
16+
## Syntax Updates
17+
- Support u128/i128 integer suffix.

docs/build.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ The Rust Enhanced build system provides an interface for running Cargo. It can
44
show inline warning and error messages. It also has a variety of ways of
55
configuring options for how Cargo is run.
66

7+
See [Messages](messages.md) for settings to control how compiler messages are
8+
displayed.
9+
710
## Usage
811

912
When Sublime is set to use "Automatic" build system detection, it will choose
@@ -42,28 +45,6 @@ Document | <code>cargo&nbsp;doc</code> | Builds package documentation.
4245
Clippy | <code>cargo&nbsp;clippy</code> | Runs [Clippy](https://github.com/Manishearth/rust-clippy). Clippy must be installed, and currently requires the nightly toolchain.
4346
Script | <code>cargo&nbsp;script&nbsp;$path</code> | Runs [Cargo Script](https://github.com/DanielKeep/cargo-script). Cargo Script must be installed. This is an addon that allows you to run a Rust source file like a script (without a Cargo.toml manifest).
4447

45-
## General Settings
46-
47-
General settings (see [Settings](../README.md#settings)) for how messages are displayed are:
48-
49-
| Setting | Default | Description |
50-
| :------ | :------ | :---------- |
51-
| `rust_syntax_hide_warnings` | `false` | If true, will not display warning messages. |
52-
| `rust_syntax_error_color` | `"var(--redish)"` | Color of error messages. |
53-
| `rust_syntax_warning_color` | `"var(--yellowish)"` | Color of warning messages. |
54-
| `rust_syntax_note_color` | `"var(--greenish)"` | Color of note messages. |
55-
| `rust_syntax_help_color` | `"var(--bluish)"` | Color of help messages. |
56-
| `rust_phantom_style` | `"normal"` | How to display inline messages. Either `normal`, `popup`, or `none`. |
57-
| `rust_region_style` | `"outline"` | How to highlight messages. Either `outline` or `none`. |
58-
| `rust_gutter_style` | `"shape"` | Type of icon to show in the gutter. Either `shape`, `circle`, or `none`. |
59-
60-
It also supports Sublime's build settings:
61-
62-
| Setting | Default | Description |
63-
| :------ | :------ | :---------- |
64-
| `show_errors_inline` | `true` | If true, messages are displayed in line using Sublime's phantoms. If false, messages are only displayed in the output panel. |
65-
| `show_panel_on_build` | `true` | If true, an output panel is displayed at the bottom of the window showing the compiler output. |
66-
6748
## Cargo Settings
6849

6950
A variety of settings are available to customize how Cargo is run. These

docs/img/messages_popup.gif

14.2 KB
Loading

docs/img/region_style_none.png

2.51 KB
Loading

docs/img/region_style_outline.png

2.56 KB
Loading

docs/img/show_errors_inline_false.png

16 KB
Loading

docs/img/show_errors_inline_true.png

11.5 KB
Loading

0 commit comments

Comments
 (0)