From bc23db25153efd480392ee479784d5bbac4b1913 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sun, 19 Mar 2023 08:09:12 -0400 Subject: feat: add Luadoc --- queries/lua/injections.scm | 4 ++ queries/luadoc/highlights.scm | 133 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 queries/luadoc/highlights.scm (limited to 'queries') 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) -- cgit v1.2.3-70-g09d2