aboutsummaryrefslogtreecommitdiffstats
path: root/queries
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 /queries
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
Diffstat (limited to 'queries')
-rw-r--r--queries/lua/injections.scm4
-rw-r--r--queries/luadoc/highlights.scm133
2 files changed, 137 insertions, 0 deletions
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)