2019-08-31 12:32:37 +00:00
|
|
|
%YAML 1.2
|
|
|
|
---
|
|
|
|
# http://www.sublimetext.com/docs/3/syntax.html
|
|
|
|
name: Manpage
|
|
|
|
file_extensions:
|
|
|
|
- man
|
|
|
|
scope: source.man
|
|
|
|
|
|
|
|
variables:
|
2020-10-14 19:20:14 +00:00
|
|
|
section_heading: '^(?!#)\S.*$'
|
|
|
|
command_line_option: '(--?[A-Za-z0-9][_A-Za-z0-9-]*)'
|
2019-08-31 12:32:37 +00:00
|
|
|
|
|
|
|
contexts:
|
2020-10-14 19:20:14 +00:00
|
|
|
prototype:
|
|
|
|
# ignore syntax test lines
|
|
|
|
- match: '^#'
|
|
|
|
push:
|
|
|
|
- meta_scope: comment.syntax-test.man
|
|
|
|
- match: $\n?
|
|
|
|
pop: true
|
2019-08-31 12:32:37 +00:00
|
|
|
main:
|
|
|
|
- match: ^
|
|
|
|
push: first_line
|
|
|
|
|
|
|
|
first_line:
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: '([A-Z0-9_\-]+)(\()([^)]+)(\))\s*'
|
2019-08-31 12:32:37 +00:00
|
|
|
captures:
|
2020-10-14 19:20:14 +00:00
|
|
|
1: meta.preprocessor.man
|
|
|
|
2: keyword.operator.man
|
|
|
|
3: string.quoted.other.man
|
|
|
|
4: keyword.operator.man
|
|
|
|
push:
|
|
|
|
- match: (?:[\w'-]+|\s(?!\s))
|
|
|
|
scope: markup.heading.title.man
|
|
|
|
- match: \s\s
|
|
|
|
pop: true
|
2020-10-19 08:24:15 +00:00
|
|
|
- match: '(?=\S|$)'
|
2020-10-14 19:20:14 +00:00
|
|
|
pop: true
|
2019-08-31 12:32:37 +00:00
|
|
|
|
|
|
|
- match: '$'
|
2020-10-19 08:24:15 +00:00
|
|
|
set: body
|
2019-08-31 12:32:37 +00:00
|
|
|
|
|
|
|
body:
|
2020-10-14 19:20:14 +00:00
|
|
|
# English, ..., ..., ..., Russian, ...
|
|
|
|
|
2020-10-19 09:29:54 +00:00
|
|
|
- match: '^(?:SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
|
2020-10-14 19:20:14 +00:00
|
|
|
scope: markup.heading.synopsis.man
|
|
|
|
embed: synopsis
|
|
|
|
escape: '(?={{section_heading}})'
|
2019-08-31 12:32:37 +00:00
|
|
|
|
2020-10-19 08:24:15 +00:00
|
|
|
- match: '^(?:USAGE)'
|
|
|
|
scope: markup.heading.synopsis.man
|
|
|
|
embed: synopsis
|
|
|
|
escape: '(?={{section_heading}})'
|
2019-08-31 12:32:37 +00:00
|
|
|
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: '{{section_heading}}'
|
|
|
|
scope: markup.heading.other.man
|
|
|
|
embed: options # some man pages put command line options under the description heading
|
|
|
|
escape: '(?={{section_heading}})'
|
|
|
|
|
|
|
|
function-call:
|
2021-01-11 22:12:42 +00:00
|
|
|
- match: '\b([A-Za-z0-9_\-]+\.)?([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
|
2019-08-31 12:32:37 +00:00
|
|
|
captures:
|
2020-10-14 19:20:14 +00:00
|
|
|
1: entity.name.function.man
|
2021-01-11 22:12:42 +00:00
|
|
|
2: entity.name.function.man
|
|
|
|
3: keyword.operator.man
|
|
|
|
4: constant.numeric.man
|
|
|
|
5: keyword.operator.man
|
|
|
|
|
|
|
|
env-var:
|
|
|
|
- match: '(\$)(?!\d)(\w+)\b'
|
|
|
|
captures:
|
|
|
|
1: punctuation.definition.variable.man
|
|
|
|
2: constant.other.man
|
2019-11-04 19:37:27 +00:00
|
|
|
|
2020-10-14 19:20:14 +00:00
|
|
|
options:
|
2019-11-04 19:37:27 +00:00
|
|
|
# command-line options like --option=value, --some-flag, or -x
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: '^[ ]{7}(?=-)'
|
|
|
|
push: expect-command-line-option
|
|
|
|
- match: '(?:[^a-zA-Z0-9_-]|^|\s){{command_line_option}}'
|
2019-11-04 19:37:27 +00:00
|
|
|
captures:
|
2020-10-14 19:20:14 +00:00
|
|
|
1: entity.name.command-line-option
|
|
|
|
push:
|
|
|
|
- match: '='
|
|
|
|
scope: keyword.operator.man
|
|
|
|
set:
|
|
|
|
- match: '[^],.() ]+'
|
|
|
|
scope: variable.parameter.man
|
|
|
|
pop: true
|
|
|
|
- match: $
|
|
|
|
pop: true
|
|
|
|
- match: ''
|
|
|
|
pop: true
|
|
|
|
- include: function-call
|
2020-10-17 15:45:23 +00:00
|
|
|
- include: c-code
|
2021-01-11 22:12:42 +00:00
|
|
|
- include: env-var
|
2020-10-14 19:20:14 +00:00
|
|
|
|
|
|
|
expect-command-line-option:
|
|
|
|
- match: '[A-Za-z0-9-]+'
|
|
|
|
scope: entity.name.command-line-option.man
|
|
|
|
- match: '(\[)(=)'
|
|
|
|
captures:
|
2020-10-15 03:39:27 +00:00
|
|
|
1: punctuation.section.brackets.begin.man
|
2020-10-14 19:20:14 +00:00
|
|
|
2: keyword.operator.man
|
2020-10-15 03:39:27 +00:00
|
|
|
push: [command-line-option-or-pipe, expect-parameter]
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: '\['
|
|
|
|
push:
|
|
|
|
- meta_scope: entity.name.command-line-option.man
|
|
|
|
- match: '\]'
|
|
|
|
pop: true
|
|
|
|
- match: '='
|
|
|
|
scope: keyword.operator.man
|
|
|
|
push: expect-parameter
|
|
|
|
- match: (?=.*\.)
|
|
|
|
pop: true
|
|
|
|
- match: '\s'
|
|
|
|
push: expect-parameter
|
|
|
|
- match: '(,)\s*'
|
|
|
|
captures:
|
|
|
|
1: punctuation.separator.man
|
|
|
|
- match: $|(?=\])
|
|
|
|
pop: true
|
|
|
|
|
|
|
|
expect-parameter:
|
|
|
|
- match: '[A-Za-z0-9-]+'
|
|
|
|
scope: variable.parameter.man
|
2020-10-15 03:39:27 +00:00
|
|
|
- match: (?=\s+\|)
|
|
|
|
pop: true
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: \|
|
|
|
|
scope: keyword.operator.logical.man
|
2020-10-15 03:39:27 +00:00
|
|
|
- match: '\['
|
|
|
|
scope: punctuation.section.brackets.begin.man
|
|
|
|
push:
|
|
|
|
- match: '\]'
|
|
|
|
scope: punctuation.section.brackets.end.man
|
|
|
|
pop: true
|
|
|
|
- include: expect-parameter
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: '$|(?=[],]|{{command_line_option}})'
|
|
|
|
pop: true
|
|
|
|
|
2020-10-17 15:45:23 +00:00
|
|
|
c-code:
|
2020-10-19 08:24:15 +00:00
|
|
|
- match: '^(?=\s+(?:#include\b|#define\b|/\*|struct\s+(\w+\s*)?\{))'
|
|
|
|
embed: scope:source.c
|
|
|
|
#embed_scope: source.c.embedded.man
|
|
|
|
#escape: ^(?!#|\1|\s*(?:$|/\*|#include\b|#define\b))
|
|
|
|
escape: ^(?=\s*(?:\(.*\.\)\s*$|[A-Z](?![A-Z])))
|
2020-10-17 15:45:23 +00:00
|
|
|
|
|
|
|
synopsis:
|
|
|
|
- include: c-code
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: \[
|
|
|
|
scope: punctuation.section.brackets.begin.man
|
|
|
|
push: command-line-option-or-pipe
|
|
|
|
- include: options
|
|
|
|
|
|
|
|
command-line-option-or-pipe:
|
|
|
|
- match: (\|)\s*
|
|
|
|
captures:
|
|
|
|
1: keyword.operator.logical.man
|
|
|
|
#- match: (?={{command_line_option}})
|
2020-10-19 08:24:15 +00:00
|
|
|
- match: \w+-\w+
|
2020-10-14 19:20:14 +00:00
|
|
|
- match: (?=-)
|
|
|
|
push:
|
|
|
|
- match: (?=\s*\|)
|
|
|
|
pop: true
|
|
|
|
- include: expect-command-line-option
|
|
|
|
- match: \]
|
|
|
|
scope: punctuation.section.brackets.end.man
|
|
|
|
pop: true
|
|
|
|
- match: \[
|
|
|
|
scope: punctuation.section.brackets.begin.man
|
|
|
|
push: command-line-option-or-pipe
|