[mlir][vscode] Highlight inside c++ raw strings

Within C++ raw strings with mlir delimitter use MLIR syntax.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D115963
This commit is contained in:
Jacques Pienaar 2021-12-17 12:55:44 -08:00
parent 71fe59212c
commit 2d4f3ed551
2 changed files with 170 additions and 116 deletions

View File

@ -0,0 +1,44 @@
{
"scopeName": "source.cpp.mlir",
"injectionSelector": "L:source.cpp",
"patterns": [
{
"include": "#mlir-raw-string"
}
],
"repository": {
"mlir-raw-string": {
"begin": "R\"(?i:mlir)(\\()",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.cpp"
},
"1": {
"name": "mlir.delimeter.raw.string.cpp"
}
},
"end": "\\)(?i:mlir)\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.cpp"
},
"1": {
"name": "mlir.delimeter.raw.string.cpp"
}
},
"name": "mlir.raw.string.cpp",
"patterns": [
{
"contentName": "source.mlir",
"begin": "(?!\\G)",
"end": "(?i)(?=\\)mlir\")",
"patterns": [
{
"include": "source.mlir"
}
]
}
]
}
}
}

View File

@ -1,118 +1,128 @@
{ {
"name": "vscode-mlir", "name": "vscode-mlir",
"displayName": "MLIR", "displayName": "MLIR",
"description": "MLIR Language Extension", "description": "MLIR Language Extension",
"version": "0.0.2", "version": "0.0.3",
"publisher": "llvm-vs-code-extensions", "publisher": "llvm-vs-code-extensions",
"homepage": "https://mlir.llvm.org/", "homepage": "https://mlir.llvm.org/",
"icon": "icon.png", "icon": "icon.png",
"engines": { "engines": {
"vscode": "^1.52.0" "vscode": "^1.52.0"
}, },
"categories": [ "categories": [
"Programming Languages" "Programming Languages"
], ],
"keywords": [ "keywords": [
"LLVM", "LLVM",
"MLIR" "MLIR"
], ],
"activationEvents": [ "activationEvents": [
"onLanguage:mlir" "onLanguage:mlir"
], ],
"main": "./out/extension", "main": "./out/extension",
"scripts": { "scripts": {
"vscode:prepublish": "tsc -p ./", "vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./", "compile": "tsc -watch -p ./",
"format": "clang-format -i --glob=\"{src,test}/*.ts\"", "format": "clang-format -i --glob=\"{src,test}/*.ts\"",
"package": "vsce package", "package": "vsce package",
"publish": "vsce publish", "publish": "vsce publish",
"git-clang-format": "git-clang-format" "git-clang-format": "git-clang-format"
}, },
"dependencies": { "dependencies": {
"chokidar": "3.5.2", "chokidar": "3.5.2",
"vscode-languageclient": "^5.2.1", "vscode-languageclient": "^5.2.1",
"vscode-languageserver-types": "3.16.0" "vscode-languageserver-types": "3.16.0"
}, },
"devDependencies": { "devDependencies": {
"@types/mocha": "^5.2.0", "@types/mocha": "^5.2.0",
"@types/node": "^8.0.0", "@types/node": "^8.0.0",
"@types/vscode": "1.52.*", "@types/vscode": "1.52.*",
"clang-format": "1.4.0", "clang-format": "1.4.0",
"tslint": "^5.16.0", "tslint": "^5.16.0",
"typescript": "^3.5.1", "typescript": "^3.5.1",
"vsce": "^1.75.0", "vsce": "^1.75.0",
"vscode-test": "^1.3.0" "vscode-test": "^1.3.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/llvm/vscode-mlir.git" "url": "https://github.com/llvm/vscode-mlir.git"
}, },
"contributes": { "contributes": {
"languages": [ "languages": [
{ {
"id": "mlir", "id": "mlir",
"aliases": [ "aliases": [
"MLIR", "MLIR",
"mlir" "mlir"
], ],
"extensions": [ "extensions": [
".mlir" ".mlir"
], ],
"configuration": "./language-configuration.json" "configuration": "./language-configuration.json"
}, },
{ {
"id": "mlir-injection" "id": "mlir-injection"
} }
], ],
"grammars": [ "grammars": [
{ {
"language": "mlir", "language": "mlir",
"scopeName": "source.mlir", "scopeName": "source.mlir",
"path": "./grammar.json" "path": "./grammar.json"
}, },
{ {
"language": "mlir-injection", "language": "mlir-injection",
"scopeName": "markdown.mlir.codeblock", "scopeName": "markdown.mlir.codeblock",
"path": "markdown-grammar.json", "path": "markdown-grammar.json",
"injectTo": [ "injectTo": [
"text.html.markdown" "text.html.markdown"
], ],
"embeddedLanguages": { "embeddedLanguages": {
"meta.embedded.block.mlir": "mlir" "meta.embedded.block.mlir": "mlir"
} }
} },
], {
"configuration": { "scopeName": "source.cpp.mlir",
"type": "object", "path": "./cpp-grammar.json",
"title": "MLIR", "injectTo": [
"properties": { "source.cpp"
"mlir.server_path": { ],
"scope": "resource", "embeddedLanguages": {
"type": "string", "source.mlir": "mlir"
"description": "The file path of the mlir-lsp-server executable." }
}, }
"mlir.onSettingsChanged": { ],
"type": "string", "configuration": {
"default": "prompt", "type": "object",
"description": "Action taken when a setting change requires a server restart to take effect.", "title": "MLIR",
"enum": [ "properties": {
"prompt", "mlir.server_path": {
"restart", "scope": "resource",
"ignore" "type": "string",
], "description": "The file path of the mlir-lsp-server executable."
"enumDescriptions": [ },
"Prompt the user for restarting the server", "mlir.onSettingsChanged": {
"Automatically restart the server", "type": "string",
"Do nothing" "default": "prompt",
] "description": "Action taken when a setting change requires a server restart to take effect.",
} "enum": [
} "prompt",
}, "restart",
"commands": [ "ignore"
{ ],
"command": "mlir.restart", "enumDescriptions": [
"title": "mlir: Restart language server" "Prompt the user for restarting the server",
} "Automatically restart the server",
] "Do nothing"
} ]
}
}
},
"commands": [
{
"command": "mlir.restart",
"title": "mlir: Restart language server"
}
]
}
} }