vscode: add highlighting of syntax tree
This commit is contained in:
@@ -411,6 +411,21 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"languages": [
|
||||||
|
{
|
||||||
|
"id": "ra_syntax_tree",
|
||||||
|
"extensions": [
|
||||||
|
".rast"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"grammars": [
|
||||||
|
{
|
||||||
|
"language": "ra_syntax_tree",
|
||||||
|
"scopeName": "source.ra_syntax_tree",
|
||||||
|
"path": "ra_syntax_tree.tmGrammar.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
"problemMatchers": [
|
"problemMatchers": [
|
||||||
{
|
{
|
||||||
"name": "rustc",
|
"name": "rustc",
|
||||||
|
|||||||
31
editors/code/ra_syntax_tree.tmGrammar.json
Normal file
31
editors/code/ra_syntax_tree.tmGrammar.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||||
|
|
||||||
|
"scopeName": "source.ra_syntax_tree",
|
||||||
|
"patterns": [
|
||||||
|
{ "include": "#node_type" },
|
||||||
|
{ "include": "#node_range_index" },
|
||||||
|
{ "include": "#token_text" }
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"node_type": {
|
||||||
|
"match": "^\\s*([A-Z_]+?)@",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "entity.name.class"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_range_index": {
|
||||||
|
"match": "\\d+",
|
||||||
|
"name": "constant.numeric"
|
||||||
|
},
|
||||||
|
"token_text": {
|
||||||
|
"match": "\".+\"",
|
||||||
|
"name": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fileTypes": [
|
||||||
|
"rast"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -15,6 +15,9 @@ export function syntaxTree(ctx: Ctx): Cmd {
|
|||||||
void new AstInspector(ctx);
|
void new AstInspector(ctx);
|
||||||
|
|
||||||
ctx.pushCleanup(vscode.workspace.registerTextDocumentContentProvider(AST_FILE_SCHEME, tdcp));
|
ctx.pushCleanup(vscode.workspace.registerTextDocumentContentProvider(AST_FILE_SCHEME, tdcp));
|
||||||
|
ctx.pushCleanup(vscode.languages.setLanguageConfiguration("ra_syntax_tree", {
|
||||||
|
brackets: [["[", ")"]],
|
||||||
|
}));
|
||||||
|
|
||||||
return async () => {
|
return async () => {
|
||||||
const editor = vscode.window.activeTextEditor;
|
const editor = vscode.window.activeTextEditor;
|
||||||
@@ -36,7 +39,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TextDocumentContentProvider implements vscode.TextDocumentContentProvider {
|
class TextDocumentContentProvider implements vscode.TextDocumentContentProvider {
|
||||||
readonly uri = vscode.Uri.parse('rust-analyzer://syntaxtree');
|
readonly uri = vscode.Uri.parse('rust-analyzer://syntaxtree/tree.rast');
|
||||||
readonly eventEmitter = new vscode.EventEmitter<vscode.Uri>();
|
readonly eventEmitter = new vscode.EventEmitter<vscode.Uri>();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user