diff --git a/packages/vscode-extension/package.json b/packages/vscode-extension/package.json index 6345004bf..0ef432c9a 100644 --- a/packages/vscode-extension/package.json +++ b/packages/vscode-extension/package.json @@ -224,6 +224,16 @@ "meta.embedded.block.cypher": "cypher" } }, + { + "injectTo": [ + "text.asciidoc" + ], + "scopeName": "inline.cypher.asciidoc.codeblock", + "path": "./syntaxes/cypher.adoc.json", + "embeddedLanguages": { + "meta.embedded.block.cypher": "cypher" + } + }, { "injectTo": [ "source.js", diff --git a/packages/vscode-extension/syntaxes/cypher.adoc.json b/packages/vscode-extension/syntaxes/cypher.adoc.json new file mode 100644 index 000000000..62dfcaae5 --- /dev/null +++ b/packages/vscode-extension/syntaxes/cypher.adoc.json @@ -0,0 +1,46 @@ +{ + "scopeName": "inline.cypher.asciidoc.codeblock", + "injectionSelector": "L:text.asciidoc -meta.embedded.block", + "patterns": [ + { + "name": "markup.code.cypher.asciidoc", + "begin": "^\\[(source)(,|#)\\s*(?i:(cypher))([^\\]]+)*\\]\\s*$", + "beginCaptures": { + "1": { + "name": "markup.meta.attribute-list.asciidoc entity.name.function.asciidoc" + }, + "3": { + "name": "markup.meta.attribute-list.asciidoc markup.heading.asciidoc" + }, + "4": { + "name": "markup.meta.attribute-list.asciidoc markup.heading.asciidoc" + } + }, + "patterns": [ + { + "comment": "listing block", + "begin": "^(-{4,})\\s*$", + "contentName": "source.block.cypher", + "patterns": [ + { + "include": "source.cypher" + } + ], + "end": "^(\\1)$" + }, + { + "comment": "open block", + "begin": "^(-{2})\\s*$", + "contentName": "source.embedded.cypher", + "patterns": [ + { + "include": "source.cypher" + } + ], + "end": "^(\\1)$" + } + ], + "end": "((?<=--|\\.\\.\\.\\.)$|^\\s*$)" + } + ] +} diff --git a/packages/vscode-extension/tests/fixtures/textmate/simple-match.adoc b/packages/vscode-extension/tests/fixtures/textmate/simple-match.adoc new file mode 100644 index 000000000..823550388 --- /dev/null +++ b/packages/vscode-extension/tests/fixtures/textmate/simple-match.adoc @@ -0,0 +1,38 @@ +[source,java] +---- +import org.neo4j.cypherdsl.parser.CypherParser; + +public class Demo { + public static void main(String...a) { + var node = CypherParser.parseNode("(m:Movie)"); + } +} +---- +Some random text + + +[source,cypher] +---- +/* This is a +multiline comment +*/ +MATCH (u1:CommerceUser{user_id:$seller_id}), + (u2:CommerceUser{user_id:$customer_id}), + p = allShortestPaths((u1)-[:PURCHASE*..10]->(u2)) +WHERE u1 <> u2 +WITH + // This is a single line comment + reduce(output = [], n IN relationships(p) | output + n.create_time.epochMillis ) as relsDate, + reduce(output = [], n IN nodes(p) | output + n ) as nodes, + "double quoted string" as a, + 'single quoted string' as b +RETURN relsDate, nodes +LIMIT $limit +---- + +Some other text + +[source,cypher,indent=0,tabsize=4] +---- +MATCH (n) RETURN n +---- \ No newline at end of file