From 56ffbdfdab107274e347d6cdb1f0f6dce2bac195 Mon Sep 17 00:00:00 2001 From: MrSubidubi Date: Fri, 20 Mar 2026 13:26:30 +0100 Subject: [PATCH] Format Tree-sitter query files --- languages/emmyluadoc/highlights.scm | 54 +++++++++++++++-- languages/lua/brackets.scm | 11 +++- languages/lua/embedding.scm | 17 +++--- languages/lua/highlights.scm | 92 ++++++++++++++--------------- languages/lua/indents.scm | 43 ++++++++++---- languages/lua/injections.scm | 19 +++--- languages/lua/outline.scm | 4 +- 7 files changed, 155 insertions(+), 85 deletions(-) diff --git a/languages/emmyluadoc/highlights.scm b/languages/emmyluadoc/highlights.scm index ef3a437..4bef13d 100644 --- a/languages/emmyluadoc/highlights.scm +++ b/languages/emmyluadoc/highlights.scm @@ -1,29 +1,48 @@ ; Highlights query for EmmyLuaDoc - ; Comment Prefix (comment_prefix) @comment ; Annotation Keywords "@class" @keyword + "@interface" @keyword + "@field" @keyword + "@type" @keyword + "@param" @keyword + "@return" @keyword + "@generic" @keyword + "@overload" @keyword + "@see" @keyword + "@alias" @keyword + "@enum" @keyword + "@module" @keyword + "@cast" @keyword + "@version" @keyword + "@diagnostic" @keyword + "@operator" @keyword + "@namespace" @keyword + "@using" @keyword + "@language" @keyword + "@attribute" @keyword + "@as" @keyword ; Other/unknown annotations @@ -31,14 +50,23 @@ ; Special annotation nodes (deprecated_annotation) @keyword + (private_annotation) @keyword + (protected_annotation) @keyword + (public_annotation) @keyword + (package_annotation) @keyword + (async_annotation) @keyword + (nodiscard_annotation) @keyword + (meta_annotation) @keyword + (readonly_annotation) @keyword + (export_annotation) @keyword ; Visibility modifiers @@ -71,7 +99,8 @@ ; Built-in types ((identifier) @type.builtin - (#match? @type.builtin "^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$")) + (#match? @type.builtin + "^(string|number|integer|boolean|table|function|thread|userdata|nil|any|unknown|self)$")) ; Class definitions (class_annotation @@ -127,19 +156,34 @@ ; Operators [ "call" - "add" "sub" "mul" "div" "mod" "pow" + "add" + "sub" + "mul" + "div" + "mod" + "pow" "concat" "len" - "eq" "lt" "le" + "eq" + "lt" + "le" "unm" - "bnot" "band" "bor" "bxor" "shl" "shr" + "bnot" + "band" + "bor" + "bxor" + "shl" + "shr" "index" ] @operator ; Literals (string) @string + (number) @number + (boolean) @boolean + "nil" @constant.builtin ; Template types diff --git a/languages/lua/brackets.scm b/languages/lua/brackets.scm index 62e137e..e83d67f 100644 --- a/languages/lua/brackets.scm +++ b/languages/lua/brackets.scm @@ -1,3 +1,8 @@ -("[" @open "]" @close) -("{" @open "}" @close) -("(" @open ")" @close) +("[" @open + "]" @close) + +("{" @open + "}" @close) + +("(" @open + ")" @close) diff --git a/languages/lua/embedding.scm b/languages/lua/embedding.scm index 0d10650..f193f42 100644 --- a/languages/lua/embedding.scm +++ b/languages/lua/embedding.scm @@ -1,10 +1,7 @@ -( - (comment)* @context - . - (function_declaration - "function" @name - name: (_) @name - (comment)* @collapse - body: (block) @collapse - ) @item -) +((comment)* @context + . + (function_declaration + "function" @name + name: (_) @name + (comment)* @collapse + body: (block) @collapse) @item) diff --git a/languages/lua/highlights.scm b/languages/lua/highlights.scm index f56b463..2d26fa4 100644 --- a/languages/lua/highlights.scm +++ b/languages/lua/highlights.scm @@ -1,5 +1,4 @@ -;; Keywords - +; Keywords [ "do" "else" @@ -19,12 +18,11 @@ (break_statement) ] @keyword -;; Operators - +; Operators [ - "and" - "not" - "or" + "and" + "not" + "or" ] @keyword.operator [ @@ -51,8 +49,7 @@ ".." ] @operator -;; Punctuations - +; Punctuations [ ";" ":" @@ -60,33 +57,33 @@ "." ] @punctuation.delimiter -;; Brackets - +; Brackets [ - "(" - ")" - "[" - "]" - "{" - "}" + "(" + ")" + "[" + "]" + "{" + "}" ] @punctuation.bracket -;; Variables - +; Variables (identifier) @variable ((identifier) @variable.special - (#eq? @variable.special "self")) + (#eq? @variable.special "self")) (variable_list - attribute: (attribute - (["<" ">"] @punctuation.bracket + attribute: (attribute + ([ + "<" + ">" + ] @punctuation.bracket (identifier) @attribute))) -;; Constants - +; Constants ((identifier) @constant - (#match? @constant "^[A-Z][A-Z_0-9]*$")) + (#match? @constant "^[A-Z][A-Z_0-9]*$")) (vararg_expression) @constant @@ -97,47 +94,49 @@ (true) ] @boolean -;; Tables +; Tables +(field + name: (identifier) @property) -(field name: (identifier) @property) - -(dot_index_expression field: (identifier) @property) +(dot_index_expression + field: (identifier) @property) (table_constructor -[ - "{" - "}" -] @constructor) + [ + "{" + "}" + ] @constructor) -;; Functions - -(parameters (identifier) @parameter) +; Functions +(parameters + (identifier) @parameter) (function_call name: [ (identifier) @function - (dot_index_expression field: (identifier) @function) + (dot_index_expression + field: (identifier) @function) ]) (function_declaration name: [ (identifier) @function.definition - (dot_index_expression field: (identifier) @function.definition) + (dot_index_expression + field: (identifier) @function.definition) ]) -(method_index_expression method: (identifier) @function.method) +(method_index_expression + method: (identifier) @function.method) (function_call (identifier) @function.builtin (#any-of? @function.builtin - ;; built-in functions in Lua 5.1 - "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" - "load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print" - "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable" - "tonumber" "tostring" "type" "unpack" "xpcall")) - -;; Others + ; built-in functions in Lua 5.1 + "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile" + "loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawset" "require" + "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall")) +; Others (comment) @comment (hash_bang_line) @preproc @@ -145,4 +144,5 @@ (number) @number (string) @string + (escape_sequence) @string.escape diff --git a/languages/lua/indents.scm b/languages/lua/indents.scm index 8ebe690..9b7b4e2 100644 --- a/languages/lua/indents.scm +++ b/languages/lua/indents.scm @@ -1,11 +1,32 @@ -(if_statement "end" @end) @indent -(do_statement "end" @end) @indent -(while_statement "end" @end) @indent -(for_statement "end" @end) @indent -(repeat_statement "until" @end) @indent -(function_declaration "end" @end) @indent -(function_definition "end" @end) @indent - -(_ "[" "]" @end) @indent -(_ "{" "}" @end) @indent -(_ "(" ")" @end) @indent +(if_statement + "end" @end) @indent + +(do_statement + "end" @end) @indent + +(while_statement + "end" @end) @indent + +(for_statement + "end" @end) @indent + +(repeat_statement + "until" @end) @indent + +(function_declaration + "end" @end) @indent + +(function_definition + "end" @end) @indent + +(_ + "[" + "]" @end) @indent + +(_ + "{" + "}" @end) @indent + +(_ + "(" + ")" @end) @indent diff --git a/languages/lua/injections.scm b/languages/lua/injections.scm index e04c4fa..61205c3 100644 --- a/languages/lua/injections.scm +++ b/languages/lua/injections.scm @@ -1,20 +1,23 @@ -;; Injections for Lua code - -;; LuaCats Doc comments injection +; Injections for Lua code +; LuaCats Doc comments injection (((comment) @_emmyluadoc_comment (#match? @_emmyluadoc_comment "^---")) @injection.content (#set! injection.language "emmyluadoc")) -;; Add support for TODO, FIXME, HACK, etc with the "comment" extension +; Add support for TODO, FIXME, HACK, etc with the "comment" extension ((comment) @injection.content (#set! injection.language "comment")) -;; LuaJIT FFI C code injection +; LuaJIT FFI C code injection ((function_call name: [ (identifier) @_cdef_identifier - (_ _ (identifier) @_cdef_identifier) + (_ + _ + (identifier) @_cdef_identifier) ] - arguments: (arguments (string content: _ @injection.content - (#set! injection.language "c")))) + arguments: (arguments + (string + content: _ @injection.content + (#set! injection.language "c")))) (#eq? @_cdef_identifier "cdef")) diff --git a/languages/lua/outline.scm b/languages/lua/outline.scm index aa59d17..b509935 100644 --- a/languages/lua/outline.scm +++ b/languages/lua/outline.scm @@ -1,3 +1,3 @@ (function_declaration - "function" @context - name: (_) @name) @item + "function" @context + name: (_) @name) @item