mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -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
|
||||
@structure
|
||||
```
|
||||
|
||||
#### Text
|
||||
|
||||
Mainly for markup languages.
|
||||
|
||||
```
|
||||
@text
|
||||
@text.strong
|
||||
@text.emphasis
|
||||
@text.underline
|
||||
@text.title
|
||||
@text.literal
|
||||
@text.uri
|
||||
```
|
||||
|
||||
### Locals
|
||||
```
|
||||
@definition for various definitions
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ List of currently supported languages:
|
|||
- [x] regex (maintained by @theHamsta)
|
||||
- [ ] jsdoc
|
||||
- [x] dart (maintained by @Akin909)
|
||||
- [x] rst (maintained by @stsewd)
|
||||
|
||||
## User Query Extensions
|
||||
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -53,6 +53,15 @@ hlmap["type.builtin"] = "TSTypeBuiltin"
|
|||
hlmap["structure"] = "TSStructure"
|
||||
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)
|
||||
local bufnr = bufnr or api.nvim_get_current_buf()
|
||||
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
|
||||
list.regex = {
|
||||
install_info = {
|
||||
|
|
|
|||
|
|
@ -62,3 +62,11 @@ highlight default link TSDefinitionUsage Visual
|
|||
highlight default link TSDefinition Search
|
||||
|
||||
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