-
Notifications
You must be signed in to change notification settings - Fork 2
/
GenericConfig.sublime-syntax
153 lines (127 loc) · 4.21 KB
/
GenericConfig.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
%YAML 1.2
---
# TODO: rework to use new SublimeText regex engine.
name: Generic Config
file_extensions:
- cfg
- conf
- config
- ini
- pro
- mak
- mk
- Doxyfile
- inputrc
- .inputrc
- dircolors
- .dircolors
- gitmodules
- .gitmodules
- gitignore
- .gitignore
- gitattributes
- .gitattributes
scope: source.genconfig
contexts:
main:
# "Color (with alpha): #aacc4322, #bf34fa, #ccc"
- match: '(?:(?:^\s*)|\s+)#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})\b'
scope: constant.other.genconfig
# One line comment
- match: (?:(?:^\s*)|\s+)(?:(#.*)|(--\s+.*)|(\/\/.*))$
captures:
1: comment.line.number-sign.genconfig
2: comment.line.double-dash.genconfig
3: comment.line.double-slash.genconfig
scope: meta.comment.genconfig
# ; one line comment
- match: (?:(?:^\s*)|(?:^.+\s+))(;.*)$
scope: meta.comment.genconfig
captures:
1: comment.line.number-sign.genconfig
# c-like block comments.
# NOTE: This block must have a space after opening literal to not break
# other constructions like '/path/to/*.conf'
- match: /\*+\s
scope: comment.block.genconfig
push: block_comment
# IP
- match: \b(?:\d+\.){3}\d+(?:(?:\:|\/)\d+)?\b
scope: meta.ip.genconfig constant.other.genconfig
# Number or number with unit (like 10k, 12M, 92dpi etc) and also hex like values 0xdf
- match: \b[0-9]+([a-zA-Z]+)?\b
scope: constant.numeric.genconfig
# "function call: name()"
- match: \b(\w+)\b\(
scope: meta.function.genconfig
captures:
1: entity.name.function.genconfig
# Constant
- match: \b(?i:true|false)\b
scope: constant.language.genconfig
# Constant
- match: \b(?<!-)(?i:on|off|yes|no|null|none|nan)(?!-)\b
scope: constant.language.genconfig
# One line word, or word with following {, or [word] or <word>
- match: (?:^\s*(\w+)\s*(?={))|(?:^\s*(\w+)\s*$)|(^\s*\[.*\]\s*$)|(^\s*\<.*\>\s*$)
scope: storage.type.genconfig
- match: '"'
push: double_string
- match: "'"
push: single_string
- match: \\"
push: quoted_double_string
- match: \\'
push: quoted_single_string
# Keywords
- match: (^\s*|\b)(?<![.-])(function|define|ifn?def|endif|macro|insertmacro|index|location|alias|include|rewrite|if|then|else|start|stop|restart|with|alert|internal)(?![.-])\b
scope: keyword.other.genconfig
# "Var name: %name, %name%, $name, $name$, ${name}, %{name}, %(name), $(name)"
- match: ([\%\$@]{1,2}\{\w+\}[\%\$@]{0,2})|([\%\$@]{1,2}\(\w+\)[\%\$@]{0,2})|([\%\$@]{1,2}\w+[\%\$@]{0,2})
scope: storage.source.genconfig
# "Constant like names (ie in uppercase: NAME, SOME_NAME)"
- match: \b[A-Z_][A-Z_0-9]*\b
scope: support.constant.genconfig
# "URL like strings (http://name.org, ssh://111.22.33.4:42)"
- match: \b(?:(\w+\:\/\/[^,\s]+)|localhost)\b
scope: meta.url.genconfig constant.other.genconfig
# 'Colorize key in lines like: key = value or key: value or key value'
- match: ^\s*(\w[\w\-_]*)\s*(\:|=)?
scope: meta.param.genconfig
captures:
1: variable.parameter.genconfig
2: keyword.operator.genconfig
# RegExp
- match: \^.*\$
scope: string.regexp.genconfig
# Operators
- match: (!|\~|%|=|\^|\+|\-|\<|\>|\?|\/|\*|\\|\||\:|\.|\,)
scope: keyword.operator.genconfig
# Mime types (text/plain, application/x-javascript etc)
- match: \b(?<!/)[\w\-\.\+]+/[\w\-\.\+]+(?!/)\b
scope: support.type.genconfig
double_string:
- meta_scope: string.quoted.double.genconfig
- match: '"'
pop: true
- match: \\\s*"
scope: constant.character.genconfig
single_string:
- meta_scope: string.quoted.signle.genconfig
- match: "'"
pop: true
- match: \\\s*'
scope: constant.character.genconfig
quoted_double_string:
- meta_scope: string.quoted.qdouble.genconfig
- match: \\"
pop: true
quoted_single_string:
- meta_scope: string.quoted.qsignle.genconfig
- match: \\'
pop: true
block_comment:
- meta_scope: comment.block.genconfig
- match: \*/
scope: comment.block.genconfig
pop: true