aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-03-19 08:09:12 -0400
committerAmaan Qureshi <amaanq12@gmail.com>2023-03-20 04:20:49 -0400
commitbc23db25153efd480392ee479784d5bbac4b1913 (patch)
treec47e66dd666781c6750d0b2f3c4be38c178954d5
parentqueries(lua): add more keywords related to variable/function builtins, debug,... (diff)
downloadnvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.tar
nvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.tar.gz
nvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.tar.bz2
nvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.tar.lz
nvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.tar.xz
nvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.tar.zst
nvim-treesitter-bc23db25153efd480392ee479784d5bbac4b1913.zip
feat: add Luadoc
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/lua/injections.scm4
-rw-r--r--queries/luadoc/highlights.scm133
5 files changed, 149 insertions, 0 deletions
diff --git a/README.md b/README.md
index e345eba61..a1c40bd66 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/lockfile.json b/lockfile.json
index 40a329b5e..3db414d7f 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -269,6 +269,9 @@
"lua": {
"revision": "0fc89962b7ff5c7d676b8592c1cbce1ceaa806fd"
},
+ "luadoc": {
+ "revision": "40a67ee798eb3c989fffde0277ff6de740ebaf34"
+ },
"luap": {
"revision": "bfb38d254f380362e26b5c559a4086ba6e92ba77"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 75fe513d4..2cb31e7bd 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -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",
diff --git a/queries/lua/injections.scm b/queries/lua/injections.scm
index 14714573a..51957461e 100644
--- a/queries/lua/injections.scm
+++ b/queries/lua/injections.scm
@@ -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
diff --git a/queries/luadoc/highlights.scm b/queries/luadoc/highlights.scm
new file mode 100644
index 000000000..c0132c966
--- /dev/null
+++ b/queries/luadoc/highlights.scm
@@ -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)