From f545c11b2edfdd968f6186b996eb3ca8b4a5b222 Mon Sep 17 00:00:00 2001 From: farwyler <1705805+farwyler@users.noreply.github.com> Date: Mon, 20 Jun 2022 17:49:07 +0200 Subject: [PATCH] adds stable highlighting for combined jsdoc/comments syntax --- runtime/queries/javascript/injections.scm | 13 ++++++++----- runtime/queries/jsdoc/injections.scm | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 runtime/queries/jsdoc/injections.scm diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm index 41f39720c5d6..af3aef10510e 100644 --- a/runtime/queries/javascript/injections.scm +++ b/runtime/queries/javascript/injections.scm @@ -22,12 +22,15 @@ ((regex_pattern) @injection.content (#set! injection.language "regex")) -; Parse JSDoc annotations in comments +; Parse JSDoc annotations in multiline comments ((comment) @injection.content - (#set! injection.language "jsdoc")) + (#set! injection.language "jsdoc") + (#match? @injection.content "^/\\*+")) -; Parse comment tags (TODO, FIXME, ...) +; Parse general tags in single line comments + +((comment) @injection.content + (#set! injection.language "comment") + (#match? @injection.content "^//")) -([(comment)] @injection.content - (#set! injection.language "comment")) diff --git a/runtime/queries/jsdoc/injections.scm b/runtime/queries/jsdoc/injections.scm new file mode 100644 index 000000000000..877b671d6f86 --- /dev/null +++ b/runtime/queries/jsdoc/injections.scm @@ -0,0 +1,5 @@ +; Parse general comment tags + +((document) @injection.content + (#set! injection.include-children) + (#set! injection.language "comment")) \ No newline at end of file