diff --git a/Go/Embeddings/Go (Embedded TSQL).sublime-syntax b/Go/Embeddings/Go (Embedded TSQL).sublime-syntax new file mode 100644 index 0000000000..854c48f25e --- /dev/null +++ b/Go/Embeddings/Go (Embedded TSQL).sublime-syntax @@ -0,0 +1,19 @@ +%YAML 1.2 +--- +name: Go (Embedded T-SQL) +scope: source.go.embedded-backtick-string.tsql +version: 2 +hidden: true + +extends: Packages/Go/Embeddings/Go (Embedded Backtick String).sublime-syntax + +contexts: + match-raw-string: + # replaces Go.sublime-syntax#match-raw-string + - match: '`' + scope: meta.string.go string.quoted.backtick.go punctuation.definition.string.begin.go + embed: scope:source.tsql.go-embedded-backtick-string + embed_scope: meta.string.go meta.embedded.go source.sql.embedded.go + escape: '`' + escape_captures: + 0: meta.string.go string.quoted.backtick.go punctuation.definition.string.end.go diff --git a/Go/Embeddings/TSQL (for Go Embedded Backtick Strings).sublime-syntax b/Go/Embeddings/TSQL (for Go Embedded Backtick Strings).sublime-syntax new file mode 100644 index 0000000000..57128ea3ff --- /dev/null +++ b/Go/Embeddings/TSQL (for Go Embedded Backtick Strings).sublime-syntax @@ -0,0 +1,21 @@ +%YAML 1.2 +--- +name: T-SQL inside Go backtick string +scope: source.tsql.go-embedded-backtick-string +version: 2 +hidden: true + +extends: Packages/SQL/TSQL.sublime-syntax + +contexts: + prototype: + - meta_prepend: true + - include: scope:source.go#match-raw-text-content + + string-escape: + - meta_prepend: true + - include: scope:source.go#match-raw-string-content + + string-interpolation: + - meta_prepend: true + - include: scope:source.go#match-raw-string-content diff --git a/Go/Go.sublime-syntax b/Go/Go.sublime-syntax index ece8a70a52..258a0791e5 100644 --- a/Go/Go.sublime-syntax +++ b/Go/Go.sublime-syntax @@ -250,6 +250,9 @@ contexts: - match: (?i)sql\b scope: meta.annotation.parameters.go constant.other.language-name.go set: scope:source.go.embedded-backtick-string.sql#match-comment-magic-language-injection-inner + - match: (?i)t-?sql\b + scope: meta.annotation.parameters.go constant.other.language-name.go + set: scope:source.go.embedded-backtick-string.tsql#match-comment-magic-language-injection-inner - match: (?i)xml\b scope: meta.annotation.parameters.go constant.other.language-name.go set: scope:source.go.embedded-backtick-string.xml#match-comment-magic-language-injection-inner diff --git a/Go/tests/syntax_test_go.go b/Go/tests/syntax_test_go.go index 9dc2db5fb3..bcfa57413f 100644 --- a/Go/tests/syntax_test_go.go +++ b/Go/tests/syntax_test_go.go @@ -5783,6 +5783,17 @@ func lang_embedding() { not_sql_string = `select not sql` // ^^^^^^^^^^^^^^^^ meta.string.go string.quoted.backtick.go - source.sql + //language=t-sql + // <- comment.line.double-slash.go punctuation.definition.comment.go + //^^^^^^^^^^^^^^^ comment.line.double-slash.go + //^^^^^^^^ meta.annotation.identifier.go + // ^ meta.annotation keyword.operator.assignment.go + // ^^^^^ meta.annotation.parameters.go constant.other.language-name.go + sqlQuery = ` + SELECT id + FROM ##global_temp_table;` + // ^^ punctuation.definition.variable + response := &http.Response{ StatusCode: http.StatusUnauthorized, //language=json