Skip to content

Commit 6664da4

Browse files
committed
Centralize string patterns context
1 parent 3d1717d commit 6664da4

File tree

5 files changed

+29
-32
lines changed

5 files changed

+29
-32
lines changed

SSH Common.sublime-syntax

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,28 @@ contexts:
193193
- include: pop-before-nl
194194
- include: pop-nl
195195

196+
string-patterns:
197+
# https://man7.org/linux/man-pages/man5/ssh_config.5.html#PATTERNS
198+
# https://man.openbsd.org/ssh_config.5#PATTERNS
199+
# https://man7.org/linux/man-pages/man5/sshd_config.5.html#PATTERNS
200+
# https://man.openbsd.org/sshd_config.5#PATTERNS
201+
- include: punctuation-comma-sequence
202+
- include: operator-exclamation
203+
- match: '"'
204+
scope: punctuation.definition.string.begin.ssh.common
205+
push:
206+
- meta_content_scope: string.quoted.double.ssh.common
207+
- match: '"'
208+
scope: punctuation.definition.string.end.ssh.common
209+
pop: 1
210+
- include: wildcards
211+
- match: (?=\S)
212+
push:
213+
- meta_content_scope: string.unquoted.ssh.common
214+
- match: (?=[,!\s])
215+
pop: 1
216+
- include: wildcards
217+
196218
paths:
197219
# This is just heuristic. Expect failures.
198220
- match: (?=~?[\w.\-?*${}%]*/[\w.\-?*${}%]?)

SSH Config.sublime-syntax

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,7 @@ contexts:
145145
scope: keyword.other.ssh_config
146146
push:
147147
- include: pop-before-match-parameter
148-
- match: '"'
149-
scope: punctuation.definition.string.begin.ssh_config
150-
push:
151-
- meta_scope: meta.string.ssh_config string.quoted.double.ssh_config
152-
- match: '"'
153-
scope: punctuation.definition.string.end.ssh_config
154-
pop: 1
155-
- include: wildcards
156-
- match: (?=\S)
157-
push:
158-
- meta_scope: string.unquoted.ssh_config
159-
- match: (?=\s)
160-
pop: 1
161-
- include: wildcards
148+
- include: string-patterns
162149

163150
# Match predicates with CIDR arguments
164151
- match: '\b(?xi: localnetwork )\b'

SSHD Config.sublime-syntax

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,6 @@ contexts:
130130
- include: pop-before-next-match
131131
- include: parameters
132132

133-
string-patterns:
134-
# https://man7.org/linux/man-pages/man5/sshd_config.5.html#PATTERNS
135-
# https://man.openbsd.org/ssh_config.5#PATTERNS
136-
- include: punctuation-comma-sequence
137-
- include: operator-exclamation
138-
- match: (?=\S)
139-
push:
140-
- meta_content_scope: string.unquoted.sshd_config
141-
- match: (?=[,!\s])
142-
pop: 1
143-
- include: wildcards
144-
145133
###[ PARAMETERS ]##############################################################
146134

147135
parameter-forcecommand:

Tests/syntax_test_client.ssh_config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Match Version Op?nSSH_10.0
2323
#^^^^ keyword.control.conditional.ssh_config
2424
# ^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.ssh_config
2525
# ^^^^^^^ keyword.other.ssh_config
26-
# ^^^^^^^^^^^^ string.unquoted.ssh_config
26+
# ^^^^^^^^^^^^ string.unquoted.ssh.common
2727
# ^ constant.other.wildcard.questionmark.ssh.common
2828

2929

@@ -38,7 +38,7 @@ Match Host targ?t_host Exec not_inside_network User sue
3838
# ^^^^ keyword.other.ssh_config
3939
# ^^^^^^^^^^^^^^^^^^ source.shell.embedded.ssh source.shell.bash variable.function.shell
4040
# ^^^^ keyword.other.ssh_config
41-
# ^^^ string.unquoted.ssh_config
41+
# ^^^ string.unquoted.ssh.common
4242
# @@@@@@@@@@@ local-definition "Alias: targ?t_host"
4343
# @@@@@@@@@@@@@@@@@@ reference
4444
ProxyCommand ssh -W %h:%p proxy_server

Tests/syntax_test_server.sshd_config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ Match User *,!username1,!usern.ame2 Host foo.example.com
155155
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.sshd_config
156156
# ^^^^ meta.mapping.key.sshd_config keyword.other.sshd_config
157157
# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.sshd_config
158-
# ^ string.unquoted.sshd_config constant.other.wildcard.asterisk.ssh.common
158+
# ^ string.unquoted.ssh.common constant.other.wildcard.asterisk.ssh.common
159159
# ^ punctuation.separator.sequence.ssh.common
160160
# ^ keyword.operator.logical.ssh.common
161-
# ^^^^^^^^^ string.unquoted.sshd_config
161+
# ^^^^^^^^^ string.unquoted.ssh.common
162162
# ^ punctuation.separator.sequence.ssh.common
163163
# ^ keyword.operator.logical.ssh.common
164-
# ^^^^^^^^^^ string.unquoted.sshd_config - punctuation
164+
# ^^^^^^^^^^ string.unquoted.ssh.common - punctuation
165165
# ^^^^ meta.mapping.key.sshd_config keyword.other.sshd_config
166166
# ^^^^^^^^^^^^^^^^ meta.mapping.value.sshd_config
167-
# ^^^^^^^^^^^^^^^ string.unquoted.sshd_config
167+
# ^^^^^^^^^^^^^^^ string.unquoted.ssh.common
168168
# ^ punctuation.separator.sequence.ssh.common
169169
# ^ punctuation.separator.sequence.ssh.common
170170
PasswordAuthentication yes

0 commit comments

Comments
 (0)