[Mlir-commits] [mlir] 0d74bd3 - [vscode-mlir] Add proper support for mlir markdown codeblocks

River Riddle llvmlistbot at llvm.org
Tue Aug 3 12:55:43 PDT 2021


Author: River Riddle
Date: 2021-08-03T19:55:31Z
New Revision: 0d74bd332d740fa65cc3069f7bbe45d86b295185

URL: https://github.com/llvm/llvm-project/commit/0d74bd332d740fa65cc3069f7bbe45d86b295185
DIFF: https://github.com/llvm/llvm-project/commit/0d74bd332d740fa65cc3069f7bbe45d86b295185.diff

LOG: [vscode-mlir] Add proper support for mlir markdown codeblocks

A special language contribution is required for properly
supporting markdown code blocks in vscodes builtin markdown
grammar, see https://github.com/mjbvz/vscode-fenced-code-block-grammar-injection-example
for more details.

Added: 
    mlir/utils/vscode/markdown-grammar.json

Modified: 
    mlir/utils/vscode/package-lock.json
    mlir/utils/vscode/package.json

Removed: 
    


################################################################################
diff  --git a/mlir/utils/vscode/markdown-grammar.json b/mlir/utils/vscode/markdown-grammar.json
new file mode 100644
index 000000000000..2f1f68d42cbe
--- /dev/null
+++ b/mlir/utils/vscode/markdown-grammar.json
@@ -0,0 +1,45 @@
+{
+	"fileTypes": [],
+	"injectionSelector": "L:text.html.markdown",
+	"patterns": [
+		{
+			"include": "#mlir-code-block"
+		}
+	],
+	"repository": {
+		"mlir-code-block": {
+			"begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(mlir)(\\s+[^`~]*)?$)",
+			"name": "markup.fenced_code.block.markdown",
+			"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
+			"beginCaptures": {
+				"3": {
+					"name": "punctuation.definition.markdown"
+				},
+				"4": {
+					"name": "fenced_code.block.language.markdown"
+				},
+				"5": {
+					"name": "fenced_code.block.language.attributes.markdown"
+				}
+			},
+			"endCaptures": {
+				"3": {
+					"name": "punctuation.definition.markdown"
+				}
+			},
+			"patterns": [
+				{
+					"begin": "(^|\\G)(\\s*)(.*)",
+					"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
+					"contentName": "meta.embedded.block.mlir",
+					"patterns": [
+						{
+							"include": "source.mlir"
+						}
+					]
+				}
+			]
+		}
+	},
+	"scopeName": "markdown.mlir.codeblock"
+}
\ No newline at end of file

diff  --git a/mlir/utils/vscode/package-lock.json b/mlir/utils/vscode/package-lock.json
index 4e14aa267e4a..633f2527b23d 100644
--- a/mlir/utils/vscode/package-lock.json
+++ b/mlir/utils/vscode/package-lock.json
@@ -1,12 +1,12 @@
 {
 	"name": "vscode-mlir",
-	"version": "0.0.1",
+	"version": "0.0.2",
 	"lockfileVersion": 2,
 	"requires": true,
 	"packages": {
 		"": {
 			"name": "vscode-mlir",
-			"version": "0.0.1",
+			"version": "0.0.2",
 			"dependencies": {
 				"chokidar": "3.5.2",
 				"vscode-languageclient": "^5.2.1",
@@ -343,6 +343,7 @@
 			"dependencies": {
 				"anymatch": "~3.1.2",
 				"braces": "~3.0.2",
+				"fsevents": "~2.3.2",
 				"glob-parent": "~5.1.2",
 				"is-binary-path": "~2.1.0",
 				"is-glob": "~4.0.1",

diff  --git a/mlir/utils/vscode/package.json b/mlir/utils/vscode/package.json
index aae3ef2d9d37..99fb94696454 100644
--- a/mlir/utils/vscode/package.json
+++ b/mlir/utils/vscode/package.json
@@ -2,7 +2,7 @@
 	"name": "vscode-mlir",
 	"displayName": "MLIR",
 	"description": "MLIR Language Extension",
-	"version": "0.0.1",
+	"version": "0.0.2",
 	"publisher": "llvm-vs-code-extensions",
 	"homepage": "https://mlir.llvm.org/",
 	"icon": "icon.png",
@@ -44,8 +44,8 @@
 		"vscode-test": "^1.3.0"
 	},
 	"repository": {
-			"type": "git",
-			"url": "https://github.com/llvm/vscode-mlir.git"
+		"type": "git",
+		"url": "https://github.com/llvm/vscode-mlir.git"
 	},
 	"contributes": {
 		"languages": [
@@ -59,6 +59,9 @@
 					".mlir"
 				],
 				"configuration": "./language-configuration.json"
+			},
+			{
+				"id": "mlir-injection"
 			}
 		],
 		"grammars": [
@@ -66,6 +69,17 @@
 				"language": "mlir",
 				"scopeName": "source.mlir",
 				"path": "./grammar.json"
+			},
+			{
+				"language": "mlir-injection",
+				"scopeName": "markdown.mlir.codeblock",
+				"path": "markdown-grammar.json",
+				"injectTo": [
+					"text.html.markdown"
+				],
+				"embeddedLanguages": {
+					"meta.embedded.block.mlir": "mlir"
+				}
 			}
 		],
 		"configuration": {


        


More information about the Mlir-commits mailing list