Skip to content

Commit

Permalink
Try to get all themes to colorize arguments
Browse files Browse the repository at this point in the history
This is a failed attempt to get option arguments colorized for all
themes by multi-scoping them with variable.other.

It's a failed attempt because it seems those themes that don't color
variable.parameter, it's not that they don't target the scope but that
they set it same as their default foreground color...

I'm committing this because I think the new architecture for declaring
scopes in an anchor and reusing that everywhere can be useful for future
attempts.

I didn't bother to change syntax tests though.
  • Loading branch information
victor-gp committed Mar 12, 2022
1 parent affb87f commit 73b2c0f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions syntaxes/cmd-help.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ variables:
allcaps_argument_name: '[:upper:][[:upper:][:digit:]_]*\b'
relaxed_argument_name: '[:alpha:][[:alnum:]_-]*\b'

### scopes (last scope is matched first)
option_argument_scope: &OPTION_ARGUMENT_SCOPE
variable.other.option-argument.cmd-help variable.parameter.option-argument.cmd-help

contexts:
main:
Expand Down Expand Up @@ -98,34 +101,34 @@ contexts:

space-after-option:
- match: '<.*?>'
scope: variable.parameter.option-argument.cmd-help
scope: *OPTION_ARGUMENT_SCOPE
set: option-argument-post
- match: '{{allcaps_argument_name}}\b'
scope: variable.parameter.option-argument.cmd-help
scope: *OPTION_ARGUMENT_SCOPE
set: option-argument-post
- match: '{{relaxed_argument_name}}(?! [:alpha:])'
scope: variable.parameter.option-argument.cmd-help
scope: *OPTION_ARGUMENT_SCOPE
set: option-argument-post
- include: else-pop

equals-after-option:
- match: '{{relaxed_argument_name}}'
scope: variable.parameter.option-argument.cmd-help
scope: *OPTION_ARGUMENT_SCOPE
set: option-argument-post
- match: '<.*?>'
scope: variable.parameter.option-argument.cmd-help
scope: *OPTION_ARGUMENT_SCOPE
set: option-argument-post
- include: else-pop

square-brackets-after-option:
- meta_content_scope: variable.parameter.option-argument.cmd-help
- meta_content_scope: *OPTION_ARGUMENT_SCOPE
- match: '(?=])'
#fixme: should consume (no lookahead), this forces else-pop on option-argument-post
set: option-argument-post

option-argument-post:
- match: '({{ellipsis}})?'
scope: variable.parameter.option-argument.cmd-help
scope: *OPTION_ARGUMENT_SCOPE
# - match: ''
# set: def-option-post
- include: connect-option-alias
Expand Down

0 comments on commit 73b2c0f

Please sign in to comment.