Skip to content

Commit

Permalink
Scope environment variable and commands sections in Manpages
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall authored and Enselic committed Feb 5, 2023
1 parent 1004018 commit 52ef1bc
Show file tree
Hide file tree
Showing 7 changed files with 2,165 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

- Added support for Ada, see #1300 and #2316 (@dkm)
- Added `todo.txt` syntax, see #2375 (@BANOnotIT)
- Improve Manpage.sublime-syntax. See #2364 (@Freed-Wu)
- Improve Manpage.sublime-syntax. See #2364 (@Freed-Wu) and #2461 (@keith-hall)
- Added a new `requirements.txt` syntax, see #2361 (@Freed-Wu)
- Added a new VimHelp syntax, see #2366 (@Freed-Wu)
- Associate `pdm.lock` with `TOML` syntax, see #2410
Expand Down
30 changes: 30 additions & 0 deletions assets/syntaxes/02_Extra/Manpage.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ contexts:
embed: synopsis
escape: '(?={{section_heading}})'

- match: '^(?:COMMANDS)\b'
scope: markup.heading.commands.man
embed: commands-start
escape: '(?={{section_heading}})'

- match: '^(?:ENVIRONMENT\s+VARIABLES)'
scope: markup.heading.env.man
embed: environment-variables
escape: '(?={{section_heading}})'

- match: '{{section_heading}}'
scope: markup.heading.other.man
embed: options # some man pages put command line options under the description heading
Expand Down Expand Up @@ -135,6 +145,10 @@ contexts:
scope: punctuation.section.brackets.end.man
pop: true
- include: expect-parameter
- match: '<'
scope: punctuation.definition.generic.begin.man
- match: '>'
scope: punctuation.definition.generic.end.man
- match: '$|(?=[],]|{{command_line_option}})'
pop: true

Expand Down Expand Up @@ -169,3 +183,19 @@ contexts:
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe

commands-start:
- match: '^[ ]{7}(?=.*(?:[ ]<|[|]))'
push: commands

commands:
- match: '[-\w]+'
scope: entity.name.command.man
push: expect-parameter
- match: $
pop: true

environment-variables:
- match: '^[ ]{7}([A-Z_]+)\b'
captures:
1: support.constant.environment-variable.man
53 changes: 53 additions & 0 deletions assets/syntaxes/02_Extra/syntax_test_man.man
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,59 @@ ENVIRONMENT
systemd reads the log level from this environment variable. This
can be overridden with --log-level=.

ENVIRONMENT VARIABLES
Various Git commands use the following environment variables:

The Git Repository
These environment variables apply to all core Git commands. Nb: it is
worth noting that they may be used/overridden by SCMS sitting above Git
so take care if using a foreign front-end.

GIT_INDEX_FILE
# ^^^^^^^^^^^^^^ support.constant.environment-variable
This environment allows the specification of an alternate index
file. If not specified, the default of $GIT_DIR/index is used.

GIT_INDEX_VERSION
# ^^^^^^^^^^^^^^^^^ support.constant.environment-variable
This environment variable allows the specification of an index
version for new repositories. It won’t affect existing index files.
By default index file version 2 or 3 is used. See git-update-
index(1) for more information.

COMMANDS
This section only lists general commands. For input and output com‐
mands, refer to sway-input(5) and sway-output(5).

The following commands may only be used in the configuration file.

bar [<bar-id>] <bar-subcommands...>
# ^^^ entity.name.command
# ^ punctuation.section.brackets.begin
# ^ punctuation.definition.generic.begin
# ^^^^^^ variable.parameter
# ^ punctuation.definition.generic.end
# ^ punctuation.section.brackets.end
# ^ punctuation.definition.generic.begin
# ^^^^^^^^^^^^^^^ variable.parameter
# ^ punctuation.definition.generic.end
For details on bar subcommands, see sway-bar(5).

default_orientation horizontal|vertical|auto
# ^^^^^^^^^^^^^^^^^^^ entity.name.command
# ^^^^^^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^ variable.parameter
Sets the default container layout for tiled containers.

include <path>
Includes another file from path. path can be either a full path or
a path relative to the parent config, and expands shell syntax (see
wordexp(3) for details). The same include file can only be included
once; subsequent attempts will be ignored.

