diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index 1a14a0f..89bfe9c 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -41,6 +41,9 @@ pub const NODE_TYPES: &str = include_str!("../../src/node-types.json"); /// The syntax highlighting queries. pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm"); +/// The language injection queries. +pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm"); + #[cfg(test)] mod tests { #[test] diff --git a/package.json b/package.json index 80813db..4c4f045 100644 --- a/package.json +++ b/package.json @@ -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"] } ] } diff --git a/queries/highlights.scm b/queries/highlights.scm index 18130ea..9f797f6 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -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 @@ -68,8 +68,6 @@ (comment) @comment -(ERROR) @error - ; Punctuation [ "${" "}" ] @punctuation.special diff --git a/queries/injections.scm b/queries/injections.scm new file mode 100644 index 0000000..7a617ff --- /dev/null +++ b/queries/injections.scm @@ -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")) diff --git a/test/highlight/ssh_config b/test/highlight/ssh_config new file mode 100644 index 0000000..18480f7 --- /dev/null +++ b/test/highlight/ssh_config @@ -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