From 5b6ee37d4ad4694c26753a4f437140ed15bf44e3 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 31 Dec 2020 23:00:38 +0100 Subject: [PATCH] Add experimental inline snapshot highlighting for vscode --- vscode-insta/package.json | 12 +++++- .../inline-insta-snapshots.tmLanguage.json | 39 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 vscode-insta/syntaxes/inline-insta-snapshots.tmLanguage.json diff --git a/vscode-insta/package.json b/vscode-insta/package.json index c37e27a2..50af0556 100644 --- a/vscode-insta/package.json +++ b/vscode-insta/package.json @@ -39,7 +39,17 @@ "language": "insta-snapshots", "scopeName": "source.insta-snapshots", "path": "./syntaxes/insta-snapshots.tmLanguage.json" + }, + { + "scopeName": "source.inline-insta-snapshots", + "injectTo": [ + "source.rust" + ], + "path": "./syntaxes/inline-insta-snapshots.tmLanguage.json", + "embeddedLanguages": { + "meta.embedded.inline-insta-snapshot": "insta-snapshots" + } } ] } -} +} \ No newline at end of file diff --git a/vscode-insta/syntaxes/inline-insta-snapshots.tmLanguage.json b/vscode-insta/syntaxes/inline-insta-snapshots.tmLanguage.json new file mode 100644 index 00000000..aaf4312e --- /dev/null +++ b/vscode-insta/syntaxes/inline-insta-snapshots.tmLanguage.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "injectionSelector": "L:source -string -comment", + "fileTypes": [ + "rust" + ], + "patterns": [ + { + "begin": "(@)(r###)(\")", + "contentName": "meta.embedded.inline-insta-snapshot", + "beginCaptures": { + "1": { + "name": "keyword.operator.subpattern.rust" + }, + "2": { + "name": "punctuation.definition.string.raw.rust" + }, + "3": { + "name": "punctuation.definition.string.rust" + } + }, + "end": "(\")(###)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.rust" + }, + "2": { + "name": "punctuation.definition.string.raw.rust" + } + }, + "patterns": [ + { + "include": "source.insta-snapshots#snapshot" + } + ] + } + ], + "scopeName": "source.inline-insta-snapshots" +} \ No newline at end of file