SEE ALSO
The systemd Homepage[11], systemd-system.conf(5), locale.conf(5)
# ^^^^^^^^^^^^^^^^^^^ entity.name.function
22 changes: 11 additions & 11 deletions tests/syntax-tests/highlighted/Manpage/bat-0.16.man
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
 ables automatic paging (alias for '--style=plain
 --pager=never').

[38;2;248;248;242m [0m[38;2;166;226;46m-l[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46m--language[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mlanguage[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m-l[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46m--language[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mlanguage[0m[38;2;248;248;242m>[0m

 Explicitly set the language for syntax highlighting. The lan‐
 guage can be specified as a name (like 'C++' or 'LaTeX') or pos‐
Expand All @@ -65,18 +65,18 @@
 --highlight-line 40:
 highlights lines 40 to the end of the file

[38;2;248;248;242m [0m[38;2;166;226;46m--tabs[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mT[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--tabs[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mT[0m[38;2;248;248;242m>[0m

 Set the tab width to T spaces. Use a width of 0 to pass tabs
 through directly

[38;2;248;248;242m [0m[38;2;166;226;46m--wrap[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mmode[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--wrap[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mmode[0m[38;2;248;248;242m>[0m

 Specify the text-wrapping mode (*auto*, never, character). The
 '--terminal-width' option can be used in addition to control the
 output width.

[38;2;248;248;242m [0m[38;2;166;226;46m--terminal-width[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mwidth[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--terminal-width[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mwidth[0m[38;2;248;248;242m>[0m

 Explicitly set the width of the terminal instead of determining
 it automatically. If prefixed with '+' or '-', the value will be
Expand All @@ -88,18 +88,18 @@
 Only show line numbers, no other decorations. This is an alias
 for '--style=numbers'

[38;2;248;248;242m [0m[38;2;166;226;46m--color[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--color[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m

 Specify when to use colored output. The automatic mode only en‐
 ables colors if an interactive terminal is detected. Possible
 values: *auto*, never, always.

[38;2;248;248;242m [0m[38;2;166;226;46m--italic-text[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--italic-text[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m

 Specify when to use ANSI sequences for italic text in the out‐
 put. Possible values: always, *never*.

[38;2;248;248;242m [0m[38;2;166;226;46m--decorations[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--decorations[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m

 Specify when to use the decorations that have been specified via
 '--style'. The automatic mode only enables decorations if an in‐
Expand All @@ -112,15 +112,15 @@
 if the output of bat is piped to another program, but you want
 to keep the colorization/decorations.

[38;2;248;248;242m [0m[38;2;166;226;46m--paging[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--paging[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mwhen[0m[38;2;248;248;242m>[0m

 Specify when to use the pager. To disable the pager, use '--pag‐
 ing=never' or its alias, -P. To disable the pager permanently,
 set BAT_PAGER to an empty string. To control which pager is
 used, see the '--pager' option. Possible values: *auto*, never,
 always.

[38;2;248;248;242m [0m[38;2;166;226;46m--pager[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mcommand[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--pager[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mcommand[0m[38;2;248;248;242m>[0m

 Determine which pager is used. This option will override the
 PAGER and BAT_PAGER environment variables. The default pager is
Expand All @@ -135,7 +135,7 @@
 '*.build:Python'. To highlight files named '.myignore' with the
 Git Ignore syntax, use -m '.myignore:Git Ignore'.

[38;2;248;248;242m [0m[38;2;166;226;46m--theme[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mtheme[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--theme[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mtheme[0m[38;2;248;248;242m>[0m

 Set the theme for syntax highlighting. Use '--list-themes' to
 see all available themes. To set a default theme, add the
Expand All @@ -146,7 +146,7 @@

 Display a list of supported themes for syntax highlighting.

[38;2;248;248;242m [0m[38;2;166;226;46m--style[0m[38;2;248;248;242m <[0m[3;38;2;253;151;31mstyle-components[0m[38;2;248;248;242m>[0m
[38;2;248;248;242m [0m[38;2;166;226;46m--style[0m[38;2;248;248;242m [0m[38;2;248;248;242m<[0m[3;38;2;253;151;31mstyle-components[0m[38;2;248;248;242m>[0m

 Configure which elements (line numbers, file headers, grid bor‐
 ders, Git modifications, ..) to display in addition to the file
Expand Down
8 changes: 4 additions & 4 deletions tests/syntax-tests/highlighted/Manpage/fzf-0.33.0.man
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@
 Note that most options have the opposite versions with --no- prefix.

ENVIRONMENT VARIABLES
[38;2;248;248;242m FZF_DEFAULT_COMMAND[0m
[38;2;248;248;242m Default command to use when input is tty. On *nix systems, fzf runs the command with [0m[38;2;255;255;255m$[0m[38;2;190;132;255mSHELL[0m[38;2;248;248;242m [0m[38;2;166;226;46m-c[0m[38;2;248;248;242m if SHELL is set, otherwise with sh [0m[38;2;166;226;46m-c[0m[38;2;248;248;242m, so in this case make sure that the command[0m
[38;2;248;248;242m [0m[38;2;102;217;239mFZF_DEFAULT_COMMAND[0m
[38;2;248;248;242m Default command to use when input is tty. On *nix systems, fzf runs the command with $SHELL -c if SHELL is set, otherwise with sh -c, so in this case make sure that the command[0m
 is POSIX-compliant.

[38;2;248;248;242m FZF_DEFAULT_OPTS[0m
[38;2;248;248;242m Default options. e.g. export FZF_DEFAULT_OPTS="[0m[38;2;166;226;46m--extended[0m[38;2;248;248;242m [0m[38;2;166;226;46m--cycle[0m[38;2;248;248;242m"[0m
[38;2;248;248;242m [0m[38;2;102;217;239mFZF_DEFAULT_OPTS[0m
[38;2;248;248;242m Default options. e.g. export FZF_DEFAULT_OPTS="--extended --cycle"[0m

EXIT STATUS
 0 Normal exit
Expand Down

0 comments on commit 52ef1bc

Please sign in to comment.