Skip to content

Commit

Permalink
Continue some meta scopes thru line end
Browse files Browse the repository at this point in the history
To support autocomplete at EOL
  • Loading branch information
michaelblyons committed May 15, 2020
1 parent 99edfc9 commit 2a26224
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
17 changes: 11 additions & 6 deletions SSH Config.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ contexts:
- 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
Expand Down Expand Up @@ -63,7 +68,7 @@ contexts:

match-conditions:
- meta_content_scope: meta.block.match.ssh_config meta.statement.conditional.ssh_config
- match: (?=\n)
- match: \n
set: match-body

- match: '!'
Expand Down Expand Up @@ -168,7 +173,7 @@ contexts:
scope: constant.language.set.ssh_config
pop: true
- include: scope:source.shell
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value

localcommand:
- match: ^\s*((?i:localcommand))\b[ \t]*(=)?
Expand All @@ -184,7 +189,7 @@ contexts:
scope: constant.language.set.ssh_config
pop: true
- include: scope:source.shell
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value

boolean-value:
- match: \b(?i:yes|no)\b
Expand Down Expand Up @@ -218,7 +223,7 @@ contexts:
2: keyword.operator.assignment.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value
- match: '[ \t]+\S+'
scope: invalid.illegal.ssh_config
- include: boolean-value-with-typing
Expand All @@ -233,7 +238,7 @@ contexts:
2: keyword.operator.assignment.ssh_config
push:
- meta_content_scope: meta.mapping.value.ssh_config
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value
- match: '[ \t]+\S+'
scope: invalid.illegal.ssh_config
- include: boolean-value-with-typing
Expand Down Expand Up @@ -271,7 +276,7 @@ contexts:
- meta_content_scope: string.unquoted.ssh_config
- include: SSH Common.sublime-syntax#pop-before-nl
- include: generic-option-includes
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value

generic-option-includes:
- include: tokens
Expand Down
13 changes: 9 additions & 4 deletions SSHD Config.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ contexts:
- match: (?=^[ \t]*(?i:match)\b)
pop: true

# Match
pop-nl-as-value:
- match: \n
scope: meta.mapping.value.ssh_config
pop: true

# Match
match:
- match: ^[ \t]*((?i:match))\b
captures:
Expand All @@ -74,7 +79,7 @@ contexts:

match-conditions:
- meta_content_scope: meta.block.match.sshd_config meta.statement.conditional.sshd_config
- match: (?=\n)
- match: \n
set: match-body

- match: '!'
Expand Down Expand Up @@ -134,7 +139,7 @@ contexts:
scope: constant.language.set.sshd_config
pop: true
- include: scope:source.shell
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value

generic-option:
- match: ^\s*([a-zA-Z1]+)\b[ \t]*(=)?
Expand All @@ -160,7 +165,7 @@ contexts:
- meta_content_scope: string.unquoted.sshd_config
- include: SSH Common.sublime-syntax#pop-before-nl
- include: generic-option-value
- include: SSH Common.sublime-syntax#pop-nl
- include: pop-nl-as-value

generic-option-value:
- match: \b(?i:yes|no)\b
Expand Down
4 changes: 2 additions & 2 deletions Tests/syntax_test_client.ssh_config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Match Host targ?t_host Exec not_inside_network User sue
# ^^^ keyword.control.conditional
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional
# ^^^^ keyword.other
# ^^^^^^^^^^^ entity.name.label.host-alias
# ^ keyword.operator.wildcard
Expand All @@ -12,8 +12,8 @@ Match Host targ?t_host Exec not_inside_network User sue
# ^ - source.embedded.shell
# ^^^^ keyword.other
# ^^^ string.unquoted
# ^ - meta.statement
ProxyCommand ssh -W %h:%p proxy_server
#<- - meta.statement
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.match
# ^^^^^^^^^^ keyword.other
# ^^^^^^^^^^^^^^^^^^^^^^^^^ source.embedded.shell
Expand Down
2 changes: 1 addition & 1 deletion Tests/syntax_test_server.sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Match User username1,username2 Address 192.168.0.0/16
Match User username1,username2 Address *,!192.168.0.0/16
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.block.match meta.block.match
#^^^^ meta.block.match keyword.control.conditional
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional
# ^^^^ keyword.other
# ^^^^^^^^^^^^^^^^^^^ string.unquoted
# ^ punctuation.separator.sequence
Expand Down

0 comments on commit 2a26224

Please sign in to comment.