mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-05 04:50:03 -04:00
feat!: drop modules, general refactor and cleanup
This commit is contained in:
parent
c13e28f894
commit
2c8f2f2fad
829 changed files with 4905 additions and 8010 deletions
171
runtime/queries/rst/highlights.scm
Normal file
171
runtime/queries/rst/highlights.scm
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
;; Marks
|
||||
|
||||
[
|
||||
".."
|
||||
"|"
|
||||
"--"
|
||||
"__"
|
||||
":"
|
||||
"::"
|
||||
"bullet"
|
||||
"adornment"
|
||||
(transition)
|
||||
] @punctuation.special
|
||||
|
||||
;; Resets for injection
|
||||
|
||||
(doctest_block) @none
|
||||
|
||||
;; Directives
|
||||
|
||||
(directive
|
||||
name: (type) @function)
|
||||
|
||||
(directive
|
||||
body: (body (arguments) @parameter))
|
||||
|
||||
((directive
|
||||
name: (type) @include)
|
||||
(#eq? @include "include"))
|
||||
|
||||
((directive
|
||||
name: (type) @function.builtin)
|
||||
(#any-of?
|
||||
@function.builtin
|
||||
; https://docutils.sourceforge.io/docs/ref/rst/directives.html
|
||||
"attention" "caution" "danger" "error" "hint" "important" "note" "tip" "warning" "admonition"
|
||||
"image" "figure"
|
||||
"topic" "sidebar" "line-block" "parsed-literal" "code" "math" "rubric" "epigraph" "highlights" "pull-quote" "compound" "container"
|
||||
"table" "csv-table" "list-table"
|
||||
"contents" "sectnum" "section-numbering" "header" "footer"
|
||||
"target-notes"
|
||||
"meta"
|
||||
"replace" "unicode" "date"
|
||||
"raw" "class" "role" "default-role" "title" "restructuredtext-test-directive"))
|
||||
|
||||
;; Blocks
|
||||
|
||||
[
|
||||
(literal_block)
|
||||
(line_block)
|
||||
] @text.literal
|
||||
|
||||
(block_quote
|
||||
(attribution)? @text.emphasis) @text.literal
|
||||
|
||||
(substitution_definition
|
||||
name: (substitution) @constant)
|
||||
|
||||
(footnote
|
||||
name: (label) @constant)
|
||||
|
||||
(citation
|
||||
name: (label) @constant)
|
||||
|
||||
(target
|
||||
name: (name)? @constant
|
||||
link: (_)? @text.literal)
|
||||
|
||||
;; Lists
|
||||
|
||||
; Definition lists
|
||||
(list_item
|
||||
(term) @text.strong
|
||||
(classifier)? @text.emphasis)
|
||||
|
||||
; Field lists
|
||||
(field (field_name) @constant)
|
||||
|
||||
;; Inline markup
|
||||
|
||||
(emphasis) @text.emphasis
|
||||
|
||||
(strong) @text.strong
|
||||
|
||||
(standalone_hyperlink) @text.uri @nospell
|
||||
|
||||
(role) @function
|
||||
|
||||
((role) @function.builtin
|
||||
(#any-of?
|
||||
@function.builtin
|
||||
; https://docutils.sourceforge.io/docs/ref/rst/roles.html
|
||||
":emphasis:"
|
||||
":literal:"
|
||||
":code:"
|
||||
":math:"
|
||||
":pep-reference:"
|
||||
":PEP:"
|
||||
":rfc-reference:"
|
||||
":RFC:"
|
||||
":strong:"
|
||||
":subscript:"
|
||||
":sub:"
|
||||
":superscript:"
|
||||
":sup:"
|
||||
":title-reference:"
|
||||
":title:"
|
||||
":t:"
|
||||
":raw:"))
|
||||
|
||||
[
|
||||
"interpreted_text"
|
||||
(literal)
|
||||
] @text.literal
|
||||
|
||||
; Prefix role
|
||||
((interpreted_text
|
||||
(role) @_role
|
||||
"interpreted_text" @text.emphasis)
|
||||
(#eq? @_role ":emphasis:"))
|
||||
|
||||
((interpreted_text
|
||||
(role) @_role
|
||||
"interpreted_text" @text.strong)
|
||||
(#eq? @_role ":strong:"))
|
||||
|
||||
((interpreted_text
|
||||
(role) @_role
|
||||
"interpreted_text" @none)
|
||||
(#eq? @_role ":math:"))
|
||||
|
||||
; Suffix role
|
||||
((interpreted_text
|
||||
"interpreted_text" @text.emphasis
|
||||
(role) @_role)
|
||||
(#eq? @_role ":emphasis:"))
|
||||
|
||||
((interpreted_text
|
||||
"interpreted_text" @text.strong
|
||||
(role) @_role)
|
||||
(#eq? @_role ":strong:"))
|
||||
|
||||
((interpreted_text
|
||||
"interpreted_text" @none
|
||||
(role) @_role)
|
||||
(#eq? @_role ":math:"))
|
||||
|
||||
[
|
||||
(inline_target)
|
||||
(substitution_reference)
|
||||
(footnote_reference)
|
||||
(citation_reference)
|
||||
(reference)
|
||||
] @text.reference @nospell
|
||||
|
||||
;; Others
|
||||
|
||||
(title) @text.title
|
||||
|
||||
(comment) @comment @spell
|
||||
(comment "..") @comment
|
||||
|
||||
(directive
|
||||
name: (type) @_directive
|
||||
body: (body
|
||||
(content) @spell
|
||||
(#not-any-of? @_directive "code" "code-block" "sourcecode")))
|
||||
|
||||
(paragraph) @spell
|
||||
|
||||
(ERROR) @error
|
||||
80
runtime/queries/rst/injections.scm
Normal file
80
runtime/queries/rst/injections.scm
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
((doctest_block) @injection.content
|
||||
(#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"))
|
||||
|
||||
;; 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"))
|
||||
|
||||
;; 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"))
|
||||
|
||||
;; Special directives
|
||||
((directive
|
||||
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"))
|
||||
|
||||
((directive
|
||||
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
|
||||
|
||||
((interpreted_text
|
||||
(role) @_role
|
||||
"interpreted_text" @injection.content)
|
||||
(#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"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
40
runtime/queries/rst/locals.scm
Normal file
40
runtime/queries/rst/locals.scm
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
;; Scopes
|
||||
|
||||
(document) @scope
|
||||
|
||||
(directive) @scope
|
||||
|
||||
;; Definitions
|
||||
|
||||
(title) @definition
|
||||
|
||||
(substitution_definition
|
||||
name: (substitution) @definition)
|
||||
|
||||
(footnote
|
||||
name: (label) @definition)
|
||||
|
||||
(citation
|
||||
name: (label) @definition)
|
||||
|
||||
(target
|
||||
name: (name) @definition)
|
||||
|
||||
; Inline targets
|
||||
(inline_target) @definition
|
||||
|
||||
; The role directive can define a new role
|
||||
((directive
|
||||
name: (type) @_type
|
||||
body: (body (arguments) @definition))
|
||||
(#eq? @_type "role"))
|
||||
|
||||
;; References
|
||||
|
||||
[
|
||||
(substitution_reference)
|
||||
(footnote_reference)
|
||||
(citation_reference)
|
||||
(reference)
|
||||
(role)
|
||||
] @reference
|
||||
Loading…
Add table
Add a link
Reference in a new issue