Skip to content

Commit

Permalink
feat: add highlight tests & injections
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Feb 24, 2024
1 parent 1c9d7ea commit 3a1a5e1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
3 changes: 3 additions & 0 deletions bindings/rust/lib.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
{
"scope": "text.ssh_config",
"highlights": "queries/highlights.scm",
"content-regex": "^\\s*IdentityFile"
"injections": "queries/injections.scm",
"content-regex": "^\\s*IdentityFile",
"file-types": ["ssh_config"]
}
]
}
8 changes: 3 additions & 5 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@

; Keywords

[ "Host" "Match" ] @keyword
[ "Host" "Match" ] @module

(parameter keyword: _ @keyword)

(host_declaration argument: _ @tag)

(match_declaration
(condition criteria: _ @attribute))
(condition criteria: _ @variable.parameter))

"all" @attribute
"all" @variable.parameter

; Misc

Expand All @@ -68,8 +68,6 @@

(comment) @comment

(ERROR) @error

; Punctuation

[ "${" "}" ] @punctuation.special
Expand Down
15 changes: 15 additions & 0 deletions queries/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
((condition
criteria: "exec"
argument: (string) @injection.content)
(#set! injection.language "bash"))

((parameter
keyword:
[
"KnownHostsCommand"
"LocalCommand"
"RemoteCommand"
"ProxyCommand"
]
argument: (string) @injection.content)
(#set! injection.language "bash"))
20 changes: 20 additions & 0 deletions test/highlight/ssh_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ControlMaster auto
# ^^^^ @constant.builtin
ControlPath /tmp/ssh-%C
# ^^^^^^^^^ @string.regexp
# ^^ @string.special.symbol

KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @string.special
# ^ @punctuation.delimiter
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @string.special

Match host=github.com
# <- @module
# ^^^^ @variable.parameter
# ^ @operator
# ^^^^^^^^^^ @string.regexp
IdentityFile ~/.ssh/id_rsa
User git
# ^^^^ @keyword
# ^^^ @string

0 comments on commit 3a1a5e1

Please sign in to comment.