Skip to content

Commit

Permalink
Multi-scope section headings as entity.name.section
Browse files Browse the repository at this point in the history
On top of "markup.heading". "entity.name.section" with higher priority
because it's the standard scope for heading content.

For most changed themes, it adds color where there was none. Although
it's the same color as option names in most of them.

For ansi it's a regression: goes from one color to the same one as
options. For Solarized it's the opposite, so a net improvement.
  • Loading branch information
victor-gp committed Mar 12, 2022
1 parent 73b2c0f commit c35ebe7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 35 deletions.
11 changes: 8 additions & 3 deletions syntaxes/cmd-help.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ variables:
relaxed_argument_name: '[:alpha:][[:alnum:]_-]*\b'

### scopes (last scope is matched first)
section_heading_scope: &SECTION_HEADING_SCOPE
markup.heading.cmd-help entity.name.section.cmd-help
inline_usage_scope: &INLINE_USAGE_SCOPE
markup.heading.inline-usage.cmd-help entity.name.section.inline-usage.cmd-help
option_argument_scope: &OPTION_ARGUMENT_SCOPE
variable.other.option-argument.cmd-help variable.parameter.option-argument.cmd-help


contexts:
main:
- match: ''
Expand All @@ -52,17 +57,17 @@ contexts:

pre-heading:
- match: '(?i:usage):(?=.+\n)'
scope: markup.heading.inline-usage.cmd-help
scope: *INLINE_USAGE_SCOPE
# only consider lines <= 40 chars long
- match: '^(?=.{1,40}\n)'
set: heading
- include: else-pop

heading:
- match: '{{leading_word}}( {{any_word}})*:?\n'
scope: markup.heading.cmd-help
scope: *SECTION_HEADING_SCOPE
# - match: '{{any_word}}( {{any_word}})*:\n'
# scope: markup.heading.cmd-help
# scope: *SECTION_HEADING_SCOPE
- include: else-pop

def-option:
Expand Down
8 changes: 4 additions & 4 deletions tests/theme/OneHalfDark.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/OneHalfLight.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/Solarized (dark).txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/Solarized (light).txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/TwoDark.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/ansi.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
bat [OPTIONS] [FILE]...
bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
-A, --show-all Show non-printable characters (space, tab, newline, ..).
-p, --plain Show plain style (alias for '--style=plain').
-l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@ OPTIONS:
-h, --help Print this help message.
-V, --version Show version information.

ARGS:
ARGS:
<FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/base16-256.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.
8 changes: 4 additions & 4 deletions tests/theme/base16.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
bat 0.18.2
A cat(1) clone with syntax highlighting and Git integration.

USAGE:
USAGE:
 bat [OPTIONS] [FILE]...
 bat <SUBCOMMAND>

OPTIONS:
OPTIONS:
 -A, --show-all Show non-printable characters (space, tab, newline, ..).
 -p, --plain Show plain style (alias for '--style=plain').
 -l, --language <language> Set the language for syntax highlighting.
Expand Down Expand Up @@ -34,10 +34,10 @@
 -h, --help Print this help message.
 -V, --version Show version information.

ARGS:
ARGS:
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.

SUBCOMMANDS:
SUBCOMMANDS:
 cache Modify the syntax-definition and theme cache

Note: `bat -h` prints a short and concise overview while `bat --help` gives all details.

0 comments on commit c35ebe7

Please sign in to comment.