Highlight C code in all man pages sections

This commit is contained in:
Keith Hall 2020-10-17 18:45:23 +03:00 committed by David Peter
parent 5b2da2b08d
commit 41e857ea16
4 changed files with 37 additions and 29 deletions

View File

@ -83,6 +83,7 @@ contexts:
- match: '' - match: ''
pop: true pop: true
- include: function-call - include: function-call
- include: c-code
expect-command-line-option: expect-command-line-option:
- match: '[A-Za-z0-9-]+' - match: '[A-Za-z0-9-]+'
@ -127,9 +128,12 @@ contexts:
- match: '$|(?=[],]|{{command_line_option}})' - match: '$|(?=[],]|{{command_line_option}})'
pop: true pop: true
synopsis: c-code:
- match: '^(?=\s+(?:#include|/\*))' - match: '^(?=\s+(?:#include|/\*))'
push: scope:source.c push: scope:source.c
synopsis:
- include: c-code
- match: \[ - match: \[
scope: punctuation.section.brackets.begin.man scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe push: command-line-option-or-pipe

View File

@ -123,3 +123,7 @@ OPTIONS
# ^^^ variable.parameter # ^^^ variable.parameter
# ^^ - variable # ^^ - variable
output NUM (default 3) lines of copied context output NUM (default 3) lines of copied context
EXAMPLE
#include <stdio.h>
# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include

View File

@ -1,7 +1,7 @@
BAT(1) General Commands Manual BAT(1) BAT(1) General Commands Manual BAT(1)
NAME NAME
 bat - a cat(1) clone with syntax highlighting and Git integration.  bat - a cat(1) clone with syntax highlighting and Git integration.
USAGE USAGE
 bat [OPTIONS] [FILE]...  bat [OPTIONS] [FILE]...
@ -28,19 +28,19 @@
 values can be specified as either '--language value', '--lan  values can be specified as either '--language value', '--lan
 guage=value', '-l value' or '-lvalue'.  guage=value', '-l value' or '-lvalue'.
 -A, --show-all  -A, --show-all
 Show non-printable characters like space, tab or newline. Use  Show non-printable characters like space, tab or newline. Use
 '--tabs' to control the width of the tab-placeholders.  '--tabs' to control the width of the tab-placeholders.
 -p, --plain  -p, --plain
 Only show plain style, no decorations. This is an alias for  Only show plain style, no decorations. This is an alias for
 '--style=plain'. When '-p' is used twice ('-pp'), it also dis  '--style=plain'. When '-p' is used twice ('-pp'), it also dis
 ables automatic paging (alias for '--style=plain  ables automatic paging (alias for '--style=plain
 --pager=never').  --pager=never').
 -l, --language <language>  -l, --language <language>
 Explicitly set the language for syntax highlighting. The lan  Explicitly set the language for syntax highlighting. The lan
 guage can be specified as a name (like 'C++' or 'LaTeX') or pos  guage can be specified as a name (like 'C++' or 'LaTeX') or pos
@ -65,54 +65,54 @@
 --highlight-line 40:  --highlight-line 40:
 highlights lines 40 to the end of the file  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  Set the tab width to T spaces. Use a width of 0 to pass tabs
 through directly  through directly
 --wrap <mode>  --wrap <mode>
 Specify the text-wrapping mode (*auto*, never, character). The  Specify the text-wrapping mode (*auto*, never, character). The
 '--terminal-width' option can be used in addition to control the  '--terminal-width' option can be used in addition to control the
 output width.  output width.
 --terminal-width <width>  --terminal-width <width>
 Explicitly set the width of the terminal instead of determining  Explicitly set the width of the terminal instead of determining
 it automatically. If prefixed with '+' or '-', the value will be  it automatically. If prefixed with '+' or '-', the value will be
 treated as an offset to the actual terminal width. See also:  treated as an offset to the actual terminal width. See also:
 '--wrap'.  '--wrap'.
 -n, --number  -n, --number
 Only show line numbers, no other decorations. This is an alias  Only show line numbers, no other decorations. This is an alias
 for '--style=numbers'  for '--style=numbers'
 --color <when>  --color <when>
 Specify when to use colored output. The automatic mode only en  Specify when to use colored output. The automatic mode only en
 ables colors if an interactive terminal is detected. Possible  ables colors if an interactive terminal is detected. Possible
 values: *auto*, never, always.  values: *auto*, never, always.
 --italic-text <when>  --italic-text <when>
 Specify when to use ANSI sequences for italic text in the out  Specify when to use ANSI sequences for italic text in the out
 put. Possible values: always, *never*.  put. Possible values: always, *never*.
 --decorations <when>  --decorations <when>
 Specify when to use the decorations that have been specified via  Specify when to use the decorations that have been specified via
 '--style'. The automatic mode only enables decorations if an in  '--style'. The automatic mode only enables decorations if an in
 teractive terminal is detected. Possible values: *auto*, never,  teractive terminal is detected. Possible values: *auto*, never,
 always.  always.
 -f, --force-colorization  -f, --force-colorization
 Alias for '--decorations=always --color=always'. This is useful  Alias for '--decorations=always --color=always'. This is useful
 if the output of bat is piped to another program, but you want  if the output of bat is piped to another program, but you want
 to keep the colorization/decorations.  to keep the colorization/decorations.
 --paging <when>  --paging <when>
 Specify when to use the pager. To disable the pager, use '--pag  Specify when to use the pager. To disable the pager, use '--pag
 ing=never' or its alias, -P. To disable the pager permanently,  ing=never' or its alias, -P. To disable the pager permanently,
@ -120,7 +120,7 @@
 used, see the '--pager' option. Possible values: *auto*, never,  used, see the '--pager' option. Possible values: *auto*, never,
 always.  always.
 --pager <command>  --pager <command>
 Determine which pager is used. This option will override the  Determine which pager is used. This option will override the
 PAGER and BAT_PAGER environment variables. The default pager is  PAGER and BAT_PAGER environment variables. The default pager is
@ -135,24 +135,24 @@
 '*.build:Python'. To highlight files named '.myignore' with the  '*.build:Python'. To highlight files named '.myignore' with the
 Git Ignore syntax, use -m '.myignore:Git Ignore'.  Git Ignore syntax, use -m '.myignore:Git Ignore'.
 --theme <theme>  --theme <theme>
 Set the theme for syntax highlighting. Use '--list-themes' to  Set the theme for syntax highlighting. Use '--list-themes' to
 see all available themes. To set a default theme, add the  see all available themes. To set a default theme, add the
 '--theme="..."' option to the configuration file or export the  '--theme="..."' option to the configuration file or export the
 BAT_THEME environment variable (e.g.: export BAT_THEME="...").  BAT_THEME environment variable (e.g.: export BAT_THEME="...").
 --list-themes  --list-themes
 Display a list of supported themes for syntax highlighting.  Display a list of supported themes for syntax highlighting.
 --style <style-components>  --style <style-components>
 Configure which elements (line numbers, file headers, grid bor  Configure which elements (line numbers, file headers, grid bor
 ders, Git modifications, ..) to display in addition to the file  ders, Git modifications, ..) to display in addition to the file
 contents. The argument is a comma-separated list of components  contents. The argument is a comma-separated list of components
 to display (e.g. 'numbers,changes,grid') or a pre-defined style  to display (e.g. 'numbers,changes,grid') or a pre-defined style
 ('full'). To set a default style, add the '--style=".."' option  ('full'). To set a default style, add the '--style=".."' option
 to the configuration file or export the BAT_STYLE environment  to the configuration file or export the BAT_STYLE environment
 variable (e.g.: export BAT_STYLE=".."). Possible values: *auto*,  variable (e.g.: export BAT_STYLE=".."). Possible values: *auto*,
 full, plain, changes, header, grid, numbers, snip.  full, plain, changes, header, grid, numbers, snip.
@ -171,21 +171,21 @@
 --line-range 40:  --line-range 40:
 prints lines 40 to the end of the file  prints lines 40 to the end of the file
 -L, --list-languages  -L, --list-languages
 Display a list of supported languages for syntax highlighting.  Display a list of supported languages for syntax highlighting.
 -u, --unbuffered  -u, --unbuffered
 This option exists for POSIX-compliance reasons ('u' is for 'un  This option exists for POSIX-compliance reasons ('u' is for 'un
 buffered'). The output is always unbuffered - this option is  buffered'). The output is always unbuffered - this option is
 simply ignored.  simply ignored.
 -h, --help  -h, --help
 Print this help message.  Print this help message.
 -V, --version  -V, --version
 Show version information.  Show version information.

View File

@ -1,4 +1,4 @@
SELECT(2) Linux Programmer's Manual SELECT(2) SELECT(2) Linux Programmer's Manual SELECT(2)
NAME NAME
 select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing  select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO - synchronous I/O multiplexing