summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantos Gallegos <stsewd@protonmail.com>2021-01-02 16:56:05 -0500
committerSantos Gallegos <stsewd@protonmail.com>2021-01-02 17:19:08 -0500
commit6aaf240d0c6ad10676e252f2e89110820d706718 (patch)
tree851304df51d0851ac45e52b7f92c6359cb45e84e
parent6114a6ed97527ffd1938815f2276d77d908c94c2 (diff)
RST: update injection queries
Finally, highlight for code blocks
-rw-r--r--lockfile.json2
-rw-r--r--queries/rst/highlights.scm3
-rw-r--r--queries/rst/injections.scm43
-rw-r--r--queries/rst/locals.scm2
4 files changed, 33 insertions, 17 deletions
diff --git a/lockfile.json b/lockfile.json
index 9c9b4981..e2f813a3 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -93,7 +93,7 @@
"revision": "be2e415b5716615530234d179dc27c32b7a1d86b"
},
"rst": {
- "revision": "a2ef2b3fae0c5b07f7c386c6397d4812275ea4e5"
+ "revision": "b3cdb27d3da6f48bec8533ea92a0f54a39679ebb"
},
"ruby": {
"revision": "bb572f60e9538bd11fbde95a54f97522073f1e06"
diff --git a/queries/rst/highlights.scm b/queries/rst/highlights.scm
index 683f0437..b0c1735e 100644
--- a/queries/rst/highlights.scm
+++ b/queries/rst/highlights.scm
@@ -17,6 +17,9 @@
(directive
name: (type) @function)
+(directive
+ body: (body (arguments) @parameter))
+
((directive
name: (type) @include)
(#eq? @include "include"))
diff --git a/queries/rst/injections.scm b/queries/rst/injections.scm
index 01d84086..475ad2f4 100644
--- a/queries/rst/injections.scm
+++ b/queries/rst/injections.scm
@@ -1,35 +1,48 @@
(doctest_block) @python
-;; Directives with nested content
-
+;; Directives with nested content without arguments nor options
((directive
name: (type) @_type
body: (body) @rst)
(#match?
@_type
- "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(image|figure)|(topic|sidebar|line-block|parsed-literal|rubric|epigraph|highlights|pull-quote|compound|container)|(table|list-table)|(contents|sectnum|section-numbering|header|footer)|(target-notes)|(meta)|(replace|unicode|date)|(include|class|role|default-role|title|restructuredtext-test-directive)$"))
+ "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(line-block|parsed-literal|epigraph|highlights|pull-quote|compound)|(header|footer)|(meta)|(replace)$"))
-;; Special directives
+;; Directives with nested content without arguments, but with options
+((directive
+ name: (type) @_type
+ body: (body (options) (content) @rst))
+ (#match?
+ @_type
+ "^(attention|caution|danger|error|hint|important|note|tip|warning|admonition)|(line-block|parsed-literal|compound)$"))
+
+;; Directives with nested content with arguments and options
+((directive
+ name: (type) @_type
+ body: (body (content) @rst))
+ (#match?
+ @_type
+ "^(figure)|(topic|sidebar|container)|(table|list-table)|(class|role|restructuredtext-test-directive)$"))
-;; TODO: using @language and @content on the same capture raises an error.
-;; ((directive
-;; name: (type) @_type
-;; body: (body) @language @content)
-;; (#eq? @_type "code"))
+;; Special directives
+((directive
+ name: (type) @_type
+ body: (body (arguments) @language (content) @content))
+ (#eq? @_type "code"))
-;; ((directive
-;; name: (type) @_type
-;; body: (body) @language @content)
-;; (#eq? @_type "raw"))
+((directive
+ name: (type) @_type
+ body: (body (arguments) @language (content) @content))
+ (#eq? @_type "raw"))
((directive
name: (type) @_type
- body: (body) @latex)
+ body: (body (content) @latex))
(#eq? @_type "math"))
((directive
name: (type) @_type
- body: (body) @csv)
+ body: (body (content) @csv))
(#eq? @_type "csv-table"))
;; Special roles - prefix
diff --git a/queries/rst/locals.scm b/queries/rst/locals.scm
index c0c99179..bf8bd041 100644
--- a/queries/rst/locals.scm
+++ b/queries/rst/locals.scm
@@ -26,7 +26,7 @@
; The role directive can define a new role
((directive
name: (type) @_type
- body: (body) @definition)
+ body: (body (arguments) @definition))
(#eq? @_type "role"))
;; References