feat: add Luadoc

This commit is contained in:
Amaan Qureshi 2023-03-19 08:09:12 -04:00
parent 581fc14cea
commit bc23db2515
5 changed files with 149 additions and 0 deletions

View file

@ -263,6 +263,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete)
- [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham)
- [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim)
- [x] [luadoc](https://github.com/amaanq/tree-sitter-luadoc) (maintained by @amaanq)
- [x] [lua patterns](https://github.com/amaanq/tree-sitter-luap) (maintained by @amaanq)
- [x] [m68k](https://github.com/grahambates/tree-sitter-m68k) (maintained by @grahambates)
- [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991)

View file

@ -269,6 +269,9 @@
"lua": {
"revision": "0fc89962b7ff5c7d676b8592c1cbce1ceaa806fd"
},
"luadoc": {
"revision": "40a67ee798eb3c989fffde0277ff6de740ebaf34"
},
"luap": {
"revision": "bfb38d254f380362e26b5c559a4086ba6e92ba77"
},

View file

@ -825,6 +825,14 @@ list.lua = {
maintainers = { "@muniftanjim" },
}
list.luadoc = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-luadoc",
files = { "src/parser.c" },
},
maintainers = { "@amaanq" },
}
list.luap = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-luap",

View file

@ -19,6 +19,10 @@
;; highlight string as query if starts with `;; query`
((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?query"))
((comment) @luadoc
(#lua-match? @luadoc "[-][-][-][%s]*@")
(#offset! @luadoc 0 3 0 0))
; string.match("123", "%d+")
(function_call
(dot_index_expression

View file

@ -0,0 +1,133 @@
; Keywords
[
"@class"
"@type"
"@param"
"@alias"
"@field"
"@generic"
"@vararg"
"@diagnostic"
"@deprecated"
"@cast"
"@overload"
"@enum"
"@language"
"@see"
"extends"
(diagnostic_identifier)
] @keyword
[
"@async"
] @keyword.coroutine
(language_injection "@language" (identifier) @parameter)
(function_type ["fun" "function"] @keyword.function)
[
"@return"
] @keyword.return
; Qualifiers
[
"public"
"protected"
"private"
"@public"
"@protected"
"@private"
] @type.qualifier
; Variables
(identifier) @variable
[
"..."
"self"
] @variable.builtin
; Macros
(alias_annotation (identifier) @function.macro)
; Parameters
(param_annotation (identifier) @parameter)
(parameter (identifier) @parameter)
; Fields
(field_annotation (identifier) @field)
(table_literal_type field: (identifier) @field)
(member_type ["#" "."] . (identifier) @field)
; Types
(table_type "table" @type.builtin)
(builtin_type) @type.builtin
(class_annotation (identifier) @type)
(enum_annotation (identifier) @type)
((array_type ["[" "]"] @type)
(#set! "priority" 105))
(type) @type
; Operators
[
"|"
] @operator
; Literals
(literal_type) @string
(number) @number
; Punctuation
[ "[" "]" ] @punctuation.bracket
[ "{" "}" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket
[
","
"."
"#"
":"
] @punctuation.delimiter
[
"@"
"?"
] @punctuation.special
; Comments
(comment) @comment @spell
(at_comment
(identifier) @type
(_) @comment @spell)
(class_at_comment
(identifier) @type
("extends"? (identifier)? @type)
(_) @comment @spell)