Add comment parser to highlight comment tags (#893)

Closes #236
This commit is contained in:
Santos Gallegos 2021-03-12 11:21:46 -05:00 committed by GitHub
parent 3b8c2ea492
commit e4083fc8e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 126 additions and 3 deletions

View file

@ -167,6 +167,10 @@ Mainly for markup languages.
@text.title
@text.literal
@text.uri
@text.note
@text.warning
@text.danger
```
#### Tags

View file

@ -136,6 +136,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @vigoux)
- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @svermeulen)
- [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @sogaiu)
- [x] [comment](https://github.com/stsewd/tree-sitter-comment) (maintained by @stsewd)
- [x] [cpp](https://github.com/tree-sitter/tree-sitter-cpp) (maintained by @theHamsta)
- [x] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD)
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @Akin909)

View file

@ -514,7 +514,7 @@ TODO: docs
`TSNumber`
*hl-TSNumber*
For all numbers
For all numbers
`TSOperator`
*hl-TSOperator*
@ -576,6 +576,11 @@ Tag delimiter like `<` `>` `/`
*hl-TSText*
For strings considered text in a markup language.
`TSStrong`
*hl-TSSTrong*
For text to be represented in bold.
`TSEmphasis`
*hl-TSEmphasis*
For text to be represented with emphasis.
@ -600,6 +605,18 @@ Literal text.
*hl-TSURI*
Any URI like a link or email.
`TSNote`
*hl-TSNote*
Text representation of an informational note.
`TSWarning`
*TSWarning*
Text representation of a warning note.
`TSDanger`
*TSDanger*
Text representation of a danger note.
`TSType`
*hl-TSType*
For types.

View file

@ -11,6 +11,9 @@
"clojure": {
"revision": "f09652f095be878df8a87a57dcbfa07094316253"
},
"comment": {
"revision": "6b0dbd56284023617c3ea755624e55d0254f813a"
},
"cpp": {
"revision": "3bfe046f3967fef92ebb33f8cd58c3ff373d5e56"
},

View file

@ -85,6 +85,10 @@ hlmap["text.title"] = "TSTitle"
hlmap["text.literal"] = "TSLiteral"
hlmap["text.uri"] = "TSURI"
hlmap["text.note"] = "TSNote"
hlmap["text.warning"] = "TSWarning"
hlmap["text.danger"] = "TSDanger"
hlmap["type"] = "TSType"
hlmap["type.builtin"] = "TSTypeBuiltin"

View file

@ -403,6 +403,14 @@ list.regex = {
maintainers = {"@theHamsta"},
}
list.comment = {
install_info = {
url = "https://github.com/stsewd/tree-sitter-comment",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = {"@stsewd"},
}
list.jsdoc = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-jsdoc",

View file

@ -80,5 +80,9 @@ highlight default link TSTitle Title
highlight default link TSLiteral String
highlight default link TSURI Underlined
highlight default link TSNote SpecialComment
highlight default link TSWarning Todo
highlight default link TSDanger WarningMsg
highlight default link TSTag Label
highlight default link TSTagDelimiter Delimiter

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -1 +1,3 @@
(preproc_arg) @c
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1,19 @@
[
"("
")"
] @punctuation.bracket
":" @punctuation.delimiter
(tag (name) @text.note (user)? @constant)
((tag ((name) @text.warning))
(#match? @text.warning "^(TODO|HACK|WARNING)$"))
((tag ((name) @text.danger))
(#match? @text.danger "^(FIXME|XXX|BUG)$"))
; Issue number (#123)
("text" @number (#match? @number "^#[0-9]+$"))
; User mention (@user)
("text" @constant (#match? @constant "^[@][a-zA-Z0-9_-]+$"))

View file

@ -1 +1,3 @@
(preproc_arg) @cpp
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -8,3 +8,5 @@
((script_element
(raw_text) @javascript))
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -1,2 +1,4 @@
((triple_string) @markdown
(#offset! @markdown 0 3 0 -3))
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -8,3 +8,5 @@
(#eq? @_cdef_identifier "cdef")
)
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
; inherits: ocaml

View file

@ -1 +1,3 @@
((ocaml) @ocaml)
(ocaml) @ocaml
(comment) @comment

View file

@ -1 +1,3 @@
((text) @html)
(text) @html
(comment) @comment

View file

@ -22,3 +22,5 @@
; Attribute docstring
(((expression_statement (assignment)) . (expression_statement (string) @rst))
(#offset! @rst 0 3 0 -3))
(comment) @comment

View file

@ -0,0 +1,5 @@
[
(line_comment)
(block_comment)
(qldoc)
] @comment

View file

@ -2,3 +2,5 @@
name: (identifier) @_name
parameters: (parameters (string) @regex))
(#match? @_name "^#?(not-)?(match|vim-match|lua-match)$"))
(comment) @comment

View file

@ -58,3 +58,5 @@
"interpreted_text" @latex
(role) @_role)
(#eq? @_role ":math:"))
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -5,3 +5,8 @@
(macro_rule
left: (token_tree_pattern) @rust
right: (token_tree) @rust))
[
(line_comment)
(block_comment)
] @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1,4 @@
[
(line_comment)
(block_comment)
] @comment

View file

@ -19,3 +19,5 @@
(raw_text) @typescript)
(#match? @_lang "(ts|typescript)")
)
(comment) @comment

View file

@ -8,3 +8,5 @@
(#eq? @_cdef_identifier "cdef")
)
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment

View file

@ -17,3 +17,5 @@
((interpolation
(raw_text) @javascript))
(comment) @comment

View file

@ -0,0 +1 @@
(comment) @comment