mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
Parsers: add reStructuredText
This commit is contained in:
parent
121c44a23b
commit
6f01384cb2
9 changed files with 186 additions and 4 deletions
|
|
@ -122,6 +122,21 @@ are optional and will not have any effect for now.
|
||||||
builtin
|
builtin
|
||||||
@structure
|
@structure
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Text
|
||||||
|
|
||||||
|
Mainly for markup languages.
|
||||||
|
|
||||||
|
```
|
||||||
|
@text
|
||||||
|
@text.strong
|
||||||
|
@text.emphasis
|
||||||
|
@text.underline
|
||||||
|
@text.title
|
||||||
|
@text.literal
|
||||||
|
@text.uri
|
||||||
|
```
|
||||||
|
|
||||||
### Locals
|
### Locals
|
||||||
```
|
```
|
||||||
@definition for various definitions
|
@definition for various definitions
|
||||||
|
|
|
||||||
|
|
@ -284,6 +284,7 @@ List of currently supported languages:
|
||||||
- [x] regex (maintained by @theHamsta)
|
- [x] regex (maintained by @theHamsta)
|
||||||
- [ ] jsdoc
|
- [ ] jsdoc
|
||||||
- [x] dart (maintained by @Akin909)
|
- [x] dart (maintained by @Akin909)
|
||||||
|
- [x] rst (maintained by @stsewd)
|
||||||
|
|
||||||
## User Query Extensions
|
## User Query Extensions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
*nvim-treesitter*
|
*nvim-treesitter*
|
||||||
|
|
||||||
Minimum version of neovim: nightly
|
Minimum version of neovim: nightly
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ By default, everything is disabled. To enable support for features, in your `ini
|
||||||
disable = { 'c', 'rust' }, -- list of language that will be disabled
|
disable = { 'c', 'rust' }, -- list of language that will be disabled
|
||||||
custom_captures = { -- mapping of user defined captures to highlight groups
|
custom_captures = { -- mapping of user defined captures to highlight groups
|
||||||
-- ["foo.bar"] = "Identifier" -- highlight own capture @foo.bar with highlight group "Identifier", see :h nvim-treesitter-query-extensions
|
-- ["foo.bar"] = "Identifier" -- highlight own capture @foo.bar with highlight group "Identifier", see :h nvim-treesitter-query-extensions
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
|
|
@ -165,7 +165,7 @@ get_node_text(node, bufnr) *ts_utils.get_node_text*
|
||||||
return the text content of a node
|
return the text content of a node
|
||||||
|
|
||||||
is_parent(dest, source) *ts_utils.is_parent*
|
is_parent(dest, source) *ts_utils.is_parent*
|
||||||
determines wether `dest` is a parent of `source`
|
determines wether `dest` is a parent of `source`
|
||||||
return a boolean
|
return a boolean
|
||||||
|
|
||||||
get_named_children(node) *ts_utils.get_named_children*
|
get_named_children(node) *ts_utils.get_named_children*
|
||||||
|
|
@ -176,7 +176,7 @@ get_next_node(node, allow_switch_parent, allow_next_parent) *ts_utils.get_next_n
|
||||||
if no node is found, returns `nil`.
|
if no node is found, returns `nil`.
|
||||||
if `allow_switch_parent` is true, it will allow switching parent
|
if `allow_switch_parent` is true, it will allow switching parent
|
||||||
when the node is the last node
|
when the node is the last node
|
||||||
if `allow_next_parent` is true, it will allow next parent if
|
if `allow_next_parent` is true, it will allow next parent if
|
||||||
the node is the last node and the next parent doesn't have children.
|
the node is the last node and the next parent doesn't have children.
|
||||||
|
|
||||||
get_previous_node(node, allow_switch_parents, allow_prev_parent) *ts_utils.get_previous_node*
|
get_previous_node(node, allow_switch_parents, allow_prev_parent) *ts_utils.get_previous_node*
|
||||||
|
|
@ -361,4 +361,32 @@ This is left as an exercise for the reader.
|
||||||
For includes: `#include` in C, `use` or `extern crate` in Rust, or `require`
|
For includes: `#include` in C, `use` or `extern crate` in Rust, or `require`
|
||||||
in Lua
|
in Lua
|
||||||
|
|
||||||
|
`TSText`
|
||||||
|
*hl-TSText*
|
||||||
|
For strings considered text in a markup language.
|
||||||
|
|
||||||
|
`TSStrong`
|
||||||
|
*hl-TSStrong*
|
||||||
|
For text to be represented with strong.
|
||||||
|
|
||||||
|
`TSEmphasis`
|
||||||
|
*hl-TSEmphasis*
|
||||||
|
For text to be represented with emphasis.
|
||||||
|
|
||||||
|
`TSUnderline`
|
||||||
|
*hl-TSUnderline*
|
||||||
|
For text to be represented with an underline.
|
||||||
|
|
||||||
|
`TSTitle`
|
||||||
|
|
||||||
|
Text that is part of a title.
|
||||||
|
|
||||||
|
`TSLiteral`
|
||||||
|
*hl-TSLiteral*
|
||||||
|
Literal text.
|
||||||
|
|
||||||
|
`TSURI`
|
||||||
|
*hl-TSURI*
|
||||||
|
Any URI like a link or email.
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,15 @@ hlmap["type.builtin"] = "TSTypeBuiltin"
|
||||||
hlmap["structure"] = "TSStructure"
|
hlmap["structure"] = "TSStructure"
|
||||||
hlmap["include"] = "TSInclude"
|
hlmap["include"] = "TSInclude"
|
||||||
|
|
||||||
|
-- Text
|
||||||
|
hlmap["text"] = "TSText"
|
||||||
|
hlmap["text.strong"] = "TSStrong"
|
||||||
|
hlmap["text.emphasis"] = "TSEmphasis"
|
||||||
|
hlmap["text.underline"] = "TSUnderline"
|
||||||
|
hlmap["text.title"] = "TSTitle"
|
||||||
|
hlmap["text.literal"] = "TSLiteral"
|
||||||
|
hlmap["text.uri"] = "TSURI"
|
||||||
|
|
||||||
function M.attach(bufnr, lang)
|
function M.attach(bufnr, lang)
|
||||||
local bufnr = bufnr or api.nvim_get_current_buf()
|
local bufnr = bufnr or api.nvim_get_current_buf()
|
||||||
local lang = lang or parsers.get_buf_lang(bufnr)
|
local lang = lang or parsers.get_buf_lang(bufnr)
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,13 @@ list.dart = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.rst = {
|
||||||
|
install_info = {
|
||||||
|
url = "https://github.com/stsewd/tree-sitter-rst",
|
||||||
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Parsers for injections
|
-- Parsers for injections
|
||||||
list.regex = {
|
list.regex = {
|
||||||
install_info = {
|
install_info = {
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,11 @@ highlight default link TSDefinitionUsage Visual
|
||||||
highlight default link TSDefinition Search
|
highlight default link TSDefinition Search
|
||||||
|
|
||||||
highlight default link TSCurrentScope CursorLine
|
highlight default link TSCurrentScope CursorLine
|
||||||
|
|
||||||
|
highlight default link TSText Normal
|
||||||
|
highlight default TSStrong term=bold cterm=bold gui=bold
|
||||||
|
highlight default TSEmphasis term=italic cterm=italic gui=italic
|
||||||
|
highlight default TSUnderline term=underline cterm=underline gui=underline
|
||||||
|
highlight default link TSTitle Title
|
||||||
|
highlight default link TSLiteral String
|
||||||
|
highlight default link TSURI Identifier
|
||||||
|
|
|
||||||
81
queries/rst/highlights.scm
Normal file
81
queries/rst/highlights.scm
Normal file
|
|
@ -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
|
||||||
31
queries/rst/locals.scm
Normal file
31
queries/rst/locals.scm
Normal file
|
|
@ -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
|
||||||
2
queries/rst/textobjects.scm
Normal file
2
queries/rst/textobjects.scm
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
(directive
|
||||||
|
body: (body) @function.inner) @function.outer
|
||||||
Loading…
Add table
Add a link
Reference in a new issue