forked from robballou/sublimetext-sshconfig
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSSH Common.sublime-syntax
258 lines (222 loc) · 8.61 KB
/
SSH Common.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
%YAML 1.2
---
# This file is some kind of internal library which is used to store
# common rules which are used by the visible syntax files.
name: SSH Common
scope: text.ssh.common
version: 2
hidden: true
variables:
base64_char: '[a-zA-Z0-9+/]'
ssh_fingerprint: (?:AAAA(?:E2V|[BC]3N){{base64_char}}+={0,3})
# ipv4_basic: (?:(?:\d{1,3}\.){3}\d{1,3})
# ipv6_basic: (?i:(?:[a-f0-9:]+:+)+[a-f0-9]+)
zero_to_32: (?:3[0-2]|[12][0-9]|[0-9])
zero_to_128: (?:12[0-8]|1[01][0-9]|[1-9][0-9]|[0-9])
zero_to_255: (?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9][0-9])|(?:[1-9][0-9])|[0-9])
zero_to_65535: (?:6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])
ipv4: (?:(?:{{zero_to_255}}\.){3}{{zero_to_255}})
ipv6: |-
(?xi:
(?:::(?:ffff(?::0{1,4}){0,1}:){0,1}{{ipv4}}) # ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses)
|(?:(?:[0-9a-f]{1,4}:){1,4}:{{ipv4}}) # 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 (IPv4-Embedded IPv6 Address)
|(?:fe80:(?::[0-9a-f]{1,4}){0,4}%[0-9a-z]{1,}) # fe80::7:8%eth0 fe80::7:8%1 (link-local IPv6 addresses with zone index)
|(?:(?:[0-9a-f]{1,4}:){7,7} [0-9a-f]{1,4}) # 1:2:3:4:5:6:7:8
| (?:[0-9a-f]{1,4}: (?::[0-9a-f]{1,4}){1,6}) # 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8
|(?:(?:[0-9a-f]{1,4}:){1,2}(?::[0-9a-f]{1,4}){1,5}) # 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8
|(?:(?:[0-9a-f]{1,4}:){1,3}(?::[0-9a-f]{1,4}){1,4}) # 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8
|(?:(?:[0-9a-f]{1,4}:){1,4}(?::[0-9a-f]{1,4}){1,3}) # 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8
|(?:(?:[0-9a-f]{1,4}:){1,5}(?::[0-9a-f]{1,4}){1,2}) # 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8
|(?:(?:[0-9a-f]{1,4}:){1,6} :[0-9a-f]{1,4}) # 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8
|(?:(?:[0-9a-f]{1,4}:){1,7} :) # 1:: 1:2:3:4:5:6:7::
|(?::(?:(?::[0-9a-f]{1,4}){1,7}|:)) # ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::
)
contexts:
main:
- include: comments-number-sign
pop-nl:
- match: \n
pop: 1
pop-before-nl:
- match: (?=\n)
pop: 1
comments:
- include: comments-number-sign
- include: comments-semicolon
comments-number-sign:
- match: ^\s*(#+)
captures:
1: comment.line.number-sign.ssh.common punctuation.definition.comment.ssh.common
push:
- meta_content_scope: comment.line.number-sign.ssh.common
- match: \n
scope: comment.line.number-sign.ssh.common
pop: true
comments-semicolon:
- match: ^\s*(;+)
captures:
1: comment.line.semi-colon.ssh.common punctuation.definition.comment.ssh.common
push:
- meta_content_scope: comment.line.semi-colon.ssh.common
- include: pop-nl
operator-exclamation:
- match: '!'
scope: keyword.operator.logical.ssh.common
wildcards:
- match: \*
scope: constant.other.wildcard.asterisk.ssh.common
- match: \?
scope: constant.other.wildcard.questionmark.ssh.common
punctuation-comma-sequence:
- match: ','
scope: punctuation.separator.sequence.ssh.common
punctuation-dot-sequence:
- match: \.
scope: punctuation.separator.sequence.ssh.common
punctuation-at:
- match: '@'
scope: punctuation.separator.sequence.ssh.common
ssh-fingerprint:
- match: '{{ssh_fingerprint}}'
scope: variable.other.fingerprint.ssh.common
ssh-fingerprint-with-label:
- match: '{{ssh_fingerprint}}'
scope: variable.other.fingerprint.ssh.common
push: expect-fingerprint-label
expect-fingerprint-label:
- include: pop-before-nl
- match: (?=\S)
push:
- meta_scope: meta.annotation.identifier.ssh.common
string.unquoted.ssh.common
- match: '(?=[ \t]*$)'
pop: 1
- include: punctuation-at
time-values:
# https://man.openbsd.org/sshd_config.5#TIME_FORMATS
# seconds, minutes, hours, days, weeks
- match: \b(?=[\dsmhdw]*\d[smhdw][\s,"])
push:
- meta_scope: meta.constant.time.ssh.common
meta.number.integer.decimal.ssh.common
- match: (?=[\s,"])
pop: 1
- match: (\d+)([smhdw])
captures:
1: constant.numeric.value.ssh.common
2: constant.numeric.suffix.ssh.common
bytes-values:
- match: \b(\d+)([KMG])(?=[\s,"])
scope: meta.constant.bytes.ssh.common
meta.number.integer.other.ssh.common
captures:
1: constant.numeric.value.ssh.common
2: constant.numeric.suffix.ssh.common
mac-addresses:
- match: (?:[0-9a-fA-F]{2}:){5}(?:[0-9a-fA-F]{2})
scope: entity.name.constant.mac-address.ssh.common
ipv4:
- match: '\b{{ipv4}}\b'
scope: meta.number.integer.other.ssh.common constant.numeric.ip-address.v4.ssh.common
ipv6:
- match: '{{ipv6}}'
scope: meta.number.integer.other.ssh.common constant.numeric.ip-address.v6.ssh.common
ipv6-square-bracket:
- match: (\[){{ipv6}}(\])
scope: meta.number.integer.other.ssh.common constant.numeric.ip-address.v6.ssh.common
captures:
1: punctuation.definition.constant.begin.ssh.common
2: punctuation.definition.constant.end.ssh.common
ip-addresses:
- include: ipv6
- include: ipv4
ipv4-with-cidr:
- match: \b({{ipv4}})(?:(/)({{zero_to_32}}))?\b
captures:
1: meta.number.integer.other.ssh.common constant.numeric.ip-address.v4.ssh.common
2: punctuation.separator.sequence.ssh.common
3: constant.other.range.ssh.common
ipv6-with-cidr:
- match: ({{ipv6}})(?:(/)({{zero_to_128}})\b)?
captures:
1: meta.number.integer.other.ssh.common constant.numeric.ip-address.v6.ssh.common
2: punctuation.separator.sequence.ssh.common
3: constant.other.range.ssh.common
ip-addresses-with-cidr:
- include: ipv6-with-cidr
- include: ipv4-with-cidr
port-numbers:
- match: \b{{zero_to_65535}}(?![\w:])
scope: meta.number.integer.decimal.ssh.common
constant.numeric.port-number.ssh.common
match-all:
- match: '\b(?xi: all )\b'
scope: constant.language.boolean.true.ssh.common
none:
- match: \bnone\b
scope: constant.language.null.ssh.common
any:
- match: \bany\b
scope: constant.language.set.ssh.common
boolean:
- match: \byes\b
scope: constant.language.boolean.true.ssh.common
- match: \bno\b
scope: constant.language.boolean.false.ssh.common
boolean-with-typing:
- include: boolean
# Consume while typing as well, but unscoped
- match: \b(?:ye?|n)\b
log-level:
- match: '\b(?x: QUIET | FATAL | ERROR | INFO | DEBUG[1-3]? )\b'
scope: constant.language.log-level.ssh.common
possibly-quoted-value:
- meta_content_scope: meta.mapping.value.ssh.common
- match: '"'
scope: punctuation.definition.string.begin.ssh.common
push:
- meta_scope: string.quoted.double.ssh.common
- match: (")(?:\s*(\S.*))?
captures:
1: punctuation.definition.string.end.ssh.common
2: invalid.illegal.ssh.common
pop: 1
- match: \n|$
scope: invalid.illegal.unclosed-string.ssh.common
pop: 2
- match: (?=\S)
push:
- meta_content_scope: string.unquoted.ssh.common
- include: pop-before-nl
- include: pop-nl
paths:
# This is just heuristic. Expect failures.
- match: (?=~?[\w.\-?*${}%]*/[\w.\-?*${}%]?)
push:
- meta_scope: meta.path.ssh.common
entity.name.ssh.common
- match: (?=[\s,"])
pop: 1
- match: ~[\w\-.]*
scope: variable.language.home.ssh.common
- match: (/)(?:(\.{1,2})(?=/)|\.(?!/))?
captures:
1: punctuation.separator.path.ssh.common
2: constant.other.placeholder.ssh.common
- match: \.(?=[\w*?%])
scope: punctuation.separator.sequence.ssh.common
- include: wildcards
- include: tokens
- include: environment-variables
none-command-values:
- match: \s*(none)\b[ \t]*$
captures:
1: constant.language.null.ssh.common
- match: \s*((")(none)("))[ \t]*$
captures:
1: string.quoted.double.ssh.common
2: punctuation.definition.string.begin.ssh.common
3: constant.language.null.ssh.common
4: punctuation.definition.string.end.ssh.common
tokens: []
environment-variables: []