summaryrefslogtreecommitdiff
path: root/queries/rst
diff options
context:
space:
mode:
authorSantos Gallegos <stsewd@protonmail.com>2020-07-26 09:38:53 -0500
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-07-27 09:16:26 +0200
commit6f01384cb2d60db4b5990085422711c0a764ed7f (patch)
treedbdec53dd3a92957a4d6c9ceba833f5fd52d57d0 /queries/rst
parent121c44a23bebefe2272da295d81d9eb5929e4cc4 (diff)
Parsers: add reStructuredText
Diffstat (limited to 'queries/rst')
-rw-r--r--queries/rst/highlights.scm81
-rw-r--r--queries/rst/locals.scm31
-rw-r--r--queries/rst/textobjects.scm2
3 files changed, 114 insertions, 0 deletions
diff --git a/queries/rst/highlights.scm b/queries/rst/highlights.scm
new file mode 100644
index 00000000..477ede2c
--- /dev/null
+++ b/queries/rst/highlights.scm
@@ -0,0 +1,81 @@
+; Marks
+
+[
+ ".."
+ "|"
+ "--"
+ "__"
+ "::"
+ "bullet"
+ "adornment"
+ (transition)
+] @punctuation.special
+
+; Directives
+
+(directive
+ name: (type) @function)
+
+((directive
+ name: (type) @include)
+ (#match? @include "^include::$"))
+
+; Blocks
+
+[
+ (literal_block)
+ (line_block)
+ (block_quote)
+ (doctest_block)
+] @text.literal
+
+(substitution_definition
+ name: (substitution) @constant)
+
+(footnote
+ name: (label) @constant)
+
+(citation
+ name: (label) @constant)
+
+(target
+ name: (reference)? @constant
+ link: (_) @text.literal)
+
+; Inline markup
+
+(emphasis) @text.emphasis
+
+(strong) @text.strong
+
+(standalone_hyperlink) @text.uri
+
+[
+ (interpreted_text)
+ (literal)
+] @text.literal
+
+[
+ (target)
+ (substitution_reference)
+ (footnote_reference)
+ (citation_reference)
+ (reference)
+] @constant
+
+; Embedded
+
+(doctest_block) @embed
+(directive
+ body: (body) @embed)
+
+; Others
+
+(title) @text.title
+
+(attribution) @text.emphasis
+
+(comment) @comment
+(comment "..") @comment
+
+(ERROR) @error
diff --git a/queries/rst/locals.scm b/queries/rst/locals.scm
new file mode 100644
index 00000000..4838935b
--- /dev/null
+++ b/queries/rst/locals.scm
@@ -0,0 +1,31 @@
+;; Scopes
+
+(document) @scope
+
+(directive) @scope
+
+;; Definitions
+
+(substitution_definition
+ name: (substitution) @definition)
+
+(footnote
+ name: (label) @definition)
+
+(citation
+ name: (label) @definition)
+
+(target
+ name: (reference) @definition)
+
+; Inline targets
+(target) @definition
+
+;; References
+
+[
+ (substitution_reference)
+ (footnote_reference)
+ (citation_reference)
+ (reference)
+] @reference
diff --git a/queries/rst/textobjects.scm b/queries/rst/textobjects.scm
new file mode 100644
index 00000000..baeadc93
--- /dev/null
+++ b/queries/rst/textobjects.scm
@@ -0,0 +1,2 @@
+(directive
+ body: (body) @function.inner) @function.outer