From 3e4ef4a5fb36d92b1765a0e6db20ba1592f77ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 10 Oct 2022 21:45:40 +0200 Subject: [PATCH 01/43] Scope lowercase terms when followed by other terms Terms as in "defined terms". Mostly for subcommands followed by arguments or other subcommands. Which are defined terms themselves, but still not handled. e.g.: "reconnect device kick connection from device side to ..." In terms of regression delta, census: - adb: ok, it motivated this change - chown: not ideal, examples with chown itself are scoped. but acceptable. - npm: idem. - dpkg: not cool, I should limit term sequences to 3-4 terms Some unhandled cases in adb, chown and npm, - reveal the single_2_space variable does't work - show a need to treat definitions that do \n after the terms --- syntaxes/cmd-help.sublime-syntax | 6 ++++++ tests/highlighted/adb-1.0.41.txt | 30 +++++++++++++++--------------- tests/highlighted/chown-8.30.txt | 4 ++-- tests/highlighted/dpkg-1.19.7.txt | 2 +- tests/highlighted/npm-8.1.2.txt | 14 +++++++------- 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index e592120..6863681 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -404,6 +404,7 @@ contexts: 1: *OTHER_TERM_SCOPES 2: *OTHER_TERM_SCOPES set: then-pop + - include: other-def-seq other-variable-def: - match: '{{allcaps_argument_name}}(?= )' @@ -436,6 +437,11 @@ contexts: scope: *PATHNAME_SCOPES set: then-pop + other-def-seq: + #nice: limit the sequence to 3-4 terms top? + - match: '{{other_lowercase_name}}(?= .*{{long_space}})' + scope: *OTHER_TERM_SCOPES + ### notable exceptions ####################################################### color-escape-codes-sink: diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 4d64540..890e448 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -13,17 +13,17 @@  -L SOCKET listen on given socket for adb server [default=tcp:localhost:5037] general commands: - devices [-l] list connected devices (-l for long output) + devices [-l] list connected devices (-l for long output)  help show this help message  version show version num networking: - connect HOST[:PORT] connect to a device via TCP/IP [default port=5555] + connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]  disconnect [HOST[:PORT]]  disconnect from given TCP/IP device [default port=5555], or all  pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication - forward --list list all forward socket connections + forward --list list all forward socket connections  forward [--no-rebind] LOCAL REMOTE  forward socket connection using:  tcp: ( may be "tcp:0" to pick any open port) @@ -34,10 +34,10 @@  jdwp: (remote only)  vsock:: (remote only)  acceptfd: (listen only) - forward --remove LOCAL remove specific forward socket connection - forward --remove-all remove all forward socket connections - ppp TTY [PARAMETER...] run PPP over USB - reverse --list list all reverse socket connections from device + forward --remove LOCAL remove specific forward socket connection + forward --remove-all remove all forward socket connections + ppp TTY [PARAMETER...] run PPP over USB + reverse --list list all reverse socket connections from device  reverse [--no-rebind] REMOTE LOCAL  reverse socket connection using:  tcp: ( may be "tcp:0" to pick any open port) @@ -45,9 +45,9 @@  localreserved:  localfilesystem:  reverse --remove REMOTE remove specific reverse socket connection - reverse --remove-all remove all reverse socket connections from device - mdns check check if mdns discovery is available - mdns services list all discovered services + reverse --remove-all remove all reverse socket connections from device + mdns check check if mdns discovery is available + mdns services list all discovered services file transfer:  push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE @@ -76,7 +76,7 @@  -T: disable pty allocation  -t: allocate a pty if on a tty (-tt: force pty allocation)  -x: disable remote exit codes and stdout/stderr separation - emu COMMAND run emulator console command + emu COMMAND run emulator console command app installation (see also `adb shell cmd package help`):  install [-lrtsdg] [--instant] PACKAGE @@ -135,18 +135,18 @@  supports bootloader and recovery too. sideload reboots  into recovery and automatically starts sideload mode,  sideload-auto-reboot is the same but reboots after sideloading. - sideload OTAPACKAGE sideload the given full OTA package + sideload OTAPACKAGE sideload the given full OTA package  root restart adbd with root permissions  unroot restart adbd without root permissions  usb restart adbd listening on USB - tcpip PORT restart adbd listening on TCP on PORT + tcpip PORT restart adbd listening on TCP on PORT internal debugging:  start-server ensure that there is a server running  kill-server kill the server if it is running  reconnect kick connection from host side to force reconnect - reconnect device kick connection from device side to force reconnect - reconnect offline reset offline/unauthorized devices to force reconnect + reconnect device kick connection from device side to force reconnect + reconnect offline reset offline/unauthorized devices to force reconnect usb:  attach attach a detached USB device diff --git a/tests/highlighted/chown-8.30.txt b/tests/highlighted/chown-8.30.txt index 8b5325f..07d082b 100644 --- a/tests/highlighted/chown-8.30.txt +++ b/tests/highlighted/chown-8.30.txt @@ -40,9 +40,9 @@ OWNER and GROUP may be numeric as well as symbolic. Examples: - chown root /u Change the owner of /u to "root". + chown root /u Change the owner of /u to "root".  chown root:staff /u Likewise, but also change its group to "staff". - chown -hR root /u Change the owner of /u and subfiles to "root". + chown -hR root /u Change the owner of /u and subfiles to "root". GNU coreutils online help:  Full documentation at:  diff --git a/tests/highlighted/dpkg-1.19.7.txt b/tests/highlighted/dpkg-1.19.7.txt index 49a14e2..af251ed 100644 --- a/tests/highlighted/dpkg-1.19.7.txt +++ b/tests/highlighted/dpkg-1.19.7.txt @@ -73,7 +73,7 @@  --abort-after  Abort after encountering errors. Comparison operators for --compare-versions are: - lt le eq ne ge gt (treat empty version as earlier than any version); + lt le eq ne ge gt (treat empty version as earlier than any version);  lt-nl le-nl ge-nl gt-nl (treat empty version as later than any version);  < << <= = >= >> > (only for compatibility with control file syntax). diff --git a/tests/highlighted/npm-8.1.2.txt b/tests/highlighted/npm-8.1.2.txt index 9070b6d..2b9bc87 100644 --- a/tests/highlighted/npm-8.1.2.txt +++ b/tests/highlighted/npm-8.1.2.txt @@ -2,14 +2,14 @@ Usage: -npm install install all the dependencies in your project +npm install install all the dependencies in your project npm install add the dependency to your project -npm test run this project's tests -npm run run the script named  -npm -h quick help on  -npm -l display usage info for all commands -npm help search for help on  -npm help npm more involved overview +npm test run this project's tests +npm run run the script named  +npm -h quick help on  +npm -l display usage info for all commands +npm help search for help on  +npm help npm more involved overview All commands: From 80382b0faed0c9226260485ba78accaf6d4bf74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 10 Oct 2022 22:43:48 +0200 Subject: [PATCH 02/43] Fix broken adb syntax test I was debugging a problem that didn't exist :scream: --- tests/syntax/syntax_test_adb.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index e51a1be..bd8db89 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -142,9 +142,9 @@ scripting: unroot restart adbd without root permissions usb restart adbd listening on USB tcpip PORT restart adbd listening on TCP on PORT -#^^^^^ - entity.name.function.option.cmd-help -# ^ - entity.name.function.option.cmd-help entity.name.function.option.cmd-help keyword.other.argument.cmd-help -# ^^^^ - entity.name.function.option.cmd-help keyword.other.argument.cmd-help +#^^^^^ keyword.other.def.cmd-help +# ^ - keyword.other.def.cmd-help variable.parameter.option-argument.cmd-help +# ^^^^ - variable.parameter.option-argument.cmd-help #nice: subcommand + ARG internal debugging: From beae87159d229f1331e970a5ff0f4c7af2fcfff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 10 Oct 2022 23:09:50 +0200 Subject: [PATCH 03/43] Add tests showing what's wrong with other-term-seq It's like it doesn't properly use all the {{long_space}} cases (newline and single_2_space) --- syntaxes/cmd-help.sublime-syntax | 1 + tests/syntax/syntax_test_adb.txt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 6863681..f109406 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -439,6 +439,7 @@ contexts: other-def-seq: #nice: limit the sequence to 3-4 terms top? + #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *OTHER_TERM_SCOPES diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index bd8db89..7f853b5 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -16,6 +16,10 @@ global options: general commands: devices [-l] list connected devices (-l for long output) +#^^^^^^^ keyword.other.def.cmd-help +# ^ - keyword.other.def.cmd-help entity.name.function.option.cmd-help +# ^^^^ - entity.name.function.option.cmd-help +#nice: [-option] after other-def-seq help show this help message version show version num @@ -47,6 +51,8 @@ networking: localreserved: localfilesystem: reverse --remove REMOTE remove specific reverse socket connection +#^^^^^^^ - keyword.other.def.cmd-help +#fixme: other-def-seq ending in 2 spaces reverse --remove-all remove all reverse socket connections from device mdns check check if mdns discovery is available mdns services list all discovered services @@ -119,6 +125,8 @@ security: disable-verity disable dm-verity checking on userdebug builds enable-verity re-enable dm-verity checking on userdebug builds keygen FILE +#^^^^^^ - keyword.other.def.cmd-help +#fixme: other-def-seq ending in newline generate adb public/private key; private key stored in FILE, scripting: From dd43878a158906208dec2d31c3e66e16b0922249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 10 Oct 2022 23:16:35 +0200 Subject: [PATCH 04/43] Scope argument after subcommand But it's kinda weird because in forward --remove LOCAL it scopes the LOCAL but skips the --remove. I guess this skip happens in the option-def+space context? Anyways, worth running the syntest debugger on. But not today! --- syntaxes/cmd-help.sublime-syntax | 5 +++++ tests/highlighted/adb-1.0.41.txt | 8 ++++---- tests/syntax/syntax_test_adb.txt | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index f109406..51fc99b 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -442,6 +442,11 @@ contexts: #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *OTHER_TERM_SCOPES + set: subcommand-def-post + + subcommand-def-post: + - match: ' (?={{allcaps_argument_name}}{{long_space}})' + set: option-term+space ### notable exceptions ####################################################### diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 890e448..033eae6 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -34,7 +34,7 @@  jdwp: (remote only)  vsock:: (remote only)  acceptfd: (listen only) - forward --remove LOCAL remove specific forward socket connection + forward --remove LOCAL remove specific forward socket connection  forward --remove-all remove all forward socket connections  ppp TTY [PARAMETER...] run PPP over USB  reverse --list list all reverse socket connections from device @@ -76,7 +76,7 @@  -T: disable pty allocation  -t: allocate a pty if on a tty (-tt: force pty allocation)  -x: disable remote exit codes and stdout/stderr separation - emu COMMAND run emulator console command + emu COMMAND run emulator console command app installation (see also `adb shell cmd package help`):  install [-lrtsdg] [--instant] PACKAGE @@ -135,11 +135,11 @@  supports bootloader and recovery too. sideload reboots  into recovery and automatically starts sideload mode,  sideload-auto-reboot is the same but reboots after sideloading. - sideload OTAPACKAGE sideload the given full OTA package + sideload OTAPACKAGE sideload the given full OTA package  root restart adbd with root permissions  unroot restart adbd without root permissions  usb restart adbd listening on USB - tcpip PORT restart adbd listening on TCP on PORT + tcpip PORT restart adbd listening on TCP on PORT internal debugging:  start-server ensure that there is a server running diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 7f853b5..de3bcfc 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -152,7 +152,7 @@ scripting: tcpip PORT restart adbd listening on TCP on PORT #^^^^^ keyword.other.def.cmd-help # ^ - keyword.other.def.cmd-help variable.parameter.option-argument.cmd-help -# ^^^^ - variable.parameter.option-argument.cmd-help +# ^^^^ variable.parameter.option-argument.cmd-help #nice: subcommand + ARG internal debugging: From db357da8aa49ae0757077d4c0d7a7c8f2638cd30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 23 Jan 2023 21:35:08 +0100 Subject: [PATCH 05/43] Update syntax tests for other-def sequences --- tests/syntax/syntax_test_adb.txt | 14 +++++++------- tests/syntax/syntax_test_chown.txt | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index de3bcfc..b7ce82d 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -16,8 +16,8 @@ global options: general commands: devices [-l] list connected devices (-l for long output) -#^^^^^^^ keyword.other.def.cmd-help -# ^ - keyword.other.def.cmd-help entity.name.function.option.cmd-help +#^^^^^^^ constant.other.def.cmd-help +# ^ - constant.other.def.cmd-help entity.name.function.option.cmd-help # ^^^^ - entity.name.function.option.cmd-help #nice: [-option] after other-def-seq help show this help message @@ -150,17 +150,17 @@ scripting: unroot restart adbd without root permissions usb restart adbd listening on USB tcpip PORT restart adbd listening on TCP on PORT -#^^^^^ keyword.other.def.cmd-help -# ^ - keyword.other.def.cmd-help variable.parameter.option-argument.cmd-help -# ^^^^ variable.parameter.option-argument.cmd-help -#nice: subcommand + ARG +#^^^^^ constant.other.def.cmd-help +# ^ - constant.other.def.cmd-help variable.parameter.option-argument.cmd-help +# ^^^^ entity.name.function.option.cmd-help keyword.other.argument.cmd-help +#nit: make the first scope of the argument "constant.other.def" internal debugging: start-server ensure that there is a server running kill-server kill the server if it is running reconnect kick connection from host side to force reconnect reconnect device kick connection from device side to force reconnect -#^^^^^^^^^ - constant.other.def.cmd-help +#^^^^^^^^^ constant.other.def.cmd-help # ^ - constant.other.def.cmd-help # ^^^^^^ - constant.other.def.cmd-help #nice: subcommand + subcommand/enum diff --git a/tests/syntax/syntax_test_chown.txt b/tests/syntax/syntax_test_chown.txt index c81f0f2..bbbc7f7 100644 --- a/tests/syntax/syntax_test_chown.txt +++ b/tests/syntax/syntax_test_chown.txt @@ -46,7 +46,10 @@ OWNER and GROUP may be numeric as well as symbolic. Examples: chown root /u Change the owner of /u to "root". +# ^^^^^ constant.other.def.cmd-help chown root:staff /u Likewise, but also change its group to "staff". +# ^^^^^ +#nit: scope this to make it consistent with the other 2 examples chown -hR root /u Change the owner of /u and subfiles to "root". GNU coreutils online help: From 83941dff0eecff73c1ba1e17c1f91f25c9ee615e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 23 Jan 2023 21:39:19 +0100 Subject: [PATCH 06/43] Move other-def-seq include to other-def --- syntaxes/cmd-help.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 51fc99b..fc7fbdc 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -380,6 +380,7 @@ contexts: - include: pathname-def - include: other-term-def - include: other-variable-def + - include: other-def-seq other-def-escapes: # pretty common in "usage:" alternatives @@ -404,7 +405,6 @@ contexts: 1: *OTHER_TERM_SCOPES 2: *OTHER_TERM_SCOPES set: then-pop - - include: other-def-seq other-variable-def: - match: '{{allcaps_argument_name}}(?= )' From 409441080d3d5142bbda4c9a602733e4cd0705db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 00:21:56 +0200 Subject: [PATCH 07/43] Rename other-def -> keyword, other-variable -> variable For ease of use. Other X is less wrong but a little more unwieldy to write and reason about. --- syntaxes/cmd-help.sublime-syntax | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index fc7fbdc..491f362 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -71,11 +71,11 @@ scope_variables: # last scope is matched first - &ARGUMENT_SCOPES keyword.other.argument.cmd-help # mostly all-caps definitions. usually envs or args =~ OPTION_ARGUMENT - - &OTHER_VARIABLE_SCOPES + - &VARIABLE_SCOPES keyword.other.variable.cmd-help # non all-caps definitions: subcommands, argument enums, etc. - - &OTHER_TERM_SCOPES + - &KEYWORD_SCOPES constant.other.def.cmd-help - &PATHNAME_SCOPES @@ -378,8 +378,8 @@ contexts: other-def: - include: other-def-escapes - include: pathname-def - - include: other-term-def - - include: other-variable-def + - include: keyword-def + - include: variable-def - include: other-def-seq other-def-escapes: @@ -387,39 +387,39 @@ contexts: - match: (?=or\s) set: then-pop - other-term-def: + keyword-def: - match: '{{other_lowercase_name}}(?={{long_space}})' - scope: *OTHER_TERM_SCOPES + scope: *KEYWORD_SCOPES set: then-pop # e.g.: "install - install packages (from apt)" - match: '{{other_lowercase_name}}(?=\s+-\s+\S)' - scope: *OTHER_TERM_SCOPES + scope: *KEYWORD_SCOPES set: then-pop # e.g.: "compose*" (from docker) - match: '{{other_lowercase_name}}\*(?={{long_space}})' - scope: *OTHER_TERM_SCOPES + scope: *KEYWORD_SCOPES set: then-pop # e.g.: "build, b" (from cargo) - match: ({{other_lowercase_name}}), ({{other_lowercase_name}})(?={{long_space}}) captures: - 1: *OTHER_TERM_SCOPES - 2: *OTHER_TERM_SCOPES + 1: *KEYWORD_SCOPES + 2: *KEYWORD_SCOPES set: then-pop - other-variable-def: + variable-def: - match: '{{allcaps_argument_name}}(?= )' - scope: *OTHER_VARIABLE_SCOPES + scope: *VARIABLE_SCOPES set: then-pop # e.g.: "PYTHONSTARTUP:", "PYTHONCASEOK :" - match: '{{allcaps_argument_name}}(?=\s*:)' - scope: *OTHER_VARIABLE_SCOPES + scope: *VARIABLE_SCOPES set: then-pop - match: \${{allcaps_argument_name}} - scope: *OTHER_VARIABLE_SCOPES + scope: *VARIABLE_SCOPES set: then-pop # e.g.: "'warn'" or "'warn-nopipe'" (from tee) - match: "'{{other_lowercase_name}}'" - scope: *OTHER_VARIABLE_SCOPES + scope: *VARIABLE_SCOPES set: then-pop pathname-def: @@ -441,7 +441,7 @@ contexts: #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' - scope: *OTHER_TERM_SCOPES + scope: *KEYWORD_SCOPES set: subcommand-def-post subcommand-def-post: From 1dbc324f57c36215ef43de9bef2800a19a871327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 00:29:12 +0200 Subject: [PATCH 08/43] Rename "..other.def.." scope to "keyword" To reflect the new change in KEYWORD_SCOPES' name --- syntaxes/cmd-help.sublime-syntax | 4 ++-- tests/syntax/syntax_test_adb.txt | 14 +++++++------- tests/syntax/syntax_test_apt.txt | 2 +- tests/syntax/syntax_test_bat.txt | 2 +- tests/syntax/syntax_test_cargo.txt | 4 ++-- tests/syntax/syntax_test_chown.txt | 2 +- tests/syntax/syntax_test_cp.txt | 4 ++-- tests/syntax/syntax_test_dd.txt | 2 +- tests/syntax/syntax_test_docker.txt | 2 +- tests/syntax/syntax_test_java.txt | 2 +- tests/syntax/syntax_test_man.txt | 2 +- tests/syntax/syntax_test_nano.txt | 2 +- tests/syntax/syntax_test_python.txt | 2 +- tests/syntax/syntax_test_ruby.txt | 4 ++-- 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 491f362..ccd9310 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -61,7 +61,7 @@ scope_variables: # last scope is matched first entity.name.function.option.cmd-help - &PLUS_OPTION_SCOPES entity.name.function.option.plus.cmd-help - - &END_OF_OPTIONS_SCOPE + - &END_OF_OPTIONS_SCOPE # =~ KEYWORD_SCOPES constant.other.end-of-options.cmd-help - &OPTION_ARGUMENT_SCOPES @@ -76,7 +76,7 @@ scope_variables: # last scope is matched first # non all-caps definitions: subcommands, argument enums, etc. - &KEYWORD_SCOPES - constant.other.def.cmd-help + constant.other.keyword.cmd-help - &PATHNAME_SCOPES constant.character.escape.pathname.cmd-help diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index b7ce82d..ee5fe63 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -16,8 +16,8 @@ global options: general commands: devices [-l] list connected devices (-l for long output) -#^^^^^^^ constant.other.def.cmd-help -# ^ - constant.other.def.cmd-help entity.name.function.option.cmd-help +#^^^^^^^ constant.other.keyword.cmd-help +# ^ - constant.other.keyword.cmd-help entity.name.function.option.cmd-help # ^^^^ - entity.name.function.option.cmd-help #nice: [-option] after other-def-seq help show this help message @@ -150,8 +150,8 @@ scripting: unroot restart adbd without root permissions usb restart adbd listening on USB tcpip PORT restart adbd listening on TCP on PORT -#^^^^^ constant.other.def.cmd-help -# ^ - constant.other.def.cmd-help variable.parameter.option-argument.cmd-help +#^^^^^ constant.other.keyword.cmd-help +# ^ - constant.other.keyword.cmd-help variable.parameter.option-argument.cmd-help # ^^^^ entity.name.function.option.cmd-help keyword.other.argument.cmd-help #nit: make the first scope of the argument "constant.other.def" @@ -160,9 +160,9 @@ internal debugging: kill-server kill the server if it is running reconnect kick connection from host side to force reconnect reconnect device kick connection from device side to force reconnect -#^^^^^^^^^ constant.other.def.cmd-help -# ^ - constant.other.def.cmd-help -# ^^^^^^ - constant.other.def.cmd-help +#^^^^^^^^^ constant.other.keyword.cmd-help +# ^ - constant.other.keyword.cmd-help +# ^^^^^^ - constant.other.keyword.cmd-help #nice: subcommand + subcommand/enum reconnect offline reset offline/unauthorized devices to force reconnect diff --git a/tests/syntax/syntax_test_apt.txt b/tests/syntax/syntax_test_apt.txt index 8ed4bb4..095d979 100644 --- a/tests/syntax/syntax_test_apt.txt +++ b/tests/syntax/syntax_test_apt.txt @@ -11,7 +11,7 @@ interactive use by default. Most used commands: list - list packages based on package names -# ^^^^ constant.other.def.cmd-help +# ^^^^ constant.other.keyword.cmd-help search - search in package descriptions show - show package details install - install packages diff --git a/tests/syntax/syntax_test_bat.txt b/tests/syntax/syntax_test_bat.txt index 09f71e6..8df3a14 100644 --- a/tests/syntax/syntax_test_bat.txt +++ b/tests/syntax/syntax_test_bat.txt @@ -149,6 +149,6 @@ ARGS: SUBCOMMANDS: cache Modify the syntax-definition and theme cache -# ^^^^^ constant.other.def.cmd-help +# ^^^^^ constant.other.keyword.cmd-help Note: `bat -h` prints a short and concise overview while `bat --help` gives all details. diff --git a/tests/syntax/syntax_test_cargo.txt b/tests/syntax/syntax_test_cargo.txt index a3cb0de..352b3bb 100644 --- a/tests/syntax/syntax_test_cargo.txt +++ b/tests/syntax/syntax_test_cargo.txt @@ -21,8 +21,8 @@ OPTIONS: Some common cargo commands are (see all commands with --list): build, b Compile the current package -# ^^^^^ constant.other.def.cmd-help -# ^ constant.other.def.cmd-help +# ^^^^^ constant.other.keyword.cmd-help +# ^ constant.other.keyword.cmd-help check, c Analyze the current package and report errors, but don't build object files clean Remove the target directory doc, d Build this package's and its dependencies' documentation diff --git a/tests/syntax/syntax_test_chown.txt b/tests/syntax/syntax_test_chown.txt index bbbc7f7..73182f1 100644 --- a/tests/syntax/syntax_test_chown.txt +++ b/tests/syntax/syntax_test_chown.txt @@ -46,7 +46,7 @@ OWNER and GROUP may be numeric as well as symbolic. Examples: chown root /u Change the owner of /u to "root". -# ^^^^^ constant.other.def.cmd-help +# ^^^^^ constant.other.keyword.cmd-help chown root:staff /u Likewise, but also change its group to "staff". # ^^^^^ #nit: scope this to make it consistent with the other 2 examples diff --git a/tests/syntax/syntax_test_cp.txt b/tests/syntax/syntax_test_cp.txt index 34903e9..8fd1810 100644 --- a/tests/syntax/syntax_test_cp.txt +++ b/tests/syntax/syntax_test_cp.txt @@ -75,8 +75,8 @@ The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if --backup is given) -# ^^^^ constant.other.def.cmd-help -# ^^^ constant.other.def.cmd-help +# ^^^^ constant.other.keyword.cmd-help +# ^^^ constant.other.keyword.cmd-help # not sure this is ideal, but it's a lesser evil anyways numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise diff --git a/tests/syntax/syntax_test_dd.txt b/tests/syntax/syntax_test_dd.txt index 3f52d8d..bfe1621 100644 --- a/tests/syntax/syntax_test_dd.txt +++ b/tests/syntax/syntax_test_dd.txt @@ -45,7 +45,7 @@ Each CONV symbol may be: notrunc do not truncate the output file noerror continue after read errors fdatasync physically write output file data before finishing -# ^^^^^^^^^ constant.other.def.cmd-help +# ^^^^^^^^^ constant.other.keyword.cmd-help fsync likewise, but also write metadata Each FLAG symbol may be: diff --git a/tests/syntax/syntax_test_docker.txt b/tests/syntax/syntax_test_docker.txt index cf2db26..8bf9889 100644 --- a/tests/syntax/syntax_test_docker.txt +++ b/tests/syntax/syntax_test_docker.txt @@ -20,7 +20,7 @@ Options: Management Commands: app* Docker App (Docker Inc., v0.9.1-beta3) -# ^^^^ constant.other.def.cmd-help +# ^^^^ constant.other.keyword.cmd-help builder Manage builds buildx* Docker Buildx (Docker Inc., v0.7.1-docker) compose* Docker Compose (Docker Inc., v2.2.3) diff --git a/tests/syntax/syntax_test_java.txt b/tests/syntax/syntax_test_java.txt index b904b27..21b316b 100644 --- a/tests/syntax/syntax_test_java.txt +++ b/tests/syntax/syntax_test_java.txt @@ -3,7 +3,7 @@ Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] -# ^^ - constant.other.def.cmd-help +# ^^ - constant.other.keyword.cmd-help (to execute a jar file) where options include: -d32 use a 32-bit data model if available diff --git a/tests/syntax/syntax_test_man.txt b/tests/syntax/syntax_test_man.txt index 190c00e..7d83576 100644 --- a/tests/syntax/syntax_test_man.txt +++ b/tests/syntax/syntax_test_man.txt @@ -57,7 +57,7 @@ Usage: man [OPTION...] [SECTION] PAGE... -p, --preprocessor=STRING STRING indicates which preprocessors to run: e - [n]eqn, p - pic, t - tbl, g - grap, r - refer, v - vgrind -# <- constant.other.def.cmd-help +# <- constant.other.keyword.cmd-help #nit: work around this (suggestion: reject "word - " if there's another instance later in the same line) -t, --troff use groff to format pages -T, --troff-device[=DEVICE] use groff with selected device diff --git a/tests/syntax/syntax_test_nano.txt b/tests/syntax/syntax_test_nano.txt index 889eb19..d0171c8 100644 --- a/tests/syntax/syntax_test_nano.txt +++ b/tests/syntax/syntax_test_nano.txt @@ -7,7 +7,7 @@ a '+' before the filename. The column number can be added after a comma. When a filename is '-', nano reads data from standard input. Option Long option Meaning -#^^^^^^ - constant.other.def.cmd-help +#^^^^^^ - constant.other.keyword.cmd-help -A --smarthome Enable smart home key # ^^^^^^^^^^^ entity.name.function.option.cmd-help -B --backup Save backups of existing files diff --git a/tests/syntax/syntax_test_python.txt b/tests/syntax/syntax_test_python.txt index 7061bac..a5999f7 100644 --- a/tests/syntax/syntax_test_python.txt +++ b/tests/syntax/syntax_test_python.txt @@ -64,7 +64,7 @@ Options and arguments (and corresponding environment variables): --check-hash-based-pycs always|default|never: control how Python invalidates hash-based .pyc files file : program read from script file -#^^^ constant.other.def.cmd-help +#^^^ constant.other.keyword.cmd-help #wontfix: should be keyword.other.argument.cmd-help, but a necessary evil - : program read from stdin (default; interactive mode if a tty) # <- keyword.other.argument.cmd-help diff --git a/tests/syntax/syntax_test_ruby.txt b/tests/syntax/syntax_test_ruby.txt index d5b55c1..f471b4d 100644 --- a/tests/syntax/syntax_test_ruby.txt +++ b/tests/syntax/syntax_test_ruby.txt @@ -69,10 +69,10 @@ Dump List: Features: gems rubygems (default: enabled) did_you_mean did_you_mean (default: enabled) -# ^^^^^^^^^^^^ constant.other.def.cmd-help +# ^^^^^^^^^^^^ constant.other.keyword.cmd-help rubyopt RUBYOPT environment variable (default: enabled) frozen-string-literal -# ^^^^^^^^^^^^^^^^^^^^^ constant.other.def.cmd-help +# ^^^^^^^^^^^^^^^^^^^^^ constant.other.keyword.cmd-help freeze all string literals (default: disabled) jit JIT compiler (default: disabled) Warning categories: From adc4446ce332d17b6e8e26a299c7f34410b3eeb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 00:38:13 +0200 Subject: [PATCH 09/43] Annotate a refactor idea for enum1|enum2|enum3 args --- tests/syntax/syntax_test_sbt.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/syntax/syntax_test_sbt.txt b/tests/syntax/syntax_test_sbt.txt index 92c5bf8..b0373cf 100644 --- a/tests/syntax/syntax_test_sbt.txt +++ b/tests/syntax/syntax_test_sbt.txt @@ -17,6 +17,8 @@ Usage: sbt [options] --color=auto|always|true|false|never # ^^^^ entity.name.function.option.cmd-help keyword.other.argument.cmd-help # ^^^^^^ entity.name.function.option.cmd-help keyword.other.argument.cmd-help +#nice: refactor idea: handle this with a single regex like (|arg)+ +# and scope match 1 (|) like default and 2 (arg) like arguments enable or disable ANSI color codes (sbt 1.3 and above) --supershell=auto|always|true|false|never enable or disable supershell (sbt 1.3 and above) From 09e84e7bd735ff02b25fdcad86844d4ae2f493a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 00:57:00 +0200 Subject: [PATCH 10/43] Scope "subcommand --option" But I'm considering leaving the later unscoped, or any other 2nd term after a keyword term. Cause it causes regressions in other, more common commands, where it scopes terms in examples. (As in every other delta in this commit) --- syntaxes/cmd-help.sublime-syntax | 9 +++++++-- tests/highlighted/adb-1.0.41.txt | 12 ++++++------ tests/highlighted/chown-8.30.txt | 2 +- tests/highlighted/mount-2.34.0.txt | 2 +- tests/highlighted/npm-8.1.2.txt | 2 +- tests/syntax/syntax_test_adb.txt | 2 ++ tests/syntax/syntax_test_chown.txt | 2 ++ 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index ccd9310..f8cc589 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -391,7 +391,7 @@ contexts: - match: '{{other_lowercase_name}}(?={{long_space}})' scope: *KEYWORD_SCOPES set: then-pop - # e.g.: "install - install packages (from apt)" + # e.g.: "install - install packages" (from apt) - match: '{{other_lowercase_name}}(?=\s+-\s+\S)' scope: *KEYWORD_SCOPES set: then-pop @@ -405,6 +405,7 @@ contexts: 1: *KEYWORD_SCOPES 2: *KEYWORD_SCOPES set: then-pop + - include: keyword-seq-def variable-def: - match: '{{allcaps_argument_name}}(?= )' @@ -437,7 +438,11 @@ contexts: scope: *PATHNAME_SCOPES set: then-pop - other-def-seq: + keyword-seq-def: + - match: '({{other_lowercase_name}}) (-{{option_name}})' + captures: + 1: *KEYWORD_SCOPES + 2: *OPTION_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 033eae6..94cff6c 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -23,7 +23,7 @@  disconnect from given TCP/IP device [default port=5555], or all  pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication - forward --list list all forward socket connections + forward --list list all forward socket connections  forward [--no-rebind] LOCAL REMOTE  forward socket connection using:  tcp: ( may be "tcp:0" to pick any open port) @@ -34,18 +34,18 @@  jdwp: (remote only)  vsock:: (remote only)  acceptfd: (listen only) - forward --remove LOCAL remove specific forward socket connection - forward --remove-all remove all forward socket connections + forward --remove LOCAL remove specific forward socket connection + forward --remove-all remove all forward socket connections  ppp TTY [PARAMETER...] run PPP over USB - reverse --list list all reverse socket connections from device + reverse --list list all reverse socket connections from device  reverse [--no-rebind] REMOTE LOCAL  reverse socket connection using:  tcp: ( may be "tcp:0" to pick any open port)  localabstract:  localreserved:  localfilesystem: - reverse --remove REMOTE remove specific reverse socket connection - reverse --remove-all remove all reverse socket connections from device + reverse --remove REMOTE remove specific reverse socket connection + reverse --remove-all remove all reverse socket connections from device  mdns check check if mdns discovery is available  mdns services list all discovered services diff --git a/tests/highlighted/chown-8.30.txt b/tests/highlighted/chown-8.30.txt index 07d082b..9658673 100644 --- a/tests/highlighted/chown-8.30.txt +++ b/tests/highlighted/chown-8.30.txt @@ -42,7 +42,7 @@ Examples:  chown root /u Change the owner of /u to "root".  chown root:staff /u Likewise, but also change its group to "staff". - chown -hR root /u Change the owner of /u and subfiles to "root". + chown -hR root /u Change the owner of /u and subfiles to "root". GNU coreutils online help:  Full documentation at:  diff --git a/tests/highlighted/mount-2.34.0.txt b/tests/highlighted/mount-2.34.0.txt index e06eb5e..4d3f6b7 100644 --- a/tests/highlighted/mount-2.34.0.txt +++ b/tests/highlighted/mount-2.34.0.txt @@ -1,7 +1,7 @@ Usage:  mount [-lhV] - mount -a [options] + mount -a [options]  mount [options] [--source] | [--target]   mount [options]   mount [] diff --git a/tests/highlighted/npm-8.1.2.txt b/tests/highlighted/npm-8.1.2.txt index 2b9bc87..edc2a50 100644 --- a/tests/highlighted/npm-8.1.2.txt +++ b/tests/highlighted/npm-8.1.2.txt @@ -7,7 +7,7 @@ npm test run this project's tests npm run run the script named  npm -h quick help on  -npm -l display usage info for all commands +npm -l display usage info for all commands npm help search for help on  npm help npm more involved overview diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index ee5fe63..dc15a8c 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -30,6 +30,8 @@ networking: pair HOST[:PORT] [PAIRING CODE] pair with a device for secure TCP/IP communication forward --list list all forward socket connections +#^^^^^^^ constant.other.keyword.cmd-help +# ^^^^^^ entity.name.function.option.cmd-help forward [--no-rebind] LOCAL REMOTE forward socket connection using: tcp: ( may be "tcp:0" to pick any open port) diff --git a/tests/syntax/syntax_test_chown.txt b/tests/syntax/syntax_test_chown.txt index 73182f1..a4d394e 100644 --- a/tests/syntax/syntax_test_chown.txt +++ b/tests/syntax/syntax_test_chown.txt @@ -51,6 +51,8 @@ Examples: # ^^^^^ #nit: scope this to make it consistent with the other 2 examples chown -hR root /u Change the owner of /u and subfiles to "root". +# ^^^ entity.name.function.option.cmd-help +#nit: don't scope this as option GNU coreutils online help: Full documentation at: From 32cdd01cc9ce3a39d1dbad9d4b33c12c1029cc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 01:10:34 +0200 Subject: [PATCH 11/43] Scope "keyword [--option]" --- syntaxes/cmd-help.sublime-syntax | 5 +++++ tests/highlighted/adb-1.0.41.txt | 22 +++++++++++----------- tests/highlighted/mount-2.34.0.txt | 2 +- tests/syntax/syntax_test_adb.txt | 3 +-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index f8cc589..9ec66d5 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -443,6 +443,11 @@ contexts: captures: 1: *KEYWORD_SCOPES 2: *OPTION_SCOPES + # e.g.: "devices [-l]" (from adb) + - match: '({{other_lowercase_name}}) \[(-{{option_name}})\]' + captures: + 1: *KEYWORD_SCOPES + 2: *OPTION_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 94cff6c..83f830e 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -13,7 +13,7 @@  -L SOCKET listen on given socket for adb server [default=tcp:localhost:5037] general commands: - devices [-l] list connected devices (-l for long output) + devices [-l] list connected devices (-l for long output)  help show this help message  version show version num @@ -24,7 +24,7 @@  pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication  forward --list list all forward socket connections - forward [--no-rebind] LOCAL REMOTE + forward [--no-rebind] LOCAL REMOTE  forward socket connection using:  tcp: ( may be "tcp:0" to pick any open port)  localabstract: @@ -38,7 +38,7 @@  forward --remove-all remove all forward socket connections  ppp TTY [PARAMETER...] run PPP over USB  reverse --list list all reverse socket connections from device - reverse [--no-rebind] REMOTE LOCAL + reverse [--no-rebind] REMOTE LOCAL  reverse socket connection using:  tcp: ( may be "tcp:0" to pick any open port)  localabstract: @@ -50,18 +50,18 @@  mdns services list all discovered services file transfer: - push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE + push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE  copy local files/directories to device  --sync: only push files that are newer on the host than the device  -n: dry run: push files to device without storing to the filesystem  -z: enable compression with a specified algorithm (any, none, brotli)  -Z: disable compression - pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL + pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL  copy files/dirs from device  -a: preserve file timestamp and mode  -z: enable compression with a specified algorithm (any, none, brotli)  -Z: disable compression - sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendor] + sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendor]  sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)  -n: dry run: push files to device without storing to the filesystem  -l: list files that would be copied, but don't copy them @@ -79,11 +79,11 @@  emu COMMAND run emulator console command app installation (see also `adb shell cmd package help`): - install [-lrtsdg] [--instant] PACKAGE + install [-lrtsdg] [--instant] PACKAGE  push a single package to the device and install it - install-multiple [-lrtsdpg] [--instant] PACKAGE... + install-multiple [-lrtsdpg] [--instant] PACKAGE...  push multiple APKs to the device for a single package and install them - install-multi-package [-lrtsdpg] [--instant] PACKAGE... + install-multi-package [-lrtsdpg] [--instant] PACKAGE...  push one or more packages to the device and install them atomically  -r: replace existing application  -t: allow test packages @@ -101,7 +101,7 @@  --version-check-agent: update deployment agent when local version has different version code and using fast deploy  --local-agent: locate agent files from local source build (instead of SDK location)  (See also `adb shell pm help` for more options.) - uninstall [-k] PACKAGE + uninstall [-k] PACKAGE  remove this app package from the device  '-k': keep the data and cache directories @@ -127,7 +127,7 @@  get-state print offline | bootloader | device  get-serialno print   get-devpath print  - remount [-R] + remount [-R]  remount partitions read-write. if a reboot is required, -R will  will automatically reboot the device.  reboot [bootloader|recovery|sideload|sideload-auto-reboot] diff --git a/tests/highlighted/mount-2.34.0.txt b/tests/highlighted/mount-2.34.0.txt index 4d3f6b7..bebaf69 100644 --- a/tests/highlighted/mount-2.34.0.txt +++ b/tests/highlighted/mount-2.34.0.txt @@ -1,6 +1,6 @@ Usage: - mount [-lhV] + mount [-lhV]  mount -a [options]  mount [options] [--source] | [--target]   mount [options]  diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index dc15a8c..cf06dee 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -18,8 +18,7 @@ general commands: devices [-l] list connected devices (-l for long output) #^^^^^^^ constant.other.keyword.cmd-help # ^ - constant.other.keyword.cmd-help entity.name.function.option.cmd-help -# ^^^^ - entity.name.function.option.cmd-help -#nice: [-option] after other-def-seq +# ^^ entity.name.function.option.cmd-help help show this help message version show version num From 437fc88421be8b49f082ff0f44d90fe50588e3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 01:13:42 +0200 Subject: [PATCH 12/43] Scope "keyword [ARGUMENT]" And it introduces a hell of a regression in the Usage section of a few other commands. This is breaking for me, we'll probably do the 1st keyword only. --- syntaxes/cmd-help.sublime-syntax | 4 ++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/highlighted/bat-0.18.2.txt | 2 +- tests/highlighted/bat-short-0.18.2.txt | 2 +- tests/highlighted/ripgrep-13.0.0.txt | 14 +++++++------- tests/syntax/syntax_test_adb.txt | 2 ++ tests/syntax/syntax_test_bat.txt | 2 ++ 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 9ec66d5..afb1eb0 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -448,6 +448,10 @@ contexts: captures: 1: *KEYWORD_SCOPES 2: *OPTION_SCOPES + - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\]' + captures: + 1: *KEYWORD_SCOPES + 2: *ARGUMENT_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 83f830e..cfe2776 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -106,7 +106,7 @@  '-k': keep the data and cache directories debugging: - bugreport [PATH] + bugreport [PATH]  write bugreport to given PATH [default=bugreport.zip];  if PATH is a directory, the bug report is saved in that directory.  devices that don't support zipped bug reports output to stdout. diff --git a/tests/highlighted/bat-0.18.2.txt b/tests/highlighted/bat-0.18.2.txt index 8de0479..a71d9df 100644 --- a/tests/highlighted/bat-0.18.2.txt +++ b/tests/highlighted/bat-0.18.2.txt @@ -2,7 +2,7 @@ A cat(1) clone with syntax highlighting and Git integration. USAGE: - bat [OPTIONS] [FILE]... + bat [OPTIONS] [FILE]...  bat  OPTIONS: diff --git a/tests/highlighted/bat-short-0.18.2.txt b/tests/highlighted/bat-short-0.18.2.txt index 3040dfa..10cb885 100644 --- a/tests/highlighted/bat-short-0.18.2.txt +++ b/tests/highlighted/bat-short-0.18.2.txt @@ -2,7 +2,7 @@ A cat(1) clone with syntax highlighting and Git integration. USAGE: - bat [OPTIONS] [FILE]... + bat [OPTIONS] [FILE]...  bat  OPTIONS: diff --git a/tests/highlighted/ripgrep-13.0.0.txt b/tests/highlighted/ripgrep-13.0.0.txt index c671f8f..d404a77 100644 --- a/tests/highlighted/ripgrep-13.0.0.txt +++ b/tests/highlighted/ripgrep-13.0.0.txt @@ -11,14 +11,14 @@ USAGE: - rg [OPTIONS] PATTERN [PATH ...] - rg [OPTIONS] -e PATTERN ... [PATH ...] - rg [OPTIONS] -f PATTERNFILE ... [PATH ...] - rg [OPTIONS] --files [PATH ...] - rg [OPTIONS] --type-list + rg [OPTIONS] PATTERN [PATH ...] + rg [OPTIONS] -e PATTERN ... [PATH ...] + rg [OPTIONS] -f PATTERNFILE ... [PATH ...] + rg [OPTIONS] --files [PATH ...] + rg [OPTIONS] --type-list  command | rg [OPTIONS] PATTERN - rg [OPTIONS] --help - rg [OPTIONS] --version + rg [OPTIONS] --help + rg [OPTIONS] --version ARGS:    diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index cf06dee..04012b1 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -116,6 +116,8 @@ app installation (see also `adb shell cmd package help`): debugging: bugreport [PATH] +#^^^^^^^^^ constant.other.keyword.cmd-help +# ^^^^ keyword.other.argument.cmd-help write bugreport to given PATH [default=bugreport.zip]; if PATH is a directory, the bug report is saved in that directory. devices that don't support zipped bug reports output to stdout. diff --git a/tests/syntax/syntax_test_bat.txt b/tests/syntax/syntax_test_bat.txt index 8df3a14..e8c0a57 100644 --- a/tests/syntax/syntax_test_bat.txt +++ b/tests/syntax/syntax_test_bat.txt @@ -7,6 +7,8 @@ USAGE: # <- string.section-heading.cmd-help #^^^^^ string.section-heading.cmd-help bat [OPTIONS] [FILE]... +# ^^^^^^^ keyword.other.argument.cmd-help +#fixme: unscope this bat OPTIONS: From ceefab364827b4634001199332e7eb5c11a7e70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 01:31:20 +0200 Subject: [PATCH 13/43] Scope "keyword ARGUMENT" But this introduces quite a bit of regression. See syntax_test_cp --- syntaxes/cmd-help.sublime-syntax | 4 ++++ tests/highlighted/adb-1.0.41.txt | 10 +++++----- tests/highlighted/cabal-3.6.2.0.txt | 2 +- tests/highlighted/cp-8.30.txt | 4 ++-- tests/highlighted/dd-8.30.txt | 2 +- tests/highlighted/jq-1.6.txt | 2 +- tests/highlighted/ln-8.30.txt | 2 +- tests/syntax/syntax_test_adb.txt | 6 ++++-- tests/syntax/syntax_test_cp.txt | 3 +++ 9 files changed, 22 insertions(+), 13 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index afb1eb0..26a3701 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -448,6 +448,10 @@ contexts: captures: 1: *KEYWORD_SCOPES 2: *OPTION_SCOPES + - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})' + captures: + 1: *KEYWORD_SCOPES + 2: *ARGUMENT_SCOPES - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\]' captures: 1: *KEYWORD_SCOPES diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index cfe2776..a873c08 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -18,10 +18,10 @@  version show version num networking: - connect HOST[:PORT] connect to a device via TCP/IP [default port=5555] + connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]  disconnect [HOST[:PORT]]  disconnect from given TCP/IP device [default port=5555], or all - pair HOST[:PORT] [PAIRING CODE] + pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication  forward --list list all forward socket connections  forward [--no-rebind] LOCAL REMOTE @@ -36,7 +36,7 @@  acceptfd: (listen only)  forward --remove LOCAL remove specific forward socket connection  forward --remove-all remove all forward socket connections - ppp TTY [PARAMETER...] run PPP over USB + ppp TTY [PARAMETER...] run PPP over USB  reverse --list list all reverse socket connections from device  reverse [--no-rebind] REMOTE LOCAL  reverse socket connection using: @@ -108,7 +108,7 @@ debugging:  bugreport [PATH]  write bugreport to given PATH [default=bugreport.zip]; - if PATH is a directory, the bug report is saved in that directory. + if PATH is a directory, the bug report is saved in that directory.  devices that don't support zipped bug reports output to stdout.  jdwp list pids of processes hosting a JDWP transport  logcat show device log (logcat --help for more) @@ -116,7 +116,7 @@ security:  disable-verity disable dm-verity checking on userdebug builds  enable-verity re-enable dm-verity checking on userdebug builds - keygen FILE + keygen FILE  generate adb public/private key; private key stored in FILE, scripting: diff --git a/tests/highlighted/cabal-3.6.2.0.txt b/tests/highlighted/cabal-3.6.2.0.txt index af5cbd2..b3b3f1f 100644 --- a/tests/highlighted/cabal-3.6.2.0.txt +++ b/tests/highlighted/cabal-3.6.2.0.txt @@ -76,7 +76,7 @@  v1-reconfigure Reconfigure the package if necessary. For more information about a command use: - cabal COMMAND --help + cabal COMMAND --help or cabal help COMMAND To install Cabal packages from hackage use: diff --git a/tests/highlighted/cp-8.30.txt b/tests/highlighted/cp-8.30.txt index 65ed568..2b9615e 100644 --- a/tests/highlighted/cp-8.30.txt +++ b/tests/highlighted/cp-8.30.txt @@ -52,7 +52,7 @@  --version output version information and exit By default, sparse SOURCE files are detected by a crude heuristic and the -corresponding DEST file is made sparse as well. That is the behavior +corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. @@ -64,7 +64,7 @@ The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/highlighted/dd-8.30.txt b/tests/highlighted/dd-8.30.txt index d9decee..7f6bc92 100644 --- a/tests/highlighted/dd-8.30.txt +++ b/tests/highlighted/dd-8.30.txt @@ -62,7 +62,7 @@  seek_bytes treat 'seek=N' as a byte count (oflag only) Sending a USR1 signal to a running 'dd' process makes it -print I/O statistics to standard error and then resume copying. +print I/O statistics to standard error and then resume copying. Options are: diff --git a/tests/highlighted/jq-1.6.txt b/tests/highlighted/jq-1.6.txt index a139603..67da82c 100644 --- a/tests/highlighted/jq-1.6.txt +++ b/tests/highlighted/jq-1.6.txt @@ -5,7 +5,7 @@  jq [options] --jsonargs [JSON_TEXTS...] jq is a tool for processing JSON inputs, applying the given filter to -its JSON text inputs and producing the filter's results as JSON on +its JSON text inputs and producing the filter's results as JSON on standard output. The simplest filter is ., which copies jq's input to its output diff --git a/tests/highlighted/ln-8.30.txt b/tests/highlighted/ln-8.30.txt index cc891b8..a1568c0 100644 --- a/tests/highlighted/ln-8.30.txt +++ b/tests/highlighted/ln-8.30.txt @@ -35,7 +35,7 @@ The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 04012b1..eb6e55f 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -24,6 +24,8 @@ general commands: networking: connect HOST[:PORT] connect to a device via TCP/IP [default port=5555] +#^^^^^^^ constant.other.keyword.cmd-help +# ^^^^ keyword.other.argument.cmd-help disconnect [HOST[:PORT]] disconnect from given TCP/IP device [default port=5555], or all pair HOST[:PORT] [PAIRING CODE] @@ -154,8 +156,8 @@ scripting: usb restart adbd listening on USB tcpip PORT restart adbd listening on TCP on PORT #^^^^^ constant.other.keyword.cmd-help -# ^ - constant.other.keyword.cmd-help variable.parameter.option-argument.cmd-help -# ^^^^ entity.name.function.option.cmd-help keyword.other.argument.cmd-help +# ^ - constant.other.keyword.cmd-help keyword.other.argument.cmd-help +# ^^^^ keyword.other.argument.cmd-help #nit: make the first scope of the argument "constant.other.def" internal debugging: diff --git a/tests/syntax/syntax_test_cp.txt b/tests/syntax/syntax_test_cp.txt index 8fd1810..07a8604 100644 --- a/tests/syntax/syntax_test_cp.txt +++ b/tests/syntax/syntax_test_cp.txt @@ -61,6 +61,9 @@ Mandatory arguments to long options are mandatory for short options too. By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior +#^^^^^^^^^^^^ constant.other.keyword.cmd-help +# ^^^^ keyword.other.argument.cmd-help +#fixme selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. From 2157efe38061be2a15ab445560a12555285895de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 01:38:14 +0200 Subject: [PATCH 14/43] Require a long space after "keyword ARG" to fix regressions --- syntaxes/cmd-help.sublime-syntax | 2 +- tests/highlighted/adb-1.0.41.txt | 6 +++--- tests/highlighted/cabal-3.6.2.0.txt | 2 +- tests/highlighted/cp-8.30.txt | 4 ++-- tests/highlighted/dd-8.30.txt | 2 +- tests/highlighted/jq-1.6.txt | 2 +- tests/highlighted/ln-8.30.txt | 2 +- tests/syntax/syntax_test_adb.txt | 2 +- tests/syntax/syntax_test_cp.txt | 5 ++--- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 26a3701..f48702c 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -448,7 +448,7 @@ contexts: captures: 1: *KEYWORD_SCOPES 2: *OPTION_SCOPES - - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})' + - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})(?= .*{{long_space}})' captures: 1: *KEYWORD_SCOPES 2: *ARGUMENT_SCOPES diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index a873c08..cdfc218 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -18,10 +18,10 @@  version show version num networking: - connect HOST[:PORT] connect to a device via TCP/IP [default port=5555] + connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]  disconnect [HOST[:PORT]]  disconnect from given TCP/IP device [default port=5555], or all - pair HOST[:PORT] [PAIRING CODE] + pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication  forward --list list all forward socket connections  forward [--no-rebind] LOCAL REMOTE @@ -108,7 +108,7 @@ debugging:  bugreport [PATH]  write bugreport to given PATH [default=bugreport.zip]; - if PATH is a directory, the bug report is saved in that directory. + if PATH is a directory, the bug report is saved in that directory.  devices that don't support zipped bug reports output to stdout.  jdwp list pids of processes hosting a JDWP transport  logcat show device log (logcat --help for more) diff --git a/tests/highlighted/cabal-3.6.2.0.txt b/tests/highlighted/cabal-3.6.2.0.txt index b3b3f1f..af5cbd2 100644 --- a/tests/highlighted/cabal-3.6.2.0.txt +++ b/tests/highlighted/cabal-3.6.2.0.txt @@ -76,7 +76,7 @@  v1-reconfigure Reconfigure the package if necessary. For more information about a command use: - cabal COMMAND --help + cabal COMMAND --help or cabal help COMMAND To install Cabal packages from hackage use: diff --git a/tests/highlighted/cp-8.30.txt b/tests/highlighted/cp-8.30.txt index 2b9615e..65ed568 100644 --- a/tests/highlighted/cp-8.30.txt +++ b/tests/highlighted/cp-8.30.txt @@ -52,7 +52,7 @@  --version output version information and exit By default, sparse SOURCE files are detected by a crude heuristic and the -corresponding DEST file is made sparse as well. That is the behavior +corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. @@ -64,7 +64,7 @@ The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/highlighted/dd-8.30.txt b/tests/highlighted/dd-8.30.txt index 7f6bc92..d9decee 100644 --- a/tests/highlighted/dd-8.30.txt +++ b/tests/highlighted/dd-8.30.txt @@ -62,7 +62,7 @@  seek_bytes treat 'seek=N' as a byte count (oflag only) Sending a USR1 signal to a running 'dd' process makes it -print I/O statistics to standard error and then resume copying. +print I/O statistics to standard error and then resume copying. Options are: diff --git a/tests/highlighted/jq-1.6.txt b/tests/highlighted/jq-1.6.txt index 67da82c..a139603 100644 --- a/tests/highlighted/jq-1.6.txt +++ b/tests/highlighted/jq-1.6.txt @@ -5,7 +5,7 @@  jq [options] --jsonargs [JSON_TEXTS...] jq is a tool for processing JSON inputs, applying the given filter to -its JSON text inputs and producing the filter's results as JSON on +its JSON text inputs and producing the filter's results as JSON on standard output. The simplest filter is ., which copies jq's input to its output diff --git a/tests/highlighted/ln-8.30.txt b/tests/highlighted/ln-8.30.txt index a1568c0..cc891b8 100644 --- a/tests/highlighted/ln-8.30.txt +++ b/tests/highlighted/ln-8.30.txt @@ -35,7 +35,7 @@ The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index eb6e55f..651806f 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -25,7 +25,7 @@ general commands: networking: connect HOST[:PORT] connect to a device via TCP/IP [default port=5555] #^^^^^^^ constant.other.keyword.cmd-help -# ^^^^ keyword.other.argument.cmd-help +# ^^^^ - keyword.other.argument.cmd-help disconnect [HOST[:PORT]] disconnect from given TCP/IP device [default port=5555], or all pair HOST[:PORT] [PAIRING CODE] diff --git a/tests/syntax/syntax_test_cp.txt b/tests/syntax/syntax_test_cp.txt index 07a8604..ea0431e 100644 --- a/tests/syntax/syntax_test_cp.txt +++ b/tests/syntax/syntax_test_cp.txt @@ -61,9 +61,8 @@ Mandatory arguments to long options are mandatory for short options too. By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior -#^^^^^^^^^^^^ constant.other.keyword.cmd-help -# ^^^^ keyword.other.argument.cmd-help -#fixme +#^^^^^^^^^^^^ - constant.other.keyword.cmd-help +# ^^^^ - keyword.other.argument.cmd-help selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. From 9887fbd55d03281762cbb841bcbc7235d7b80aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 13:40:42 +0200 Subject: [PATCH 15/43] Add gdiffm util to get regression diff with main --- scripts/env.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/env.sh b/scripts/env.sh index 647395a..2ecf47d 100644 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -3,9 +3,15 @@ function gdiff { GIT_PAGER="LESS=R less" git diff "$@" -- tests/{highlighted,theme} } + function gdiffs { gdiff --staged "$@" } + +function gdiffm { + gdiff main "$@" +} + # to exclude e.g. THEME-italics, do: # gdiff -- ":^*-italics*" From 57748ffe632ec595958f82fa951b817b0c5cb9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 13:42:54 +0200 Subject: [PATCH 16/43] Rename scripts/env.sh to ../utils The shelcheck directive is explained here: https://www.shellcheck.net/wiki/SC2148 --- scripts/{env.sh => utils} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename scripts/{env.sh => utils} (92%) diff --git a/scripts/env.sh b/scripts/utils similarity index 92% rename from scripts/env.sh rename to scripts/utils index 2ecf47d..3e14b66 100644 --- a/scripts/env.sh +++ b/scripts/utils @@ -1,4 +1,5 @@ -#!/bin/bash +# usage: source scripts/utils +# shellcheck shell=bash function gdiff { GIT_PAGER="LESS=R less" git diff "$@" -- tests/{highlighted,theme} From a064b0f2d8275e048758bb528d38d006bd3c3f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 16:53:16 +0200 Subject: [PATCH 17/43] Don't scope the 2nd term after a subcommand To avoid inconsistent scoping in the usage/examples section of a bunch of help messages. But keep these scope assignations as comments, for future reference. --- syntaxes/cmd-help.sublime-syntax | 8 ++--- tests/highlighted/adb-1.0.41.txt | 46 +++++++++++++------------- tests/highlighted/bat-0.18.2.txt | 2 +- tests/highlighted/bat-short-0.18.2.txt | 2 +- tests/highlighted/chown-8.30.txt | 2 +- tests/highlighted/mount-2.34.0.txt | 4 +-- tests/highlighted/npm-8.1.2.txt | 2 +- tests/highlighted/ripgrep-13.0.0.txt | 14 ++++---- tests/syntax/syntax_test_adb.txt | 18 +++++----- tests/syntax/syntax_test_bat.txt | 3 +- tests/syntax/syntax_test_chown.txt | 3 +- 11 files changed, 50 insertions(+), 54 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index f48702c..441b7cc 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -442,20 +442,20 @@ contexts: - match: '({{other_lowercase_name}}) (-{{option_name}})' captures: 1: *KEYWORD_SCOPES - 2: *OPTION_SCOPES + # 2: *OPTION_SCOPES # e.g.: "devices [-l]" (from adb) - match: '({{other_lowercase_name}}) \[(-{{option_name}})\]' captures: 1: *KEYWORD_SCOPES - 2: *OPTION_SCOPES + # 2: *OPTION_SCOPES - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})(?= .*{{long_space}})' captures: 1: *KEYWORD_SCOPES - 2: *ARGUMENT_SCOPES + # 2: *ARGUMENT_SCOPES - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\]' captures: 1: *KEYWORD_SCOPES - 2: *ARGUMENT_SCOPES + # 2: *ARGUMENT_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index cdfc218..98442f6 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -13,7 +13,7 @@  -L SOCKET listen on given socket for adb server [default=tcp:localhost:5037] general commands: - devices [-l] list connected devices (-l for long output) + devices [-l] list connected devices (-l for long output)  help show this help message  version show version num @@ -23,8 +23,8 @@  disconnect from given TCP/IP device [default port=5555], or all  pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication - forward --list list all forward socket connections - forward [--no-rebind] LOCAL REMOTE + forward --list list all forward socket connections + forward [--no-rebind] LOCAL REMOTE  forward socket connection using:  tcp: ( may be "tcp:0" to pick any open port)  localabstract: @@ -34,34 +34,34 @@  jdwp: (remote only)  vsock:: (remote only)  acceptfd: (listen only) - forward --remove LOCAL remove specific forward socket connection - forward --remove-all remove all forward socket connections - ppp TTY [PARAMETER...] run PPP over USB - reverse --list list all reverse socket connections from device - reverse [--no-rebind] REMOTE LOCAL + forward --remove LOCAL remove specific forward socket connection + forward --remove-all remove all forward socket connections + ppp TTY [PARAMETER...] run PPP over USB + reverse --list list all reverse socket connections from device + reverse [--no-rebind] REMOTE LOCAL  reverse socket connection using:  tcp: ( may be "tcp:0" to pick any open port)  localabstract:  localreserved:  localfilesystem: - reverse --remove REMOTE remove specific reverse socket connection - reverse --remove-all remove all reverse socket connections from device + reverse --remove REMOTE remove specific reverse socket connection + reverse --remove-all remove all reverse socket connections from device  mdns check check if mdns discovery is available  mdns services list all discovered services file transfer: - push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE + push [--sync] [-z ALGORITHM] [-Z] LOCAL... REMOTE  copy local files/directories to device  --sync: only push files that are newer on the host than the device  -n: dry run: push files to device without storing to the filesystem  -z: enable compression with a specified algorithm (any, none, brotli)  -Z: disable compression - pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL + pull [-a] [-z ALGORITHM] [-Z] REMOTE... LOCAL  copy files/dirs from device  -a: preserve file timestamp and mode  -z: enable compression with a specified algorithm (any, none, brotli)  -Z: disable compression - sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendor] + sync [-l] [-z ALGORITHM] [-Z] [all|data|odm|oem|product|system|system_ext|vendor]  sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)  -n: dry run: push files to device without storing to the filesystem  -l: list files that would be copied, but don't copy them @@ -76,14 +76,14 @@  -T: disable pty allocation  -t: allocate a pty if on a tty (-tt: force pty allocation)  -x: disable remote exit codes and stdout/stderr separation - emu COMMAND run emulator console command + emu COMMAND run emulator console command app installation (see also `adb shell cmd package help`): - install [-lrtsdg] [--instant] PACKAGE + install [-lrtsdg] [--instant] PACKAGE  push a single package to the device and install it - install-multiple [-lrtsdpg] [--instant] PACKAGE... + install-multiple [-lrtsdpg] [--instant] PACKAGE...  push multiple APKs to the device for a single package and install them - install-multi-package [-lrtsdpg] [--instant] PACKAGE... + install-multi-package [-lrtsdpg] [--instant] PACKAGE...  push one or more packages to the device and install them atomically  -r: replace existing application  -t: allow test packages @@ -101,12 +101,12 @@  --version-check-agent: update deployment agent when local version has different version code and using fast deploy  --local-agent: locate agent files from local source build (instead of SDK location)  (See also `adb shell pm help` for more options.) - uninstall [-k] PACKAGE + uninstall [-k] PACKAGE  remove this app package from the device  '-k': keep the data and cache directories debugging: - bugreport [PATH] + bugreport [PATH]  write bugreport to given PATH [default=bugreport.zip];  if PATH is a directory, the bug report is saved in that directory.  devices that don't support zipped bug reports output to stdout. @@ -116,7 +116,7 @@ security:  disable-verity disable dm-verity checking on userdebug builds  enable-verity re-enable dm-verity checking on userdebug builds - keygen FILE + keygen FILE  generate adb public/private key; private key stored in FILE, scripting: @@ -127,7 +127,7 @@  get-state print offline | bootloader | device  get-serialno print   get-devpath print  - remount [-R] + remount [-R]  remount partitions read-write. if a reboot is required, -R will  will automatically reboot the device.  reboot [bootloader|recovery|sideload|sideload-auto-reboot] @@ -135,11 +135,11 @@  supports bootloader and recovery too. sideload reboots  into recovery and automatically starts sideload mode,  sideload-auto-reboot is the same but reboots after sideloading. - sideload OTAPACKAGE sideload the given full OTA package + sideload OTAPACKAGE sideload the given full OTA package  root restart adbd with root permissions  unroot restart adbd without root permissions  usb restart adbd listening on USB - tcpip PORT restart adbd listening on TCP on PORT + tcpip PORT restart adbd listening on TCP on PORT internal debugging:  start-server ensure that there is a server running diff --git a/tests/highlighted/bat-0.18.2.txt b/tests/highlighted/bat-0.18.2.txt index a71d9df..5746bac 100644 --- a/tests/highlighted/bat-0.18.2.txt +++ b/tests/highlighted/bat-0.18.2.txt @@ -2,7 +2,7 @@ A cat(1) clone with syntax highlighting and Git integration. USAGE: - bat [OPTIONS] [FILE]... + bat [OPTIONS] [FILE]...  bat  OPTIONS: diff --git a/tests/highlighted/bat-short-0.18.2.txt b/tests/highlighted/bat-short-0.18.2.txt index 10cb885..ff37fd1 100644 --- a/tests/highlighted/bat-short-0.18.2.txt +++ b/tests/highlighted/bat-short-0.18.2.txt @@ -2,7 +2,7 @@ A cat(1) clone with syntax highlighting and Git integration. USAGE: - bat [OPTIONS] [FILE]... + bat [OPTIONS] [FILE]...  bat  OPTIONS: diff --git a/tests/highlighted/chown-8.30.txt b/tests/highlighted/chown-8.30.txt index 9658673..07d082b 100644 --- a/tests/highlighted/chown-8.30.txt +++ b/tests/highlighted/chown-8.30.txt @@ -42,7 +42,7 @@ Examples:  chown root /u Change the owner of /u to "root".  chown root:staff /u Likewise, but also change its group to "staff". - chown -hR root /u Change the owner of /u and subfiles to "root". + chown -hR root /u Change the owner of /u and subfiles to "root". GNU coreutils online help:  Full documentation at:  diff --git a/tests/highlighted/mount-2.34.0.txt b/tests/highlighted/mount-2.34.0.txt index bebaf69..2d65784 100644 --- a/tests/highlighted/mount-2.34.0.txt +++ b/tests/highlighted/mount-2.34.0.txt @@ -1,7 +1,7 @@ Usage: - mount [-lhV] - mount -a [options] + mount [-lhV] + mount -a [options]  mount [options] [--source] | [--target]   mount [options]   mount [] diff --git a/tests/highlighted/npm-8.1.2.txt b/tests/highlighted/npm-8.1.2.txt index edc2a50..2b9bc87 100644 --- a/tests/highlighted/npm-8.1.2.txt +++ b/tests/highlighted/npm-8.1.2.txt @@ -7,7 +7,7 @@ npm test run this project's tests npm run run the script named  npm -h quick help on  -npm -l display usage info for all commands +npm -l display usage info for all commands npm help search for help on  npm help npm more involved overview diff --git a/tests/highlighted/ripgrep-13.0.0.txt b/tests/highlighted/ripgrep-13.0.0.txt index d404a77..c30e26e 100644 --- a/tests/highlighted/ripgrep-13.0.0.txt +++ b/tests/highlighted/ripgrep-13.0.0.txt @@ -11,14 +11,14 @@ USAGE: - rg [OPTIONS] PATTERN [PATH ...] - rg [OPTIONS] -e PATTERN ... [PATH ...] - rg [OPTIONS] -f PATTERNFILE ... [PATH ...] - rg [OPTIONS] --files [PATH ...] - rg [OPTIONS] --type-list + rg [OPTIONS] PATTERN [PATH ...] + rg [OPTIONS] -e PATTERN ... [PATH ...] + rg [OPTIONS] -f PATTERNFILE ... [PATH ...] + rg [OPTIONS] --files [PATH ...] + rg [OPTIONS] --type-list  command | rg [OPTIONS] PATTERN - rg [OPTIONS] --help - rg [OPTIONS] --version + rg [OPTIONS] --help + rg [OPTIONS] --version ARGS:    diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 651806f..df212bd 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -17,8 +17,7 @@ global options: general commands: devices [-l] list connected devices (-l for long output) #^^^^^^^ constant.other.keyword.cmd-help -# ^ - constant.other.keyword.cmd-help entity.name.function.option.cmd-help -# ^^ entity.name.function.option.cmd-help +# ^^ - entity.name.function.option.cmd-help help show this help message version show version num @@ -27,12 +26,14 @@ networking: #^^^^^^^ constant.other.keyword.cmd-help # ^^^^ - keyword.other.argument.cmd-help disconnect [HOST[:PORT]] +#^^^^^^^^^^ - constant.other.keyword.cmd-help +# ^^^^ - keyword.other.argument.cmd-help disconnect from given TCP/IP device [default port=5555], or all pair HOST[:PORT] [PAIRING CODE] pair with a device for secure TCP/IP communication forward --list list all forward socket connections #^^^^^^^ constant.other.keyword.cmd-help -# ^^^^^^ entity.name.function.option.cmd-help +# ^^^^^^ - entity.name.function.option.cmd-help forward [--no-rebind] LOCAL REMOTE forward socket connection using: tcp: ( may be "tcp:0" to pick any open port) @@ -119,7 +120,7 @@ app installation (see also `adb shell cmd package help`): debugging: bugreport [PATH] #^^^^^^^^^ constant.other.keyword.cmd-help -# ^^^^ keyword.other.argument.cmd-help +# ^^^^ - keyword.other.argument.cmd-help write bugreport to given PATH [default=bugreport.zip]; if PATH is a directory, the bug report is saved in that directory. devices that don't support zipped bug reports output to stdout. @@ -130,8 +131,7 @@ security: disable-verity disable dm-verity checking on userdebug builds enable-verity re-enable dm-verity checking on userdebug builds keygen FILE -#^^^^^^ - keyword.other.def.cmd-help -#fixme: other-def-seq ending in newline +#^^^^^^ constant.other.keyword.cmd-help generate adb public/private key; private key stored in FILE, scripting: @@ -156,9 +156,8 @@ scripting: usb restart adbd listening on USB tcpip PORT restart adbd listening on TCP on PORT #^^^^^ constant.other.keyword.cmd-help -# ^ - constant.other.keyword.cmd-help keyword.other.argument.cmd-help -# ^^^^ keyword.other.argument.cmd-help -#nit: make the first scope of the argument "constant.other.def" +# ^^^^ - keyword.other.argument.cmd-help +#nit: make the first scope of the argument "constant.other.keyword" internal debugging: start-server ensure that there is a server running @@ -166,7 +165,6 @@ internal debugging: reconnect kick connection from host side to force reconnect reconnect device kick connection from device side to force reconnect #^^^^^^^^^ constant.other.keyword.cmd-help -# ^ - constant.other.keyword.cmd-help # ^^^^^^ - constant.other.keyword.cmd-help #nice: subcommand + subcommand/enum reconnect offline reset offline/unauthorized devices to force reconnect diff --git a/tests/syntax/syntax_test_bat.txt b/tests/syntax/syntax_test_bat.txt index e8c0a57..ec758f2 100644 --- a/tests/syntax/syntax_test_bat.txt +++ b/tests/syntax/syntax_test_bat.txt @@ -7,8 +7,7 @@ USAGE: # <- string.section-heading.cmd-help #^^^^^ string.section-heading.cmd-help bat [OPTIONS] [FILE]... -# ^^^^^^^ keyword.other.argument.cmd-help -#fixme: unscope this +# ^^^^^^^ - keyword.other.argument.cmd-help bat OPTIONS: diff --git a/tests/syntax/syntax_test_chown.txt b/tests/syntax/syntax_test_chown.txt index a4d394e..7c41497 100644 --- a/tests/syntax/syntax_test_chown.txt +++ b/tests/syntax/syntax_test_chown.txt @@ -51,8 +51,7 @@ Examples: # ^^^^^ #nit: scope this to make it consistent with the other 2 examples chown -hR root /u Change the owner of /u and subfiles to "root". -# ^^^ entity.name.function.option.cmd-help -#nit: don't scope this as option +# ^^^ - entity.name.function.option.cmd-help GNU coreutils online help: Full documentation at: From f59e14e415e305850673ffe1ddd0d92057603e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 17:04:13 +0200 Subject: [PATCH 18/43] Handle "disconnect [HOST[:PORT]]" from adb --- syntaxes/cmd-help.sublime-syntax | 8 ++++++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/syntax/syntax_test_adb.txt | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 441b7cc..bf165d0 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -448,14 +448,22 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *OPTION_SCOPES + # e.g.: "connect HOST[:PORT] ..." (from adb) - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})(?= .*{{long_space}})' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + # e.g.: "bugreport [PATH]" (from adb) - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\]' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + # e.g.: "disconnect [HOST[:PORT]]" (from adb) + - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\[' + captures: + 1: *KEYWORD_SCOPES + # 2: *ARGUMENT_SCOPES + #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' - match: '{{other_lowercase_name}}(?= .*{{long_space}})' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 98442f6..baab0aa 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -19,7 +19,7 @@ networking:  connect HOST[:PORT] connect to a device via TCP/IP [default port=5555] - disconnect [HOST[:PORT]] + disconnect [HOST[:PORT]]  disconnect from given TCP/IP device [default port=5555], or all  pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index df212bd..9185a42 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -26,7 +26,7 @@ networking: #^^^^^^^ constant.other.keyword.cmd-help # ^^^^ - keyword.other.argument.cmd-help disconnect [HOST[:PORT]] -#^^^^^^^^^^ - constant.other.keyword.cmd-help +#^^^^^^^^^^ constant.other.keyword.cmd-help # ^^^^ - keyword.other.argument.cmd-help disconnect from given TCP/IP device [default port=5555], or all pair HOST[:PORT] [PAIRING CODE] @@ -157,7 +157,7 @@ scripting: tcpip PORT restart adbd listening on TCP on PORT #^^^^^ constant.other.keyword.cmd-help # ^^^^ - keyword.other.argument.cmd-help -#nit: make the first scope of the argument "constant.other.keyword" +#nit: make the first scope of the argument: "constant.other.keyword" internal debugging: start-server ensure that there is a server running From fda6af9152c40c2c26c1bf54be43574be98c68af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 17:07:37 +0200 Subject: [PATCH 19/43] Handle ""pair HOST[:PORT] ..." from adb Only the "pair" bit. This is all so overfitted, to suit adb's help message only, that it's making me feel icky. But, on the other hand, it's also a good census of all kinds of patterns that we don't currently have a proper way to handle. And if it doesn't add too many unnecessary scopes for other help messages, I don't care much, I guess? --- syntaxes/cmd-help.sublime-syntax | 5 +++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/syntax/syntax_test_adb.txt | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index bf165d0..3024de6 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -463,6 +463,11 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + # e.g.: "pair HOST[:PORT] [PAIRING CODE]" (from adb) + - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})\[' + captures: + 1: *KEYWORD_SCOPES + # 2: *ARGUMENT_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index baab0aa..76962ea 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -21,7 +21,7 @@  connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]  disconnect [HOST[:PORT]]  disconnect from given TCP/IP device [default port=5555], or all - pair HOST[:PORT] [PAIRING CODE] + pair HOST[:PORT] [PAIRING CODE]  pair with a device for secure TCP/IP communication  forward --list list all forward socket connections  forward [--no-rebind] LOCAL REMOTE diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 9185a42..e3fee9c 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -30,6 +30,8 @@ networking: # ^^^^ - keyword.other.argument.cmd-help disconnect from given TCP/IP device [default port=5555], or all pair HOST[:PORT] [PAIRING CODE] +#^^^^ constant.other.keyword.cmd-help +# ^^^^ - keyword.other.argument.cmd-help pair with a device for secure TCP/IP communication forward --list list all forward socket connections #^^^^^^^ constant.other.keyword.cmd-help From e42fe00f614cc5dc7b45699f0f00c7c7161151c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 17:13:29 +0200 Subject: [PATCH 20/43] Handle "shell [-e ESCAPE] ..." from adb --- syntaxes/cmd-help.sublime-syntax | 6 ++++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/syntax/syntax_test_adb.txt | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 3024de6..75e6ffe 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -468,6 +468,12 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + # e.g.: "shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]" (from adb) + - match: '({{other_lowercase_name}}) \[(-{{option_name}}) ({{allcaps_argument_name}})\]' + captures: + 1: *KEYWORD_SCOPES + # 2: *OPTION_SCOPES + # 3: *ARGUMENT_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index 76962ea..f990f24 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -69,7 +69,7 @@  -Z: disable compression shell: - shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...] + shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]  run remote shell command (interactive shell if no command given)  -e: choose escape character, or "none"; default '~'  -n: don't read from stdin diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index e3fee9c..7ed6be5 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -84,6 +84,9 @@ file transfer: shell: shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...] +#^^^^ constant.other.keyword.cmd-help +# ^^ - entity.name.function.option.cmd-help +# ^^^^^^ - keyword.other.argument.cmd-help run remote shell command (interactive shell if no command given) -e: choose escape character, or "none"; default '~' -n: don't read from stdin From 11071bb945b31df51a865d4fb1b40d3445fee055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 17:35:45 +0200 Subject: [PATCH 21/43] Handle "shell [-e ESCAPE] ..." from adb --- syntaxes/cmd-help.sublime-syntax | 5 +++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/syntax/syntax_test_adb.txt | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 75e6ffe..35f9c6f 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -474,6 +474,11 @@ contexts: 1: *KEYWORD_SCOPES # 2: *OPTION_SCOPES # 3: *ARGUMENT_SCOPES + # e.g.: "wait-for[-TRANSPORT]-STATE..." (from adb) + - match: '({{other_lowercase_name}})\[(-{{allcaps_argument_name}})\]' + captures: + 1: *KEYWORD_SCOPES + # 2: *ARGUMENT_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index f990f24..c96d514 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -120,7 +120,7 @@  generate adb public/private key; private key stored in FILE, scripting: - wait-for[-TRANSPORT]-STATE... + wait-for[-TRANSPORT]-STATE...  wait for device to be in a given state  STATE: device, recovery, rescue, sideload, bootloader, or disconnect  TRANSPORT: usb, local, or any [default=any] diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 7ed6be5..13cfa53 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -141,6 +141,10 @@ security: scripting: wait-for[-TRANSPORT]-STATE... +#^^^^^^^^ constant.other.keyword.cmd-help +# ^^^^^^^^^^ - keyword.other.argument.cmd-help +# ^^^^^^^^^ entity.name.function.option.cmd-help +#fixme: unscope -STATE wait for device to be in a given state STATE: device, recovery, rescue, sideload, bootloader, or disconnect TRANSPORT: usb, local, or any [default=any] From 938f74baa18a776bca7c91e842f25f504a687f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 17:40:36 +0200 Subject: [PATCH 22/43] Handle "reboot [bootloader|recovery|..." from adb --- syntaxes/cmd-help.sublime-syntax | 5 +++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/syntax/syntax_test_adb.txt | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 35f9c6f..eab490b 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -479,6 +479,11 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + # e.g.: " reboot [bootloader|recovery| ..." (from adb) + - match: '({{other_lowercase_name}}) \[({{relaxed_argument_name}})\|' + captures: + 1: *KEYWORD_SCOPES + # 2: *ARGUMENT_SCOPES #nice: limit the sequence to 3-4 terms top? #nice: add an other_term_seq_break including '\. |\: ' diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index c96d514..a6ebe8c 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -130,7 +130,7 @@  remount [-R]  remount partitions read-write. if a reboot is required, -R will  will automatically reboot the device. - reboot [bootloader|recovery|sideload|sideload-auto-reboot] + reboot [bootloader|recovery|sideload|sideload-auto-reboot]  reboot the device; defaults to booting system image but  supports bootloader and recovery too. sideload reboots  into recovery and automatically starts sideload mode, diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 13cfa53..949b924 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -155,6 +155,8 @@ scripting: remount partitions read-write. if a reboot is required, -R will will automatically reboot the device. reboot [bootloader|recovery|sideload|sideload-auto-reboot] +#^^^^^^ constant.other.keyword.cmd-help +# ^^^^^^^^^^ - keyword.other.argument.cmd-help reboot the device; defaults to booting system image but supports bootloader and recovery too. sideload reboots into recovery and automatically starts sideload mode, From 6a703413406d5cc15545796f7ccf5a6deed6c88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sat, 1 Jul 2023 17:46:53 +0200 Subject: [PATCH 23/43] Fix a stray, outdated syntax assertion --- tests/syntax/syntax_test_adb.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 949b924..5f6415d 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -57,8 +57,8 @@ networking: localreserved: localfilesystem: reverse --remove REMOTE remove specific reverse socket connection -#^^^^^^^ - keyword.other.def.cmd-help -#fixme: other-def-seq ending in 2 spaces +#^^^^^^^ constant.other.keyword.cmd-help +# ^^^^^^^^ - entity.name.function.option.cmd-help reverse --remove-all remove all reverse socket connections from device mdns check check if mdns discovery is available mdns services list all discovered services From f8bf10d7187ffbe5fc978b255d5b06c002c015f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 00:23:50 +0200 Subject: [PATCH 24/43] Rename regression test utils --- scripts/utils | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/utils b/scripts/utils index 3e14b66..f686c28 100644 --- a/scripts/utils +++ b/scripts/utils @@ -1,22 +1,24 @@ # usage: source scripts/utils # shellcheck shell=bash -function gdiff { +# regression tests diff +function reg { GIT_PAGER="LESS=R less" git diff "$@" -- tests/{highlighted,theme} } -function gdiffs { - gdiff --staged "$@" +function regs { + reg --staged "$@" } -function gdiffm { - gdiff main "$@" +function regm { + reg main "$@" } # to exclude e.g. THEME-italics, do: # gdiff -- ":^*-italics*" -function gshow { +# regression tests show +function regshow { GIT_PAGER="LESS=R less" git show "$@" -- tests/{highlighted,theme} } From 310a626838488fe5090f32fd234dd24106372e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 00:28:20 +0200 Subject: [PATCH 25/43] Reorganize & document dev utils --- scripts/utils | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/utils b/scripts/utils index f686c28..9af31fb 100644 --- a/scripts/utils +++ b/scripts/utils @@ -1,4 +1,4 @@ -# usage: source scripts/utils +# usage: $ source scripts/utils # shellcheck shell=bash # regression tests diff @@ -6,6 +6,9 @@ function reg { GIT_PAGER="LESS=R less" git diff "$@" -- tests/{highlighted,theme} } +# to exclude e.g. THEME-italics, do: +# reg -- ":^*-italics*" + function regs { reg --staged "$@" } @@ -14,9 +17,6 @@ function regm { reg main "$@" } -# to exclude e.g. THEME-italics, do: -# gdiff -- ":^*-italics*" - # regression tests show function regshow { GIT_PAGER="LESS=R less" git show "$@" -- tests/{highlighted,theme} @@ -24,15 +24,16 @@ function regshow { alias git0='GIT_CONFIG=/dev/null git' -debug() { +# run a syntax test in debug mode +function debug { tests/syntax.py "$@" -d | less -R } -demo() { +function demo { "$@" --help | bat --no-config -pl cmd-help --pager='less -R' } -demo_it() { +function demo_it { "$@" --help | bat --no-config -pl cmd-help --pager='less -R' --italic-text=always } From bd64ca0e00d06c9acef409862a062c63ca833252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 01:03:29 +0200 Subject: [PATCH 26/43] Remove subcommand-def-post We're handling subcommand sub-tokens in an explicit manner, without abstraction / generalization. At least for the time being. --- syntaxes/cmd-help.sublime-syntax | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index eab490b..6d342d8 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -484,16 +484,9 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES - - #nice: limit the sequence to 3-4 terms top? - #nice: add an other_term_seq_break including '\. |\: ' + # less restrictive match, catch all - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES - set: subcommand-def-post - - subcommand-def-post: - - match: ' (?={{allcaps_argument_name}}{{long_space}})' - set: option-term+space ### notable exceptions ####################################################### From 3de9f625069c51f0ddd44c7af287c87aa3bdb53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 01:14:33 +0200 Subject: [PATCH 27/43] Handle "bat " from bat Now we're scoping command keywords in usage lines so as to make them coherent. Otherwise, some help messages show usage lines with and without the command colorized. --- syntaxes/cmd-help.sublime-syntax | 7 ++++++- tests/highlighted/bat-0.18.2.txt | 2 +- tests/highlighted/bat-short-0.18.2.txt | 2 +- tests/highlighted/bat-short-23.0.0.txt | 2 +- tests/highlighted/mount-2.34.0.txt | 2 +- tests/highlighted/npm-8.1.2.txt | 2 +- tests/syntax/syntax_test_bat.txt | 6 +++++- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 6d342d8..fd9519e 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -479,11 +479,16 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES - # e.g.: " reboot [bootloader|recovery| ..." (from adb) + # e.g.: "reboot [bootloader|recovery| ..." (from adb) - match: '({{other_lowercase_name}}) \[({{relaxed_argument_name}})\|' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + # e.g.: "bat " (from bat) + - match: '({{other_lowercase_name}}) <({{relaxed_argument_name}})>' + captures: + 1: *KEYWORD_SCOPES + # 2: *KEYWORD_SCOPES # less restrictive match, catch all - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES diff --git a/tests/highlighted/bat-0.18.2.txt b/tests/highlighted/bat-0.18.2.txt index 5746bac..5858871 100644 --- a/tests/highlighted/bat-0.18.2.txt +++ b/tests/highlighted/bat-0.18.2.txt @@ -3,7 +3,7 @@ USAGE:  bat [OPTIONS] [FILE]... - bat  + bat  OPTIONS:  -A, --show-all  diff --git a/tests/highlighted/bat-short-0.18.2.txt b/tests/highlighted/bat-short-0.18.2.txt index ff37fd1..ecebb78 100644 --- a/tests/highlighted/bat-short-0.18.2.txt +++ b/tests/highlighted/bat-short-0.18.2.txt @@ -3,7 +3,7 @@ USAGE:  bat [OPTIONS] [FILE]... - bat  + bat  OPTIONS:  -A, --show-all Show non-printable characters (space, tab, newline, ..). diff --git a/tests/highlighted/bat-short-23.0.0.txt b/tests/highlighted/bat-short-23.0.0.txt index 59dccea..156eb2d 100644 --- a/tests/highlighted/bat-short-23.0.0.txt +++ b/tests/highlighted/bat-short-23.0.0.txt @@ -1,7 +1,7 @@ A cat(1) clone with wings. Usage: bat [OPTIONS] [FILE]... - bat  + bat  Arguments:  [FILE]... File(s) to print / concatenate. Use '-' for standard input. diff --git a/tests/highlighted/mount-2.34.0.txt b/tests/highlighted/mount-2.34.0.txt index 2d65784..4ddfa7c 100644 --- a/tests/highlighted/mount-2.34.0.txt +++ b/tests/highlighted/mount-2.34.0.txt @@ -4,7 +4,7 @@  mount -a [options]  mount [options] [--source] | [--target]   mount [options]  - mount [] + mount [] Mount a filesystem. diff --git a/tests/highlighted/npm-8.1.2.txt b/tests/highlighted/npm-8.1.2.txt index 2b9bc87..13fb6a9 100644 --- a/tests/highlighted/npm-8.1.2.txt +++ b/tests/highlighted/npm-8.1.2.txt @@ -1,4 +1,4 @@ -npm  +npm  Usage: diff --git a/tests/syntax/syntax_test_bat.txt b/tests/syntax/syntax_test_bat.txt index ec758f2..1f3bc05 100644 --- a/tests/syntax/syntax_test_bat.txt +++ b/tests/syntax/syntax_test_bat.txt @@ -7,8 +7,12 @@ USAGE: # <- string.section-heading.cmd-help #^^^^^ string.section-heading.cmd-help bat [OPTIONS] [FILE]... -# ^^^^^^^ - keyword.other.argument.cmd-help +# ^^^ constant.other.keyword.cmd-help +# ^^^^^^^ - entity.name.function.option.cmd-help bat +# ^^^ constant.other.keyword.cmd-help +# ^^^^^^^^^^^^ - constant.other.keyword.cmd-help +#todo: handle Usage lines OPTIONS: #^^^^^^^ string.section-heading.cmd-help From 885f8c80ab754a3b99ff1ff4603e563ef2651a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 01:43:20 +0200 Subject: [PATCH 28/43] Separate {{long_space}} and {{single_2_space}} I hoped to catch the tricky chown case with this, but I think I know why it's failing: we do not `set: then-pop" in keyword-seq-def matches !! As a side effect, we scoped "operand=VALUE" operands in dd, which is nice. As another side effect, we scoped "or:" usage lines in vim, which is bad but easy to fix (next commit). --- syntaxes/cmd-help.sublime-syntax | 8 +++++--- tests/highlighted/dd-8.30.txt | 26 +++++++++++++------------- tests/highlighted/vim-8.1.txt | 4 ++-- tests/syntax/syntax_test_chown.txt | 2 +- tests/syntax/syntax_test_dd.txt | 5 ++++- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index fd9519e..84ef904 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -32,8 +32,8 @@ variables: ### other-def variables: other_lowercase_name: '[a-z][0-9a-z_-]*\b' - long_space: ' |\t|\n|{{single_2_space}}' - single_2_space: ' (?!.*\S \S)' + long_space: ' |\t|\n' + lookahead_single_2_space: '(?=.* )(?!.*\S \S)' ### pathname variables: path_atom: '[0-9a-zA-Z._-]+' @@ -489,9 +489,11 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *KEYWORD_SCOPES - # less restrictive match, catch all + # less restrictive matches, catch all - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES + - match: '{{other_lowercase_name}}{{lookahead_single_2_space}}' + scope: *KEYWORD_SCOPES ### notable exceptions ####################################################### diff --git a/tests/highlighted/dd-8.30.txt b/tests/highlighted/dd-8.30.txt index d9decee..ef78693 100644 --- a/tests/highlighted/dd-8.30.txt +++ b/tests/highlighted/dd-8.30.txt @@ -2,20 +2,20 @@  or: dd OPTION Copy a file, converting and formatting according to the operands. - bs=BYTES read and write up to BYTES bytes at a time (default: 512); + bs=BYTES read and write up to BYTES bytes at a time (default: 512);  overrides ibs and obs - cbs=BYTES convert BYTES bytes at a time - conv=CONVS convert the file as per the comma separated symbol list - count=N copy only N input blocks - ibs=BYTES read up to BYTES bytes at a time (default: 512) - if=FILE read from FILE instead of stdin - iflag=FLAGS read as per the comma separated symbol list - obs=BYTES write BYTES bytes at a time (default: 512) - of=FILE write to FILE instead of stdout - oflag=FLAGS write as per the comma separated symbol list - seek=N skip N obs-sized blocks at start of output - skip=N skip N ibs-sized blocks at start of input - status=LEVEL The LEVEL of information to print to stderr; + cbs=BYTES convert BYTES bytes at a time + conv=CONVS convert the file as per the comma separated symbol list + count=N copy only N input blocks + ibs=BYTES read up to BYTES bytes at a time (default: 512) + if=FILE read from FILE instead of stdin + iflag=FLAGS read as per the comma separated symbol list + obs=BYTES write BYTES bytes at a time (default: 512) + of=FILE write to FILE instead of stdout + oflag=FLAGS write as per the comma separated symbol list + seek=N skip N obs-sized blocks at start of output + skip=N skip N ibs-sized blocks at start of input + status=LEVEL The LEVEL of information to print to stderr;  'none' suppresses everything but error messages,  'noxfer' suppresses the final transfer statistics,  'progress' shows periodic transfer statistics diff --git a/tests/highlighted/vim-8.1.txt b/tests/highlighted/vim-8.1.txt index 76bb2c2..263d076 100644 --- a/tests/highlighted/vim-8.1.txt +++ b/tests/highlighted/vim-8.1.txt @@ -1,8 +1,8 @@ VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32) Usage: vim [arguments] [file ..] edit specified file(s) - or: vim [arguments] - read text from stdin - or: vim [arguments] -t tag edit file where tag is defined + or: vim [arguments] - read text from stdin + or: vim [arguments] -t tag edit file where tag is defined  or: vim [arguments] -q [errorfile] edit file with first error Arguments: diff --git a/tests/syntax/syntax_test_chown.txt b/tests/syntax/syntax_test_chown.txt index 7c41497..2b084a4 100644 --- a/tests/syntax/syntax_test_chown.txt +++ b/tests/syntax/syntax_test_chown.txt @@ -49,7 +49,7 @@ Examples: # ^^^^^ constant.other.keyword.cmd-help chown root:staff /u Likewise, but also change its group to "staff". # ^^^^^ -#nit: scope this to make it consistent with the other 2 examples +#nit: scope this to make it consistent with the other 2 examples. chown -hR root /u Change the owner of /u and subfiles to "root". # ^^^ - entity.name.function.option.cmd-help diff --git a/tests/syntax/syntax_test_dd.txt b/tests/syntax/syntax_test_dd.txt index bfe1621..0dcf989 100644 --- a/tests/syntax/syntax_test_dd.txt +++ b/tests/syntax/syntax_test_dd.txt @@ -5,7 +5,10 @@ Usage: dd [OPERAND]... Copy a file, converting and formatting according to the operands. bs=BYTES read and write up to BYTES bytes at a time (default: 512); -#nice: should I scope these +# ^^ constant.other.keyword.cmd-help +# ^ - constant.other.keyword.cmd-help keyword.other.argument.cmd-help +# ^^^^^ - constant.other.keyword.cmd-help keyword.other.argument.cmd-help +#nice: scope these overrides ibs and obs cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list From 833cbb9dc544ba4dd8dfd03c812cc1bc07c2cfbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 01:50:43 +0200 Subject: [PATCH 29/43] Don't scope "or:" as keyword other Cause it's an alternative connector in Usage lines --- syntaxes/cmd-help.sublime-syntax | 2 ++ tests/highlighted/vim-8.1.txt | 4 ++-- tests/syntax/syntax_test_vim.txt | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 84ef904..5dee84e 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -386,6 +386,8 @@ contexts: # pretty common in "usage:" alternatives - match: (?=or\s) set: then-pop + - match: (?=or:) + set: then-pop keyword-def: - match: '{{other_lowercase_name}}(?={{long_space}})' diff --git a/tests/highlighted/vim-8.1.txt b/tests/highlighted/vim-8.1.txt index 263d076..76bb2c2 100644 --- a/tests/highlighted/vim-8.1.txt +++ b/tests/highlighted/vim-8.1.txt @@ -1,8 +1,8 @@ VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32) Usage: vim [arguments] [file ..] edit specified file(s) - or: vim [arguments] - read text from stdin - or: vim [arguments] -t tag edit file where tag is defined + or: vim [arguments] - read text from stdin + or: vim [arguments] -t tag edit file where tag is defined  or: vim [arguments] -q [errorfile] edit file with first error Arguments: diff --git a/tests/syntax/syntax_test_vim.txt b/tests/syntax/syntax_test_vim.txt index ae58b88..93ffb1c 100644 --- a/tests/syntax/syntax_test_vim.txt +++ b/tests/syntax/syntax_test_vim.txt @@ -4,6 +4,7 @@ VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 01 2022 09:16:32) Usage: vim [arguments] [file ..] edit specified file(s) or: vim [arguments] - read text from stdin +# ^^ - constant.other.keyword.cmd-help or: vim [arguments] -t tag edit file where tag is defined or: vim [arguments] -q [errorfile] edit file with first error From 751858f82a565933e26775067b87425649dfd55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 01:55:05 +0200 Subject: [PATCH 30/43] Properly `set: then-pop` after each keyword-seq-def match I hoped to catch the chown corner case with this but no such luck. Instead, we caught a stray adb bug that I had forgotten all about (but my syntax tests didn't :D ). --- syntaxes/cmd-help.sublime-syntax | 12 ++++++++++++ tests/highlighted/adb-1.0.41.txt | 2 +- tests/syntax/syntax_test_adb.txt | 3 +-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 5dee84e..06a91f1 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -445,57 +445,69 @@ contexts: captures: 1: *KEYWORD_SCOPES # 2: *OPTION_SCOPES + set: then-pop # e.g.: "devices [-l]" (from adb) - match: '({{other_lowercase_name}}) \[(-{{option_name}})\]' captures: 1: *KEYWORD_SCOPES # 2: *OPTION_SCOPES + set: then-pop # e.g.: "connect HOST[:PORT] ..." (from adb) - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})(?= .*{{long_space}})' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + set: then-pop # e.g.: "bugreport [PATH]" (from adb) - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\]' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + set: then-pop # e.g.: "disconnect [HOST[:PORT]]" (from adb) - match: '({{other_lowercase_name}}) \[({{allcaps_argument_name}})\[' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + set: then-pop # e.g.: "pair HOST[:PORT] [PAIRING CODE]" (from adb) - match: '({{other_lowercase_name}}) ({{allcaps_argument_name}})\[' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + set: then-pop # e.g.: "shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]" (from adb) - match: '({{other_lowercase_name}}) \[(-{{option_name}}) ({{allcaps_argument_name}})\]' captures: 1: *KEYWORD_SCOPES # 2: *OPTION_SCOPES # 3: *ARGUMENT_SCOPES + set: then-pop # e.g.: "wait-for[-TRANSPORT]-STATE..." (from adb) - match: '({{other_lowercase_name}})\[(-{{allcaps_argument_name}})\]' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + set: then-pop # e.g.: "reboot [bootloader|recovery| ..." (from adb) - match: '({{other_lowercase_name}}) \[({{relaxed_argument_name}})\|' captures: 1: *KEYWORD_SCOPES # 2: *ARGUMENT_SCOPES + set: then-pop # e.g.: "bat " (from bat) - match: '({{other_lowercase_name}}) <({{relaxed_argument_name}})>' captures: 1: *KEYWORD_SCOPES # 2: *KEYWORD_SCOPES + set: then-pop # less restrictive matches, catch all - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES + set: then-pop - match: '{{other_lowercase_name}}{{lookahead_single_2_space}}' scope: *KEYWORD_SCOPES + set: then-pop ### notable exceptions ####################################################### diff --git a/tests/highlighted/adb-1.0.41.txt b/tests/highlighted/adb-1.0.41.txt index a6ebe8c..249bb8c 100644 --- a/tests/highlighted/adb-1.0.41.txt +++ b/tests/highlighted/adb-1.0.41.txt @@ -120,7 +120,7 @@  generate adb public/private key; private key stored in FILE, scripting: - wait-for[-TRANSPORT]-STATE... + wait-for[-TRANSPORT]-STATE...  wait for device to be in a given state  STATE: device, recovery, rescue, sideload, bootloader, or disconnect  TRANSPORT: usb, local, or any [default=any] diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 5f6415d..0200344 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -143,8 +143,7 @@ scripting: wait-for[-TRANSPORT]-STATE... #^^^^^^^^ constant.other.keyword.cmd-help # ^^^^^^^^^^ - keyword.other.argument.cmd-help -# ^^^^^^^^^ entity.name.function.option.cmd-help -#fixme: unscope -STATE +# ^^^^^^^^^ - entity.name.function.option.cmd-help wait for device to be in a given state STATE: device, recovery, rescue, sideload, bootloader, or disconnect TRANSPORT: usb, local, or any [default=any] From aa81feb4855cdab1acff7ee2cdbfb797f98650e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 02:14:37 +0200 Subject: [PATCH 31/43] Scope bat in "Usage: bat" To harmonize with the following line, where "bat" is scoped. This is very hacky but highlighting bat's help message properly is a big priority for this syntax, as bat is our only playground. Also renames the test file, cause it was incorrectly versioned 23.0.0 --- syntaxes/cmd-help.sublime-syntax | 12 +++++++++++- .../{bat-short-23.0.0.txt => bat-short-0.23.0.txt} | 2 +- .../{bat-short-23.0.0.txt => bat-short-0.23.0.txt} | 0 tests/syntax/syntax_test_bat-short.txt | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) rename tests/highlighted/{bat-short-23.0.0.txt => bat-short-0.23.0.txt} (97%) rename tests/source/{bat-short-23.0.0.txt => bat-short-0.23.0.txt} (100%) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 06a91f1..e09e8a7 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -184,9 +184,19 @@ contexts: heading-specials: - match: (?i:usage):(?=.+\n) scope: *INLINE_USAGE_SCOPES - set: then-pop + set: maybe-bat - include: python-argparse-headings + + # hack to harmonize usage lines in bat's help message + #nice: generalize this pattern and remove this hardcoded case + maybe-bat: + - match: " (bat)" + captures: + 1: *KEYWORD_SCOPES + set: then-pop + - include: else-pop + ### option definitions ####################################################### option-def-head: diff --git a/tests/highlighted/bat-short-23.0.0.txt b/tests/highlighted/bat-short-0.23.0.txt similarity index 97% rename from tests/highlighted/bat-short-23.0.0.txt rename to tests/highlighted/bat-short-0.23.0.txt index 156eb2d..3b90899 100644 --- a/tests/highlighted/bat-short-23.0.0.txt +++ b/tests/highlighted/bat-short-0.23.0.txt @@ -1,6 +1,6 @@ A cat(1) clone with wings. -Usage: bat [OPTIONS] [FILE]... +Usage: bat [OPTIONS] [FILE]...  bat  Arguments: diff --git a/tests/source/bat-short-23.0.0.txt b/tests/source/bat-short-0.23.0.txt similarity index 100% rename from tests/source/bat-short-23.0.0.txt rename to tests/source/bat-short-0.23.0.txt diff --git a/tests/syntax/syntax_test_bat-short.txt b/tests/syntax/syntax_test_bat-short.txt index 9daefd2..1ab8b85 100644 --- a/tests/syntax/syntax_test_bat-short.txt +++ b/tests/syntax/syntax_test_bat-short.txt @@ -3,6 +3,7 @@ A cat(1) clone with wings. Usage: bat [OPTIONS] [FILE]... +# ^^^ constant.other.keyword.cmd-help bat Arguments: From a700040977c8c8a31956f1732edb03ff0ac2fde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 02:41:22 +0200 Subject: [PATCH 32/43] Handle "mount [options] ..." from mount This change also has lots of side-effects. ghc, ghci and tealdeer are ok It leaves the jq in the "usage: jq ..." line not scoped, but it's acceptable to me. Not like bat's case. --- syntaxes/cmd-help.sublime-syntax | 6 ++++++ tests/highlighted/ghc-8.10.7.txt | 2 +- tests/highlighted/ghci-8.10.7.txt | 2 +- tests/highlighted/jq-1.6.txt | 4 ++-- tests/highlighted/mount-2.34.0.txt | 4 ++-- tests/highlighted/tealdeer-1.4.1.txt | 4 ++-- tests/syntax/syntax_test_ghc.txt | 1 + tests/syntax/syntax_test_jq.txt | 3 +++ 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index e09e8a7..fac5333 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -511,6 +511,12 @@ contexts: 1: *KEYWORD_SCOPES # 2: *KEYWORD_SCOPES set: then-pop + # e.g.: "mount [options] ..." (from mount) + - match: '({{other_lowercase_name}}) \[({{other_lowercase_name}})\]' + captures: + 1: *KEYWORD_SCOPES + # 2: *OPTION_SCOPES + set: then-pop # less restrictive matches, catch all - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES diff --git a/tests/highlighted/ghc-8.10.7.txt b/tests/highlighted/ghc-8.10.7.txt index 3626cb3..3f7a365 100644 --- a/tests/highlighted/ghc-8.10.7.txt +++ b/tests/highlighted/ghc-8.10.7.txt @@ -1,6 +1,6 @@ Usage: - ghc [command-line-options-and-input-files] + ghc [command-line-options-and-input-files] To compile and link a complete Haskell program, run the compiler like so: diff --git a/tests/highlighted/ghci-8.10.7.txt b/tests/highlighted/ghci-8.10.7.txt index f7f8dd7..cc5efdc 100644 --- a/tests/highlighted/ghci-8.10.7.txt +++ b/tests/highlighted/ghci-8.10.7.txt @@ -1,6 +1,6 @@ Usage: - ghci [command-line-options-and-input-files] + ghci [command-line-options-and-input-files] The kinds of input files that can be given on the command-line include: diff --git a/tests/highlighted/jq-1.6.txt b/tests/highlighted/jq-1.6.txt index a139603..9e0d32b 100644 --- a/tests/highlighted/jq-1.6.txt +++ b/tests/highlighted/jq-1.6.txt @@ -1,8 +1,8 @@ jq - commandline JSON processor [version 1.6] Usage: jq [options] [file...] - jq [options] --args [strings...] - jq [options] --jsonargs [JSON_TEXTS...] + jq [options] --args [strings...] + jq [options] --jsonargs [JSON_TEXTS...] jq is a tool for processing JSON inputs, applying the given filter to its JSON text inputs and producing the filter's results as JSON on diff --git a/tests/highlighted/mount-2.34.0.txt b/tests/highlighted/mount-2.34.0.txt index 4ddfa7c..80ecffc 100644 --- a/tests/highlighted/mount-2.34.0.txt +++ b/tests/highlighted/mount-2.34.0.txt @@ -2,8 +2,8 @@ Usage:  mount [-lhV]  mount -a [options] - mount [options] [--source] | [--target]  - mount [options]  + mount [options] [--source] | [--target]  + mount [options]   mount [] Mount a filesystem. diff --git a/tests/highlighted/tealdeer-1.4.1.txt b/tests/highlighted/tealdeer-1.4.1.txt index 48abc94..b651106 100644 --- a/tests/highlighted/tealdeer-1.4.1.txt +++ b/tests/highlighted/tealdeer-1.4.1.txt @@ -1,7 +1,7 @@ Usage: - tldr [options] ... - tldr [options] + tldr [options] ... + tldr [options] Options: diff --git a/tests/syntax/syntax_test_ghc.txt b/tests/syntax/syntax_test_ghc.txt index 978efb1..152c173 100644 --- a/tests/syntax/syntax_test_ghc.txt +++ b/tests/syntax/syntax_test_ghc.txt @@ -3,6 +3,7 @@ Usage: ghc [command-line-options-and-input-files] +# ^^^ constant.other.keyword.cmd-help To compile and link a complete Haskell program, run the compiler like so: diff --git a/tests/syntax/syntax_test_jq.txt b/tests/syntax/syntax_test_jq.txt index 2079ac8..01e049a 100644 --- a/tests/syntax/syntax_test_jq.txt +++ b/tests/syntax/syntax_test_jq.txt @@ -3,7 +3,10 @@ jq - commandline JSON processor [version 1.6] Usage: jq [options] [file...] +# ^^ - constant.other.keyword.cmd-help +#todo: scope this one too jq [options] --args [strings...] +#^^ constant.other.keyword.cmd-help jq [options] --jsonargs [JSON_TEXTS...] jq is a tool for processing JSON inputs, applying the given filter to From 22ceeb280bbc37e442ffab86506e46dd181789fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 02:47:27 +0200 Subject: [PATCH 33/43] Change a todo comment priority Cause keyword=VALUE looks pretty ugly if only the former is colorized. --- tests/syntax/syntax_test_dd.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/syntax/syntax_test_dd.txt b/tests/syntax/syntax_test_dd.txt index 0dcf989..89a8d43 100644 --- a/tests/syntax/syntax_test_dd.txt +++ b/tests/syntax/syntax_test_dd.txt @@ -8,7 +8,7 @@ Copy a file, converting and formatting according to the operands. # ^^ constant.other.keyword.cmd-help # ^ - constant.other.keyword.cmd-help keyword.other.argument.cmd-help # ^^^^^ - constant.other.keyword.cmd-help keyword.other.argument.cmd-help -#nice: scope these +#todo: scope these overrides ibs and obs cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list From 7e46345c76dd7975f44994e8c80f07cb4c4dff2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 03:01:27 +0200 Subject: [PATCH 34/43] Add lookahead_long_space variable --- syntaxes/cmd-help.sublime-syntax | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index fac5333..13ccfd7 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -33,6 +33,7 @@ variables: ### other-def variables: other_lowercase_name: '[a-z][0-9a-z_-]*\b' long_space: ' |\t|\n' + lookahead_long_space: '(?={{long_space}})' lookahead_single_2_space: '(?=.* )(?!.*\S \S)' ### pathname variables: @@ -400,7 +401,7 @@ contexts: set: then-pop keyword-def: - - match: '{{other_lowercase_name}}(?={{long_space}})' + - match: '{{other_lowercase_name}}{{lookahead_long_space}}' scope: *KEYWORD_SCOPES set: then-pop # e.g.: "install - install packages" (from apt) @@ -408,11 +409,11 @@ contexts: scope: *KEYWORD_SCOPES set: then-pop # e.g.: "compose*" (from docker) - - match: '{{other_lowercase_name}}\*(?={{long_space}})' + - match: '{{other_lowercase_name}}\*{{lookahead_long_space}}' scope: *KEYWORD_SCOPES set: then-pop # e.g.: "build, b" (from cargo) - - match: ({{other_lowercase_name}}), ({{other_lowercase_name}})(?={{long_space}}) + - match: ({{other_lowercase_name}}), ({{other_lowercase_name}}){{lookahead_long_space}} captures: 1: *KEYWORD_SCOPES 2: *KEYWORD_SCOPES @@ -436,17 +437,17 @@ contexts: set: then-pop pathname-def: - - match: '{{absolute_path}}(?={{long_space}})' + - match: '{{absolute_path}}{{lookahead_long_space}}' scope: *PATHNAME_SCOPES set: then-pop - - match: '{{relative_path}}(?={{long_space}})' + - match: '{{relative_path}}{{lookahead_long_space}}' scope: *PATHNAME_SCOPES set: then-pop - - match: '{{home_relative_path}}(?={{long_space}})' + - match: '{{home_relative_path}}{{lookahead_long_space}}' scope: *PATHNAME_SCOPES set: then-pop # dotfile - - match: '\.{{path_atom}}(?={{long_space}})' + - match: '\.{{path_atom}}{{lookahead_long_space}}' scope: *PATHNAME_SCOPES set: then-pop From 01e0bbfcc6a5048c3fb02dac361f1a3d6a2817c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Tue, 18 Jul 2023 03:03:27 +0200 Subject: [PATCH 35/43] Rename lookahead_40 to _lte_40_chars --- syntaxes/cmd-help.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 13ccfd7..304326c 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -17,7 +17,7 @@ variables: # words starting with uppercase leading_word: '[A-Z][A-Za-z-]*\b' # only consider lines <= 40 chars long - lookahead_40: '(?=.{1,40}\n)' + lookahead_lte_40_chars: '(?=.{1,40}\n)' ### command option variables: option_break: '[ \t\n,=\[ Date: Sat, 29 Jul 2023 17:44:07 +0200 Subject: [PATCH 36/43] Isolate keyword-def-seq last resort matches --- syntaxes/cmd-help.sublime-syntax | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 304326c..d7d4065 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -518,7 +518,10 @@ contexts: 1: *KEYWORD_SCOPES # 2: *OPTION_SCOPES set: then-pop - # less restrictive matches, catch all + - include: keyword-def-seq-lax + + # less restrictive matches, catch all + keyword-def-seq-lax: - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES set: then-pop From c8627589995aa6f2c182075c90331035c50a2da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sun, 30 Jul 2023 23:48:05 +0200 Subject: [PATCH 37/43] docs: Update scripts/{env.sh -> utils} I moved scripts/env.sh to ./utils in 57748ff and renamed the regression diff functions from gdiff* to reg* in f8bf10d --- docs/Development.md | 8 ++++---- scripts/make_syntax_test.sh | 2 +- tests/docker/bat-test.dockerfile | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/Development.md b/docs/Development.md index 86fbb0e..bafcc3a 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -60,7 +60,7 @@ The project uses two classes of tests: - regression tests: catch-all integration tests There's a number of command-line utils I use to streamline development, including tests. -You can load them with `$ source scripts/env.sh` +You can load them with `$ source scripts/utils` ### Syntax tests @@ -76,7 +76,7 @@ If you expect the tests to pass, it's better to run them with the *summary* opti Syntax tests are also useful to *debug* the workings of the syntax line by line. If you can't make heads or tails of why something doesn't work, run `$ tests/syntax.py -d tests/syntax/` -`env.sh` also contains an util to run with debug and pipe the output to `less`: `$ debug tests/syntax/` +`scripts/utils` also contains an util to run with debug and pipe the output to `less`: `$ debug tests/syntax/` The `syntax -d` output is a bit hard to grasp unless you understand Sublime Syntaxes very well (not my case). So have patience and ask for help if you get stuck. @@ -98,9 +98,9 @@ You can run them with `$ tests/highlight_regression` Because the result files contain color escape characters, they should be opened with `less -R` -To query their changes with respect to the git index, do `$ gdiff` (from `env.sh`) +To query their changes with respect to the git index, do `$ reg` (from `scripts/utils`) -For the diff between the index and the last commit (so staged changes), do `$ gdiffs` +For the diff between the index and the last commit (so staged changes), do `$ regs` These are also a great place to look at when looking for unhandled patterns, to document pending tasks. diff --git a/scripts/make_syntax_test.sh b/scripts/make_syntax_test.sh index 0873b3b..209211e 100755 --- a/scripts/make_syntax_test.sh +++ b/scripts/make_syntax_test.sh @@ -1,7 +1,7 @@ #!/bin/bash # usage: scripts/make_syntax_test.sh tests/source/ -# or: mksyn tests/source/ (if you $ source scripts/env.sh) +# or: mksyn tests/source/ (if you $ source scripts/utils) set -euo pipefail diff --git a/tests/docker/bat-test.dockerfile b/tests/docker/bat-test.dockerfile index 5d9c540..5759b62 100644 --- a/tests/docker/bat-test.dockerfile +++ b/tests/docker/bat-test.dockerfile @@ -10,7 +10,7 @@ RUN curl -LJ \ https://github.com/sharkdp/bat/releases/download/v$BAT_VERSION/bat_${BAT_VERSION}_amd64.deb \ --output /tmp/bat.deb -# fixme: run this without root +#fixme: run this without root FROM debian:bullseye-slim COPY --from=fetch-pkg /tmp/bat.deb /tmp RUN dpkg --install /tmp/bat.deb From 682bc7d515e48fe31e20a940c32e60e73f57692e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Sun, 30 Jul 2023 23:55:28 +0200 Subject: [PATCH 38/43] docs: Write command line arguments --- README.md | 2 +- docs/Development.md | 8 ++++---- scripts/make_syntax_test.sh | 7 +++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fec65d5..c9ac04d 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ If `help()` doesn't work with a command's alternative help option, you can still The syntax works nicely with most `bat` themes. In some cases, even better than with the default Monokai theme (used in the above example). You can find examples of working themes [here](https://github.com/victor-gp/cmd-help-sublime-syntax/tree/demo/docs/examples/theme). -To use a different theme, just append `--theme=` to your `bat` commands. More info [here](https://github.com/sharkdp/bat#highlighting-theme). +To use a different theme, just append `--theme=''` to your `bat` commands. More info [here](https://github.com/sharkdp/bat#highlighting-theme). You may also want to experiment with setting `--italic-text=always`. A few themes use italics on some elements, including Monokai. diff --git a/docs/Development.md b/docs/Development.md index bafcc3a..8f52a12 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -74,13 +74,13 @@ You can run them with `$ tests/syntax.py` If you expect the tests to pass, it's better to run them with the *summary* option: `$ tests/syntax.py -s` Syntax tests are also useful to *debug* the workings of the syntax line by line. -If you can't make heads or tails of why something doesn't work, run `$ tests/syntax.py -d tests/syntax/` +If you can't make heads or tails of why something doesn't work, run `$ tests/syntax.py -d tests/syntax/` -`scripts/utils` also contains an util to run with debug and pipe the output to `less`: `$ debug tests/syntax/` +`scripts/utils` also contains an util to run with debug and pipe the output to `less`: `$ debug tests/syntax/` The `syntax -d` output is a bit hard to grasp unless you understand Sublime Syntaxes very well (not my case). So have patience and ask for help if you get stuck. -Lastly, there's an util to create a syntax test from a `tests/source/` help message: `$ mksyn tests/source/` +Lastly, there's an util to create a syntax test from a `tests/source/` help message: `$ mksyn tests/source/` As a rule of thumb, if there's a syntax test for a command, it should also be in `tests/source`. @@ -106,7 +106,7 @@ These are also a great place to look at when looking for unhandled patterns, to To query them do: `less -R tests/highlighted/*` -or `less -R tests/highlighted/` +or `less -R tests/highlighted/` After a big syntax change that causes many highlight test files to update, it's ok not to include them in the same commit as the syntax change. diff --git a/scripts/make_syntax_test.sh b/scripts/make_syntax_test.sh index 209211e..ca24349 100755 --- a/scripts/make_syntax_test.sh +++ b/scripts/make_syntax_test.sh @@ -1,8 +1,7 @@ #!/bin/bash -# usage: scripts/make_syntax_test.sh tests/source/ -# or: mksyn tests/source/ (if you $ source scripts/utils) - +# usage: scripts/make_syntax_test.sh tests/source/ +# or: mksyn tests/source/ (if you $ source scripts/utils) set -euo pipefail @@ -10,7 +9,7 @@ set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/.." if [ $# -ne 1 ] || [ ! -f "$1" ]; then - >&2 echo "usage: $0 tests/source/" + >&2 echo "usage: $0 tests/source/" exit 2 fi From 76dd911ccbd80fc18d69f5a4d795471e0542c592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 31 Jul 2023 00:24:55 +0200 Subject: [PATCH 39/43] docs: Update the Regression Tests section --- docs/Development.md | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/Development.md b/docs/Development.md index 8f52a12..a756af4 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -89,24 +89,37 @@ For that, I like to pair both within the same commit, so the former serves as an ### Highlight regression tests -These take all the samples (help messages from actual commands) in `tests/source` and run them through `bat` + `cmd-help`. -Then they store the result (syntax highlighted text) in `tests/highlighted/`. +There are a bunch of samples (help messages from actual commands) in `tests/source`. -You can run them with `$ tests/highlight_regression` +Regression tests take all these samples and run them through `bat` + `cmd-help`, storing the result (syntax highlighted text) in `tests/highlighted/`. + +Run them with `$ tests/highlight_regression` + +This script runs the entire suite of highlight regression tests. They usually take < 5s, but it depends on how fast Docker + `bat` update the syntax theme. **They're good for quickly validating if your change breaks existing functionality.** -Because the result files contain color escape characters, they should be opened with `less -R` +#### Displaying regression test differences + +Because the result files in `tests/highlighted` contain color escape characters (e.g.: `ESC[0m`), they should be opened with `less -R`. + +To check highlight regression changes with respect to the git index, load `scripts/utils` and do `$ reg` + +There are a few more utils based on `reg`: -To query their changes with respect to the git index, do `$ reg` (from `scripts/utils`) +- For the regression diff between the index and the last commit (so staged changes), do `$ regs` +- For the regression diff between your branch and `main`, do `$ regm` +- To show the regression diff from a commit (HEAD by default), do `$ regshow` -For the diff between the index and the last commit (so staged changes), do `$ regs` +#### Looking for pending work in regression tests -These are also a great place to look at when looking for unhandled patterns, to document pending tasks. +The corpus of highlighted help messages is also a great place to look for pending work: -To query them do: `less -R tests/highlighted/*` +- do `$ less -R tests/highlighted/*` +- iterate through the files with `:n` (next) and `:p` (previous) +- scroll through the highligted help messages and look for tokens that should (not) be colorized -or `less -R tests/highlighted/` +#### Syntax tests > regression tests to illustrate changes After a big syntax change that causes many highlight test files to update, it's ok not to include them in the same commit as the syntax change. @@ -125,7 +138,7 @@ These track the syntax's coverage for the themes included with `bat`. The motiva You can run them with `$ tests/theme_regression` It runs a synthetic help message through `bat` + `cmd-help`, twice for each theme: with and without italics enabled. -Then it store the result in `tests/theme_regression/`, but deleting the italics version if it makes no difference. +Then it stores the result in `tests/theme_regression/`, but deleting the italics version if it makes no difference. Everything I mentioned on `highlight_regression` applies here, just replacing `highlight` for `theme`. @@ -154,10 +167,11 @@ Look there if you want to break entirely new ground. 1. Update the assertion/s related to that task, negate it to make it fail. 1. Make whatever changes in the syntax to try and fix that test case. 1. Run `tests/syntax.py` to check the assertion now passes without breaking anything else. -1. Repeat steps 3-4 until you get it right. 1. Run `tests/highlight_regression.sh` to ensure the changes don't have unintended consequences in the larger body of help messages. -1. Run `tests/theme_regression.sh` to make double sure. +1. Repeat steps 3-5 until you get it right. 1. Commit, early and often! +1. Run `tests/theme_regression.sh` to check that you didn't break support for any theme. +1. [Submit a Pull Request](https://github.com/victor-gp/cmd-help-sublime-syntax/pulls) ## Contact From 7e18cd86973cfccd6664d8502758d42cc324fb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 31 Jul 2023 00:32:58 +0200 Subject: [PATCH 40/43] docs: Development: move a subsection --- docs/Development.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/Development.md b/docs/Development.md index a756af4..b73a14d 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -111,14 +111,6 @@ There are a few more utils based on `reg`: - For the regression diff between your branch and `main`, do `$ regm` - To show the regression diff from a commit (HEAD by default), do `$ regshow` -#### Looking for pending work in regression tests - -The corpus of highlighted help messages is also a great place to look for pending work: - -- do `$ less -R tests/highlighted/*` -- iterate through the files with `:n` (next) and `:p` (previous) -- scroll through the highligted help messages and look for tokens that should (not) be colorized - #### Syntax tests > regression tests to illustrate changes After a big syntax change that causes many highlight test files to update, it's ok not to include them in the same commit as the syntax change. @@ -161,6 +153,14 @@ I should probably make these into GitHub Issues, but I haven't got the chance to There's also a [Roadmap doc](./Roadmap.md) that defines some long-term goals for the project. Look there if you want to break entirely new ground. +### Spotting issues in regression tests + +The corpus of highlighted help messages in `tests/highlighted` is also a great place to look for pending work: + +- do `$ less -R tests/highlighted/*` +- iterate through the files with `:n` (next) and `:p` (previous) +- scroll through the highlighted text and look for tokens that should (not) be colorized + ## Sample development workflow 1. Search pending tasks with the to-do marker keywords. Choose one. From f597e539046e2f0bbbfbf40344c48a802454b4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 31 Jul 2023 01:20:03 +0200 Subject: [PATCH 41/43] Fix regex for lookahead_single_2_space Because it was matching the 2-space with the first lookahead, without consuming the characters it matched. Then it matched the second (negative) lookahead with the same 2-space. But because it's negative, the whole match failed. We just have to circumscribe the 2nd lookahead (negative) within the first one. This catches the 2 stray corner cases that I wanted to fix before merging this branch: one line each in chown and npm. But it also adds a hell of a regression in that it now matches plain text from a lot of help messages. But this can be fixed easily enough, cf. next commit. --- syntaxes/cmd-help.sublime-syntax | 2 +- tests/highlighted/chown-8.30.txt | 4 ++-- tests/highlighted/cp-8.30.txt | 8 ++++---- tests/highlighted/emacs-26.3.txt | 6 +++--- tests/highlighted/gcc-9.3.0.txt | 2 +- tests/highlighted/ghc-8.10.7.txt | 2 +- tests/highlighted/grep-3.4.txt | 2 +- tests/highlighted/ln-8.30.txt | 2 +- tests/highlighted/nano-4.8.txt | 2 +- tests/highlighted/npm-8.1.2.txt | 2 +- tests/highlighted/python-3.10.0.txt | 2 +- tests/highlighted/xsel-1.2.0.txt | 2 +- tests/syntax/syntax_test_chown.txt | 3 +-- tests/syntax/syntax_test_cp.txt | 3 ++- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index d7d4065..6c7178e 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -34,7 +34,7 @@ variables: other_lowercase_name: '[a-z][0-9a-z_-]*\b' long_space: ' |\t|\n' lookahead_long_space: '(?={{long_space}})' - lookahead_single_2_space: '(?=.* )(?!.*\S \S)' + lookahead_single_2_space: '(?=.* (?!.*\S \S))' ### pathname variables: path_atom: '[0-9a-zA-Z._-]+' diff --git a/tests/highlighted/chown-8.30.txt b/tests/highlighted/chown-8.30.txt index 07d082b..6be9da9 100644 --- a/tests/highlighted/chown-8.30.txt +++ b/tests/highlighted/chown-8.30.txt @@ -23,7 +23,7 @@  -R, --recursive operate on files and directories recursively The following options modify how a hierarchy is traversed when the -R -option is also specified. If more than one is specified, only the final +option is also specified. If more than one is specified, only the final one takes effect.  -H if a command line argument is a symbolic link @@ -41,7 +41,7 @@ Examples:  chown root /u Change the owner of /u to "root". - chown root:staff /u Likewise, but also change its group to "staff". + chown root:staff /u Likewise, but also change its group to "staff".  chown -hR root /u Change the owner of /u and subfiles to "root". GNU coreutils online help:  diff --git a/tests/highlighted/cp-8.30.txt b/tests/highlighted/cp-8.30.txt index 65ed568..c146798 100644 --- a/tests/highlighted/cp-8.30.txt +++ b/tests/highlighted/cp-8.30.txt @@ -52,19 +52,19 @@  --version output version information and exit By default, sparse SOURCE files are detected by a crude heuristic and the -corresponding DEST file is made sparse as well. That is the behavior -selected by --sparse=auto. Specify --sparse=always to create a sparse DEST +corresponding DEST file is made sparse as well. That is the behavior +selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. When --reflink[=always] is specified, perform a lightweight copy, where the -data blocks are copied only when modified. If this is not possible the copy +data blocks are copied only when modified. If this is not possible the copy fails, or if --reflink=auto is specified, fall back to a standard copy. Use --reflink=never to ensure a standard copy is performed. The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/highlighted/emacs-26.3.txt b/tests/highlighted/emacs-26.3.txt index 23730ef..efaba4d 100644 --- a/tests/highlighted/emacs-26.3.txt +++ b/tests/highlighted/emacs-26.3.txt @@ -1,7 +1,7 @@ Usage: emacs [OPTION-OR-FILENAME]... Run Emacs, the extensible, customizable, self-documenting real-time -display editor. The recommended way to start Emacs for normal editing +display editor. The recommended way to start Emacs for normal editing is with no options at all. Run M-x info RET m emacs RET m emacs invocation RET inside Emacs to @@ -82,11 +82,11 @@ --version output version information and exit You can generally also specify long option names with a single -; for -example, -batch as well as --batch. You can use any unambiguous +example, -batch as well as --batch. You can use any unambiguous abbreviation for a --option. Various environment variables and window system resources also affect -the operation of Emacs. See the main documentation. +the operation of Emacs. See the main documentation. Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs section of the Emacs manual or the file BUGS. diff --git a/tests/highlighted/gcc-9.3.0.txt b/tests/highlighted/gcc-9.3.0.txt index b8ff186..d87cb6e 100644 --- a/tests/highlighted/gcc-9.3.0.txt +++ b/tests/highlighted/gcc-9.3.0.txt @@ -54,7 +54,7 @@  guessing the language based on the file's extension. Options starting with -g, -f, -m, -O, -W, or --param are automatically - passed on to the various sub-processes invoked by gcc. In order to pass + passed on to the various sub-processes invoked by gcc. In order to pass  other options on to these processes the -W options must be used. For bug reporting instructions, please see: diff --git a/tests/highlighted/ghc-8.10.7.txt b/tests/highlighted/ghc-8.10.7.txt index 3f7a365..7d69202 100644 --- a/tests/highlighted/ghc-8.10.7.txt +++ b/tests/highlighted/ghc-8.10.7.txt @@ -8,7 +8,7 @@  ghc Main where the module Main is in a file named Main.hs (or Main.lhs) in the -current directory. The other modules in the program will be located +current directory. The other modules in the program will be located and compiled automatically, and the linked program will be placed in the file `Main' (or `Main.exe' on Windows). diff --git a/tests/highlighted/grep-3.4.txt b/tests/highlighted/grep-3.4.txt index 234847a..71cd39b 100644 --- a/tests/highlighted/grep-3.4.txt +++ b/tests/highlighted/grep-3.4.txt @@ -63,7 +63,7 @@  -U, --binary do not strip CR characters at EOL (MSDOS/Windows) When FILE is '-', read standard input. With no FILE, read '.' if -recursive, '-' otherwise. With fewer than two FILEs, assume -h. +recursive, '-' otherwise. With fewer than two FILEs, assume -h. Exit status is 0 if any line (or file if -L) is selected, 1 otherwise; if any error occurs and -q is not given, the exit status is 2. diff --git a/tests/highlighted/ln-8.30.txt b/tests/highlighted/ln-8.30.txt index cc891b8..9593e92 100644 --- a/tests/highlighted/ln-8.30.txt +++ b/tests/highlighted/ln-8.30.txt @@ -35,7 +35,7 @@ The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/highlighted/nano-4.8.txt b/tests/highlighted/nano-4.8.txt index 77bc2a4..e93e2f2 100644 --- a/tests/highlighted/nano-4.8.txt +++ b/tests/highlighted/nano-4.8.txt @@ -1,7 +1,7 @@ Usage: nano [OPTIONS] [[+LINE[,COLUMN]] FILE]... To place the cursor on a specific line of a file, put the line number with -a '+' before the filename. The column number can be added after a comma. +a '+' before the filename. The column number can be added after a comma. When a filename is '-', nano reads data from standard input.  Option Long option Meaning diff --git a/tests/highlighted/npm-8.1.2.txt b/tests/highlighted/npm-8.1.2.txt index 13fb6a9..2c7a9d1 100644 --- a/tests/highlighted/npm-8.1.2.txt +++ b/tests/highlighted/npm-8.1.2.txt @@ -3,7 +3,7 @@ Usage: npm install install all the dependencies in your project -npm install add the dependency to your project +npm install add the dependency to your project npm test run this project's tests npm run run the script named  npm -h quick help on  diff --git a/tests/highlighted/python-3.10.0.txt b/tests/highlighted/python-3.10.0.txt index 83dcc59..b14325f 100644 --- a/tests/highlighted/python-3.10.0.txt +++ b/tests/highlighted/python-3.10.0.txt @@ -76,7 +76,7 @@ PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr. PYTHONFAULTHANDLER: dump the Python traceback on fatal errors. PYTHONHASHSEED: if this variable is set to 'random', a random value is used - to seed the hashes of str and bytes objects. It can also be set to an + to seed the hashes of str and bytes objects. It can also be set to an  integer in the range [0,4294967295] to get hash values with a  predictable seed. PYTHONMALLOC: set the Python memory allocators and/or install debug hooks diff --git a/tests/highlighted/xsel-1.2.0.txt b/tests/highlighted/xsel-1.2.0.txt index 8663b32..071d917 100644 --- a/tests/highlighted/xsel-1.2.0.txt +++ b/tests/highlighted/xsel-1.2.0.txt @@ -2,7 +2,7 @@ Manipulate the X selection. By default the current selection is output and not modified if both -standard input and standard output are terminals (ttys). Otherwise, +standard input and standard output are terminals (ttys). Otherwise, the current selection is output if standard output is not a terminal (tty), and the selection is set from standard input if standard input is not a terminal (tty). If any input or output options are given then diff --git a/tests/syntax/syntax_test_chown.txt b/tests/syntax/syntax_test_chown.txt index 2b084a4..a17c3ef 100644 --- a/tests/syntax/syntax_test_chown.txt +++ b/tests/syntax/syntax_test_chown.txt @@ -48,8 +48,7 @@ Examples: chown root /u Change the owner of /u to "root". # ^^^^^ constant.other.keyword.cmd-help chown root:staff /u Likewise, but also change its group to "staff". -# ^^^^^ -#nit: scope this to make it consistent with the other 2 examples. +# ^^^^^ constant.other.keyword.cmd-help chown -hR root /u Change the owner of /u and subfiles to "root". # ^^^ - entity.name.function.option.cmd-help diff --git a/tests/syntax/syntax_test_cp.txt b/tests/syntax/syntax_test_cp.txt index ea0431e..f950926 100644 --- a/tests/syntax/syntax_test_cp.txt +++ b/tests/syntax/syntax_test_cp.txt @@ -61,8 +61,9 @@ Mandatory arguments to long options are mandatory for short options too. By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior -#^^^^^^^^^^^^ - constant.other.keyword.cmd-help +#^^^^^^^^^^^^ constant.other.keyword.cmd-help # ^^^^ - keyword.other.argument.cmd-help +#fixme: don't scope plain words selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. From 07b0b4e64321547cc3b92d1354bd47af6f5507b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 31 Jul 2023 01:30:38 +0200 Subject: [PATCH 42/43] Don't scope plain words with lookahead_single_2_space The pattern we incorrectly matched was lines including some kind of justified text, with ". " We can safely match this pattern out. --- syntaxes/cmd-help.sublime-syntax | 3 ++- tests/highlighted/chown-8.30.txt | 2 +- tests/highlighted/cp-8.30.txt | 8 ++++---- tests/highlighted/emacs-26.3.txt | 6 +++--- tests/highlighted/gcc-9.3.0.txt | 2 +- tests/highlighted/ghc-8.10.7.txt | 2 +- tests/highlighted/grep-3.4.txt | 2 +- tests/highlighted/ln-8.30.txt | 2 +- tests/highlighted/nano-4.8.txt | 2 +- tests/highlighted/python-3.10.0.txt | 2 +- tests/highlighted/xsel-1.2.0.txt | 2 +- tests/syntax/syntax_test_cp.txt | 3 +-- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index 6c7178e..c566e4d 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -35,6 +35,7 @@ variables: long_space: ' |\t|\n' lookahead_long_space: '(?={{long_space}})' lookahead_single_2_space: '(?=.* (?!.*\S \S))' + lookahead_no_period_2_space: '(?!.*\. )' ### pathname variables: path_atom: '[0-9a-zA-Z._-]+' @@ -525,7 +526,7 @@ contexts: - match: '{{other_lowercase_name}}(?= .*{{long_space}})' scope: *KEYWORD_SCOPES set: then-pop - - match: '{{other_lowercase_name}}{{lookahead_single_2_space}}' + - match: '{{other_lowercase_name}}{{lookahead_single_2_space}}{{lookahead_no_period_2_space}}' scope: *KEYWORD_SCOPES set: then-pop diff --git a/tests/highlighted/chown-8.30.txt b/tests/highlighted/chown-8.30.txt index 6be9da9..4c5113a 100644 --- a/tests/highlighted/chown-8.30.txt +++ b/tests/highlighted/chown-8.30.txt @@ -23,7 +23,7 @@  -R, --recursive operate on files and directories recursively The following options modify how a hierarchy is traversed when the -R -option is also specified. If more than one is specified, only the final +option is also specified. If more than one is specified, only the final one takes effect.  -H if a command line argument is a symbolic link diff --git a/tests/highlighted/cp-8.30.txt b/tests/highlighted/cp-8.30.txt index c146798..65ed568 100644 --- a/tests/highlighted/cp-8.30.txt +++ b/tests/highlighted/cp-8.30.txt @@ -52,19 +52,19 @@  --version output version information and exit By default, sparse SOURCE files are detected by a crude heuristic and the -corresponding DEST file is made sparse as well. That is the behavior -selected by --sparse=auto. Specify --sparse=always to create a sparse DEST +corresponding DEST file is made sparse as well. That is the behavior +selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. When --reflink[=always] is specified, perform a lightweight copy, where the -data blocks are copied only when modified. If this is not possible the copy +data blocks are copied only when modified. If this is not possible the copy fails, or if --reflink=auto is specified, fall back to a standard copy. Use --reflink=never to ensure a standard copy is performed. The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/highlighted/emacs-26.3.txt b/tests/highlighted/emacs-26.3.txt index efaba4d..23730ef 100644 --- a/tests/highlighted/emacs-26.3.txt +++ b/tests/highlighted/emacs-26.3.txt @@ -1,7 +1,7 @@ Usage: emacs [OPTION-OR-FILENAME]... Run Emacs, the extensible, customizable, self-documenting real-time -display editor. The recommended way to start Emacs for normal editing +display editor. The recommended way to start Emacs for normal editing is with no options at all. Run M-x info RET m emacs RET m emacs invocation RET inside Emacs to @@ -82,11 +82,11 @@ --version output version information and exit You can generally also specify long option names with a single -; for -example, -batch as well as --batch. You can use any unambiguous +example, -batch as well as --batch. You can use any unambiguous abbreviation for a --option. Various environment variables and window system resources also affect -the operation of Emacs. See the main documentation. +the operation of Emacs. See the main documentation. Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs section of the Emacs manual or the file BUGS. diff --git a/tests/highlighted/gcc-9.3.0.txt b/tests/highlighted/gcc-9.3.0.txt index d87cb6e..b8ff186 100644 --- a/tests/highlighted/gcc-9.3.0.txt +++ b/tests/highlighted/gcc-9.3.0.txt @@ -54,7 +54,7 @@  guessing the language based on the file's extension. Options starting with -g, -f, -m, -O, -W, or --param are automatically - passed on to the various sub-processes invoked by gcc. In order to pass + passed on to the various sub-processes invoked by gcc. In order to pass  other options on to these processes the -W options must be used. For bug reporting instructions, please see: diff --git a/tests/highlighted/ghc-8.10.7.txt b/tests/highlighted/ghc-8.10.7.txt index 7d69202..3f7a365 100644 --- a/tests/highlighted/ghc-8.10.7.txt +++ b/tests/highlighted/ghc-8.10.7.txt @@ -8,7 +8,7 @@  ghc Main where the module Main is in a file named Main.hs (or Main.lhs) in the -current directory. The other modules in the program will be located +current directory. The other modules in the program will be located and compiled automatically, and the linked program will be placed in the file `Main' (or `Main.exe' on Windows). diff --git a/tests/highlighted/grep-3.4.txt b/tests/highlighted/grep-3.4.txt index 71cd39b..234847a 100644 --- a/tests/highlighted/grep-3.4.txt +++ b/tests/highlighted/grep-3.4.txt @@ -63,7 +63,7 @@  -U, --binary do not strip CR characters at EOL (MSDOS/Windows) When FILE is '-', read standard input. With no FILE, read '.' if -recursive, '-' otherwise. With fewer than two FILEs, assume -h. +recursive, '-' otherwise. With fewer than two FILEs, assume -h. Exit status is 0 if any line (or file if -L) is selected, 1 otherwise; if any error occurs and -q is not given, the exit status is 2. diff --git a/tests/highlighted/ln-8.30.txt b/tests/highlighted/ln-8.30.txt index 9593e92..cc891b8 100644 --- a/tests/highlighted/ln-8.30.txt +++ b/tests/highlighted/ln-8.30.txt @@ -35,7 +35,7 @@ The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through -the VERSION_CONTROL environment variable. Here are the values: +the VERSION_CONTROL environment variable. Here are the values:  none, off never make backups (even if --backup is given)  numbered, t make numbered backups diff --git a/tests/highlighted/nano-4.8.txt b/tests/highlighted/nano-4.8.txt index e93e2f2..77bc2a4 100644 --- a/tests/highlighted/nano-4.8.txt +++ b/tests/highlighted/nano-4.8.txt @@ -1,7 +1,7 @@ Usage: nano [OPTIONS] [[+LINE[,COLUMN]] FILE]... To place the cursor on a specific line of a file, put the line number with -a '+' before the filename. The column number can be added after a comma. +a '+' before the filename. The column number can be added after a comma. When a filename is '-', nano reads data from standard input.  Option Long option Meaning diff --git a/tests/highlighted/python-3.10.0.txt b/tests/highlighted/python-3.10.0.txt index b14325f..83dcc59 100644 --- a/tests/highlighted/python-3.10.0.txt +++ b/tests/highlighted/python-3.10.0.txt @@ -76,7 +76,7 @@ PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr. PYTHONFAULTHANDLER: dump the Python traceback on fatal errors. PYTHONHASHSEED: if this variable is set to 'random', a random value is used - to seed the hashes of str and bytes objects. It can also be set to an + to seed the hashes of str and bytes objects. It can also be set to an  integer in the range [0,4294967295] to get hash values with a  predictable seed. PYTHONMALLOC: set the Python memory allocators and/or install debug hooks diff --git a/tests/highlighted/xsel-1.2.0.txt b/tests/highlighted/xsel-1.2.0.txt index 071d917..8663b32 100644 --- a/tests/highlighted/xsel-1.2.0.txt +++ b/tests/highlighted/xsel-1.2.0.txt @@ -2,7 +2,7 @@ Manipulate the X selection. By default the current selection is output and not modified if both -standard input and standard output are terminals (ttys). Otherwise, +standard input and standard output are terminals (ttys). Otherwise, the current selection is output if standard output is not a terminal (tty), and the selection is set from standard input if standard input is not a terminal (tty). If any input or output options are given then diff --git a/tests/syntax/syntax_test_cp.txt b/tests/syntax/syntax_test_cp.txt index f950926..ea0431e 100644 --- a/tests/syntax/syntax_test_cp.txt +++ b/tests/syntax/syntax_test_cp.txt @@ -61,9 +61,8 @@ Mandatory arguments to long options are mandatory for short options too. By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior -#^^^^^^^^^^^^ constant.other.keyword.cmd-help +#^^^^^^^^^^^^ - constant.other.keyword.cmd-help # ^^^^ - keyword.other.argument.cmd-help -#fixme: don't scope plain words selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files. From fc97338884c65d1fadef87dde0bfdaf179aa73ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Mon, 31 Jul 2023 01:43:45 +0200 Subject: [PATCH 43/43] Add a todo for adb's lowercase headings --- tests/syntax/syntax_test_adb.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/syntax/syntax_test_adb.txt b/tests/syntax/syntax_test_adb.txt index 0200344..5f10fb0 100644 --- a/tests/syntax/syntax_test_adb.txt +++ b/tests/syntax/syntax_test_adb.txt @@ -5,6 +5,8 @@ Version 31.0.3p2-android-tools Installed as /usr/bin/adb global options: +#^^^^^^^^^^^^^^ - string.section-heading.cmd-help +#nice: lowercase headings -a listen on all network interfaces, not just localhost -d use USB device (error if multiple devices connected) -e use TCP/IP device (error if multiple TCP/IP devices available)