Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope environment variable and commands sections in Manpages #2461

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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').

 -l, --language <language>
 -l, --language <language>

 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

 --tabs <T>
 --tabs <T>

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

 --wrap <mode>
 --wrap <mode>

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

 --terminal-width <width>
 --terminal-width <width>

 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'

 --color <when>
 --color <when>

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

 --italic-text <when>
 --italic-text <when>

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

 --decorations <when>
 --decorations <when>

 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.

 --paging <when>
 --paging <when>

 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.

 --pager <command>
 --pager <command>

 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'.

 --theme <theme>
 --theme <theme>

 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.

 --style <style-components>
 --style <style-components>

 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
 FZF_DEFAULT_COMMAND
 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
 FZF_DEFAULT_COMMAND
 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
 is POSIX-compliant.

 FZF_DEFAULT_OPTS
 Default options. e.g. export FZF_DEFAULT_OPTS="--extended --cycle"
 FZF_DEFAULT_OPTS
 Default options. e.g. export FZF_DEFAULT_OPTS="--extended --cycle"

EXIT STATUS
 0 Normal exit
Expand Down
Loading