forked from robballou/sublimetext-sshconfig
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SSH Config.sublime-syntax
303 lines (275 loc) · 9.84 KB
/
SSH Config.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
%YAML 1.2
---
# https://www.sublimetext.com/docs/syntax.html
# https://man7.org/linux/man-pages/man5/ssh_config.5.html
# https://man.openbsd.org/ssh_config.5
name: SSH Config
file_extensions:
- ssh_config
scope: source.ssh_config
contexts:
main:
- include: comments
- include: host
- include: match
options:
- include: comments
- include: hostname
- include: localcommand
- include: proxycommand
- include: boolean-option
- include: boolean-option-plus
- include: generic-option
tokens:
# https://man7.org/linux/man-pages/man5/ssh_config.5.html#TOKENS
# https://man.openbsd.org/ssh_config.5#TOKENS
- match: '%[%CdhiLlnprTu]'
scope: constant.character.escape.ssh_config
pop-before-match-option:
- include: SSH Common.sublime-syntax#pop-before-nl
- match: (?=[ \t]*(?i:all|canonical|exec|host|originalhost|user|localuser)\b)
pop: true
pop-before-next-host:
- match: (?=^[ \t]*(?i:host|match)\b)
pop: true
pop-nl-as-value:
- match: \n
scope: meta.mapping.value.ssh_config
pop: true
# Host
host:
- match: ^[ \t]*((?i:host))\b
captures:
1: meta.block.host.ssh_config keyword.declaration.host-alias.ssh_config
set: host-aliases
host-aliases:
- meta_scope: meta.block.host.ssh_config
- match: (?=\n)
set: host-body
- include: host-patterns
host-body:
- meta_scope: meta.block.host.ssh_config
- include: pop-before-next-host
- include: options
# Match
match:
- match: ^[ \t]*((?i:match))\b
captures:
1: meta.block.match.ssh_config keyword.control.conditional.ssh_config
set: match-conditions
match-conditions:
- meta_content_scope: meta.block.match.ssh_config meta.statement.conditional.ssh_config
- match: \n
set: match-body
- match: '!'
scope: keyword.operator.logical.ssh_config
- match: \b(?i:all)\b
scope: constant.language.boolean.ssh_config
- match: \b(?i:canonical|final)\b
scope: keyword.other.ssh_config
- match: \b((?i:exec))\b[ \t]*(\")
captures:
1: keyword.other.ssh_config
2: string.quoted.double.ssh_config punctuation.definition.string.begin.ssh_config
escape: (?<!\\)\"(?=\s*(?:#.*)?)
escape_captures:
0: string.quoted.double.ssh_config punctuation.definition.string.end.ssh_config
embed: scope:source.shell
- match: \b((?i:exec))\b[ \t]+
captures:
1: keyword.other.ssh_config
with_prototype:
- include: match-exec-tokens
- include: pop-before-match-option
push:
- meta_content_scope: source.embedded.shell
- include: scope:source.shell
- match: \b(?i:(?:original)?host)\b
scope: keyword.other.ssh_config
push:
- include: pop-before-match-option
- match: ','
scope: punctuation.separator.sequence.ssh_config
- include: host-patterns
- match: \b(?i:(?:local)?user)\b
scope: keyword.other.ssh_config
push:
- include: pop-before-match-option
- match: \S
scope: string.unquoted.ssh_config
match-body:
- meta_scope: meta.block.match.ssh_config
- include: pop-before-next-host
- include: options
# Options
hostname:
- match: ^[ \t]*((?i:hostname))\b[ \t]*(=)?
captures:
1: meta.mapping.key.ssh_config keyword.declaration.host.ssh_config
2: keyword.operator.assignment.ssh_config
push:
- include: SSH Common.sublime-syntax#pop-nl
- include: hostname-or-ip-value
hostname-or-ip-value:
- match: |-
(?x:
(
((?:\d{1,3}\.){3}\d{1,3})| # simple IPv4
((?i:[a-f0-9:]+:+)+[a-f0-9]+)| # simple IPv6
(\S+) # anything else
)
[ \t]* # any whitespace
(\S*) # anything else on the line
)
scope: meta.mapping.value.ssh_config
captures:
1: meta.string.host.ssh_config
2: constant.numeric.ip-address.v4.ssh_config
3: constant.numeric.ip-address.v6.ssh_config
4: string.unquoted.hostname.ssh_config
5: invalid.illegal.ssh_config
host-patterns:
# https://man7.org/linux/man-pages/man5/ssh_config.5.html#PATTERNS
# https://man.openbsd.org/ssh_config.5#PATTERNS
- match: '!'
scope: keyword.operator.logical.ssh_config
- match: '[^\s*?,]+'
scope: entity.name.label.host-alias.ssh_config
- match: \*|\?
scope: entity.name.label.host-alias.ssh_config keyword.operator.wildcard.ssh_config
match-exec-tokens:
# https://man7.org/linux/man-pages/man5/ssh_config.5.html#TOKENS
# https://man.openbsd.org/ssh_config.5#TOKENS
- match: '%[%hiLlnpru]'
scope: constant.character.escape.ssh_config
proxycommand:
- match: ^\s*((?i:proxycommand))\b[ \t]*(=)?
captures:
1: meta.mapping.key.ssh_config keyword.other.ssh_config
2: keyword.operator.assignment.ssh_config
with_prototype:
- match: '%[%hpr]'
scope: constant.character.escape.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config source.embedded.shell
- match: none
scope: constant.language.set.ssh_config
pop: true
- include: scope:source.shell
- include: pop-nl-as-value
localcommand:
- match: ^\s*((?i:localcommand))\b[ \t]*(=)?
captures:
1: meta.mapping.key.ssh_config keyword.other.ssh_config
2: keyword.operator.assignment.ssh_config
with_prototype:
- match: '%[%CdhilnprTu]'
scope: constant.character.escape.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config source.embedded.shell
- match: none
scope: constant.language.set.ssh_config
pop: true
- include: scope:source.shell
- include: pop-nl-as-value
boolean-value:
- match: \b(?i:yes|no)\b
scope: constant.language.boolean.ssh_config
boolean-value-with-typing:
- include: boolean-value
# Match while typing as well
- match: \b(?i:y(?:es?)?|no?)\b
boolean-option:
- match: |-
(?x:
^\s*((?i:
(?:Pubkey|HostBased|Password|ChallengeResponse|
KbdInteractive|(?:Rhosts)?RSA)
Authentication| # Auth
ForwardAgent|ForwardX11(?:Trusted)?|ClearAllForwardings|
ExitOnForwardFailure| # Fwds
BatchMode|CanonicalizeFallbackLocal|CheckHostIP|Compression|
EnableSSHKeySign|GatewayPorts|HashKnownHosts|IdentitiesOnly|
NoHostAuthenticationForLocalhost|PermitLocalCommand|ProxyUseFdpass|
StreamLocalBindUnlink|TCPKeepAlive|UseKeychain|UsePrivilegedPort|
VisualHostKey|
GSSAPI(?:Authentication|KeyExchange|DelegateCredentials|
RenewalForcesRekey|TrustDNS) # GSSAPI
))\b[ \t]*(=)?
)
captures:
1: meta.mapping.key.ssh_config keyword.other.ssh_config
2: keyword.operator.assignment.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config
- include: pop-nl-as-value
- match: '[ \t]+\S+'
scope: invalid.illegal.ssh_config
- include: boolean-value-with-typing
- match: \S+
scope: invalid.illegal.ssh_config
boolean-option-plus:
# ask
- match: ^\s*((?i:StrictHostKeyChecking|VerifyHostKeyDNS))\b[ \t]*(=)?
captures:
1: meta.mapping.key.ssh_config keyword.other.ssh_config
2: keyword.operator.assignment.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config
- include: pop-nl-as-value
- match: '[ \t]+\S+'
scope: invalid.illegal.ssh_config
- include: boolean-value-with-typing
- match: \b(?i:ask)\b
scope: constant.language.set.ssh_config
- match: \b(?i:a(?:s?k)?)\b
- match: \S+
scope: invalid.illegal.ssh_config
generic-option:
- match: ^\s*([a-zA-Z1]+)\b[ \t]*(=)?
captures:
1: meta.mapping.key.ssh_config keyword.other.ssh_config
2: keyword.operator.assignment.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config
- include: boolean-value
- include: tokens
- match: \b\d+(?=[\s,"])
scope: constant.numeric.ssh_config
- match: \"
scope: punctuation.definition.string.begin.ssh_config
push:
- meta_scope: string.quoted.double.ssh_config
- match: \"
scope: punctuation.definition.string.end.ssh_config
pop: true
- match: \n|$
scope: invalid.illegal.ssh_config
pop: true
- include: generic-option-includes
- match: \S
scope: string.unquoted.ssh_config
push:
- meta_content_scope: string.unquoted.ssh_config
- include: SSH Common.sublime-syntax#pop-before-nl
- include: generic-option-includes
- include: pop-nl-as-value
generic-option-includes:
- include: tokens
- match: \*|\?
scope: keyword.operator.wildcard.ssh_config
- match: '!'
scope: keyword.operator.logical.ssh_config
- match: ','
scope: punctuation.separator.sequence.ssh_config
- include: SSH Crypto.sublime-syntax#ssh-key-types
- include: SSH Crypto.sublime-syntax#ssh-ciphers
- include: SSH Crypto.sublime-syntax#ssh-kex-algorithms
- include: SSH Crypto.sublime-syntax#ssh-mac-algorithms
- include: SSH Common.sublime-syntax#ipv6-square-bracket
- include: SSH Common.sublime-syntax#ip-addresses-with-cidr
- include: SSH Common.sublime-syntax#time-values
- include: SSH Common.sublime-syntax#bytes-values
comments:
- include: SSH Common.sublime-syntax#comments-number-sign
- include: SSH Common.sublime-syntax#comments-semicolon