Skip to content

Commit

Permalink
Clean up settings handling (#140)
Browse files Browse the repository at this point in the history
- Use sublime_lib.NamedSettingsDict to handle settings
- apart from `trailing_spaces_highlight_color` which has special handling,
  get all options directly from settings so that they are always up-to-date
  with user preferences. Previously settings were only read on init.
- remove `trailing_spaces_` prefixes from settings. Settings with prefixes
   are still respected for backward-compatibility.
  • Loading branch information
rchl authored Apr 27, 2020
1 parent ea3ff98 commit 820c18f
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 127 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.mypy_cache
TODO.md
*.pyc
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ You may change the highlighting color, providing a color scope name such as
"error", "comment"… just like that:

``` js
{ "trailing_spaces_highlight_color": "comment" }
{ "highlight_color": "comment" }
```

The scope should be defined in your current theme file. Here is a dummy,
Expand Down Expand Up @@ -164,7 +164,7 @@ You can make trailing spaces "invisible" yet still rely on the deletion
command. To do that, set the highlight scope to an empty string:

``` js
{ "trailing_spaces_highlight_color": "" }
{ "highlight_color": "" }
```

Beware: this is **not** the same as *disabling* the highlighting (see "On-
Expand All @@ -181,7 +181,7 @@ each time you are about to start a new word, the space you type is matched as
a trailing spaces. Currently edited line can thus be ignored:

``` js
{ "trailing_spaces_include_current_line": false }
{ "include_current_line": false }
```

Even though the trailing spaces are not highlighted on this line, they are
Expand All @@ -195,7 +195,7 @@ When firing the deletion command, empty lines are matched as trailing regions,
and end up being deleted. You can specifically ignore them:

``` js
{ "trailing_spaces_include_empty_lines": false }
{ "include_empty_lines": false }
```

They will not be highlighted either.
Expand All @@ -216,7 +216,7 @@ regions. You may either:
- specify as a setting:

``` js
{ "trailing_spaces_modified_lines_only": true }
{ "modified_lines_only": true }
```

There is also a command to toggle this feature on and off. You may thus define
Expand All @@ -234,7 +234,7 @@ Setting this to `true` will ensure trailing spaces are deleted when you save
your document. It abides by the other settings, such as *Modified Lines Only*.

``` js
{ "trailing_spaces_trim_on_save": true }
{ "trim_on_save": true }
```

### Save After Trim
Expand All @@ -246,7 +246,7 @@ around could prove useful. Setting this to `true` will automatically save your
document after you fire the deletion command:

``` js
{ "trailing_spaces_save_after_trim": true }
{ "save_after_trim": true }
```

It is obviously ignored if *Trim On Save* is on.
Expand All @@ -265,7 +265,7 @@ to cause slowness (for instance, you already installed several *heavy*
plugins), you can disable live matching:

``` js
{ "trailing_spaces_enabled": false }
{ "enabled": false }
```

In this case, for no trailing regions are matched until you request them to be
Expand All @@ -291,7 +291,7 @@ By default, the scope under the mouse cursor is shown by pressing

``` js
// Trailing spaces for find results, build output and markdown are ignored
{ "trailing_spaces_scope_ignore": ["text.find-in-files", "source.build_output", "text.html.markdown"] }
{ "scope_ignore": ["text.find-in-files", "source.build_output", "text.html.markdown"] }
```

### For power-users only!
Expand All @@ -303,7 +303,7 @@ The default threshold is around 1 million of characters. This is
configurable (in "File Settings - User") and the unit is number of chars:

``` js
{ "trailing_spaces_file_max_size": 1000}
{ "file_max_size": 1000}
```

#### The matching pattern
Expand All @@ -316,7 +316,7 @@ to abide by another definition to cover edge-cases, go ahead:

``` js
// *danger* will match newline chars and many other folks
"trailing_spaces_regexp": "[\\s]+"
"regexp": "[\\s]+"
```

About Sublime Text's built-in features
Expand Down
7 changes: 7 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"*": {
"*": [
"sublime_lib"
]
}
}
Loading

0 comments on commit 820c18f

Please sign in to comment.