chore: query formatting

This commit is contained in:
Pham Huy Hoang 2024-01-06 15:05:50 +09:00 committed by Christian Clason
parent 79975d6557
commit 57a8acf0c4
674 changed files with 18466 additions and 12648 deletions

View file

@ -1,5 +1,4 @@
;; Marks
; Marks
[
".."
"|"
@ -14,24 +13,25 @@
"bullet"
"adornment"
] @markup.list
;; Resets for injection
; Resets for injection
(doctest_block) @none
;; Directives
; Directives
(directive
name: (type) @function)
(directive
body: (body (arguments) @variable.parameter))
body:
(body
(arguments) @variable.parameter))
((directive
name: (type) @keyword.import)
(#eq? @keyword.import "include"))
(#eq? @keyword.import "include"))
((directive
name: (type) @function.builtin)
name: (type) @function.builtin)
; format-ignore
(#any-of? @function.builtin
; https://docutils.sourceforge.io/docs/ref/rst/directives.html
@ -45,8 +45,7 @@
"replace" "unicode" "date"
"raw" "class" "role" "default-role" "title" "restructuredtext-test-directive"))
;; Blocks
; Blocks
[
(literal_block)
(line_block)
@ -68,18 +67,17 @@
name: (name)? @markup.link.label
link: (_)? @markup.link)
;; Lists
; Lists
; Definition lists
(list_item
(term) @markup.strong
(classifier)? @markup.italic)
; Field lists
(field (field_name) @constant)
;; Inline markup
(field
(field_name) @constant)
; Inline markup
(emphasis) @markup.italic
(strong) @markup.strong
@ -111,7 +109,7 @@
":raw:"))
[
"interpreted_text"
"interpreted_text"
(literal)
] @markup.raw
@ -119,33 +117,33 @@
((interpreted_text
(role) @_role
"interpreted_text" @markup.italic)
(#eq? @_role ":emphasis:"))
(#eq? @_role ":emphasis:"))
((interpreted_text
(role) @_role
"interpreted_text" @markup.strong)
(#eq? @_role ":strong:"))
(#eq? @_role ":strong:"))
((interpreted_text
(role) @_role
"interpreted_text" @none)
(#eq? @_role ":math:"))
(#eq? @_role ":math:"))
; Suffix role
((interpreted_text
"interpreted_text" @markup.italic
(role) @_role)
(#eq? @_role ":emphasis:"))
(#eq? @_role ":emphasis:"))
((interpreted_text
"interpreted_text" @markup.strong
(role) @_role)
(#eq? @_role ":strong:"))
(#eq? @_role ":strong:"))
((interpreted_text
"interpreted_text" @none
(role) @_role)
(#eq? @_role ":math:"))
(#eq? @_role ":math:"))
[
(inline_target)
@ -155,17 +153,19 @@
(reference)
] @markup.link @nospell
;; Others
; Others
(title) @markup.heading
(comment) @comment @spell
(comment "..") @comment
(comment
"..") @comment
(directive
name: (type) @_directive
body: (body
(content) @spell
(#not-any-of? @_directive "code" "code-block" "sourcecode")))
name: (type) @_directive
body:
(body
(content) @spell
(#not-any-of? @_directive "code" "code-block" "sourcecode")))
(paragraph) @spell

View file

@ -1,80 +1,78 @@
((doctest_block) @injection.content
(#set! injection.language "python"))
;; Directives with nested content without arguments nor options
(#set! injection.language "python"))
; Directives with nested content without arguments nor options
((directive
name: (type) @_type
body: (body) @injection.content)
(#set! injection.language "rst")
(#any-of?
@_type
"attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition"
"line-block" "parsed-literal" "epigraph" "highlights" "pull-quote" "compound"
"header" "footer"
"meta"
"replace"))
name: (type) @_type
body: (body) @injection.content)
(#set! injection.language "rst")
(#any-of? @_type "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" "line-block" "parsed-literal" "epigraph" "highlights" "pull-quote" "compound" "header" "footer" "meta" "replace"))
;; Directives with nested content without arguments, but with options
; Directives with nested content without arguments, but with options
((directive
name: (type) @_type
body: (body (options) (content) @injection.content))
(#set! injection.language "rst")
(#any-of?
@_type
"attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition"
"line-block" "parsed-literal" "compound"))
name: (type) @_type
body:
(body
(options)
(content) @injection.content))
(#set! injection.language "rst")
(#any-of? @_type "attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition" "line-block" "parsed-literal" "compound"))
;; Directives with nested content with arguments and options
; Directives with nested content with arguments and options
((directive
name: (type) @_type
body: (body (content) @injection.content))
(#set! injection.language "rst")
(#any-of?
@_type
"figure"
"topic" "sidebar" "container"
"table" "list-table"
"class" "role" "restructuredtext-test-directive"))
name: (type) @_type
body:
(body
(content) @injection.content))
(#set! injection.language "rst")
(#any-of? @_type "figure" "topic" "sidebar" "container" "table" "list-table" "class" "role" "restructuredtext-test-directive"))
;; Special directives
; Special directives
((directive
name: (type) @_type
body: (body (arguments) @injection.language (content) @injection.content))
(#any-of? @_type "code" "code-block" "sourcecode"))
name: (type) @_type
body:
(body
(arguments) @injection.language
(content) @injection.content))
(#any-of? @_type "code" "code-block" "sourcecode"))
((directive
name: (type) @_type
body: (body (arguments) @injection.language (content) @injection.content))
(#eq? @_type "raw"))
name: (type) @_type
body:
(body
(arguments) @injection.language
(content) @injection.content))
(#eq? @_type "raw"))
((directive
name: (type) @_type
body: (body (content) @injection.content))
(#set! injection.language "latex")
(#eq? @_type "math"))
name: (type) @_type
body:
(body
(content) @injection.content))
(#set! injection.language "latex")
(#eq? @_type "math"))
; TODO: re-add when a parser for csv is added.
((directive
name: (type) @_type
body: (body (content) @injection.content))
(#set! injection.language "csv")
(#eq? @_type "csv-table"))
;; Special roles - prefix
name: (type) @_type
body:
(body
(content) @injection.content))
(#set! injection.language "csv")
(#eq? @_type "csv-table"))
; Special roles - prefix
((interpreted_text
(role) @_role
"interpreted_text" @injection.content)
(#eq? @_role ":math:")
(#set! injection.language "latex"))
;; Special roles - suffix
(#eq? @_role ":math:")
(#set! injection.language "latex"))
; Special roles - suffix
((interpreted_text
"interpreted_text" @injection.content
(role) @_role)
(#eq? @_role ":math:")
(#set! injection.language "latex"))
(#eq? @_role ":math:")
(#set! injection.language "latex"))
((comment) @injection.content
(#set! injection.language "comment"))
(#set! injection.language "comment"))

View file

@ -1,11 +1,9 @@
;; Scopes
; Scopes
(document) @local.scope
(directive) @local.scope
;; Definitions
; Definitions
(title) @local.definition
(substitution_definition
@ -26,15 +24,16 @@
; The role directive can define a new role
((directive
name: (type) @_type
body: (body (arguments) @local.definition))
(#eq? @_type "role"))
;; References
body:
(body
(arguments) @local.definition))
(#eq? @_type "role"))
; References
[
(substitution_reference)
(footnote_reference)
(citation_reference)
(reference)
(role)
(substitution_reference)
(footnote_reference)
(citation_reference)
(reference)
(role)
] @local.reference