mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 02:40:09 -04:00
RST: update parser and queries
- The directive type does not longer includes `::`. - The content of the directives is not longer interpreted as rst, but it uses language injection for it. - Fix a query to allow to capture targets without link. - Reset the content of the math role so it can be highlighted by the injection instead. Problems I found: - Capturing the same node with @language and @content will raise an error. ``` Error detected while processing FileType Autocommands for "*": E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:331: table index is nil ``` Harcoding the language works, Using the offset predicate doesn't work either `(#offset! 0 0 1 0)` nor `(#offset! 0 0 0 5)` - Generating the grammar using `tree-sitter-cli@0.17.x` breaks nvim-treesitter, `@0.16.9` works.
This commit is contained in:
parent
748ac8f781
commit
5ffcd75ea6
4 changed files with 69 additions and 13 deletions
47
queries/rst/injections.scm
Normal file
47
queries/rst/injections.scm
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
(doctest_block) @python
|
||||
|
||||
;; Directives with nested content
|
||||
|
||||
((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)$"))
|
||||
|
||||
;; Special directives
|
||||
|
||||
;; TODO: using @language and @content on the same capture raises an error.
|
||||
;; ((directive
|
||||
;; name: (type) @_type
|
||||
;; body: (body) @language @content)
|
||||
;; (#eq? @_type "code"))
|
||||
|
||||
;; ((directive
|
||||
;; name: (type) @_type
|
||||
;; body: (body) @language @content)
|
||||
;; (#eq? @_type "raw"))
|
||||
|
||||
((directive
|
||||
name: (type) @_type
|
||||
body: (body) @latex)
|
||||
(#eq? @_type "math"))
|
||||
|
||||
((directive
|
||||
name: (type) @_type
|
||||
body: (body) @csv)
|
||||
(#eq? @_type "csv-table"))
|
||||
|
||||
;; Special roles - prefix
|
||||
|
||||
((interpreted_text
|
||||
(role) @_role
|
||||
"interpreted_text" @latex)
|
||||
(#eq? @_role ":math:"))
|
||||
|
||||
;; Special roles - suffix
|
||||
|
||||
((interpreted_text
|
||||
"interpreted_text" @latex
|
||||
(role) @_role)
|
||||
(#eq? @_role ":math:"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue