diff options
| author | Pham Huy Hoang <hoangtun0810@gmail.com> | 2024-01-06 15:05:50 +0900 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-01-19 16:58:37 +0100 |
| commit | 57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9 (patch) | |
| tree | 70bf645539882b88e6fa129cefd30986b89bbac3 /queries/lua | |
| parent | ci: add query lint job (diff) | |
| download | nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.gz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.bz2 nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.lz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.xz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.zst nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.zip | |
chore: query formatting
Diffstat (limited to 'queries/lua')
| -rw-r--r-- | queries/lua/folds.scm | 20 | ||||
| -rw-r--r-- | queries/lua/highlights.scm | 231 | ||||
| -rw-r--r-- | queries/lua/indents.scm | 1 | ||||
| -rw-r--r-- | queries/lua/injections.scm | 143 | ||||
| -rw-r--r-- | queries/lua/locals.scm | 29 |
5 files changed, 233 insertions, 191 deletions
diff --git a/queries/lua/folds.scm b/queries/lua/folds.scm index 37c4947ed..9dfac3abc 100644 --- a/queries/lua/folds.scm +++ b/queries/lua/folds.scm @@ -1,12 +1,12 @@ [ - (do_statement) - (while_statement) - (repeat_statement) - (if_statement) - (for_statement) - (function_declaration) - (function_definition) - (parameters) - (arguments) - (table_constructor) + (do_statement) + (while_statement) + (repeat_statement) + (if_statement) + (for_statement) + (function_declaration) + (function_definition) + (parameters) + (arguments) + (table_constructor) ] @fold diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index ea87c0da0..0b0bf35a8 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -1,81 +1,79 @@ -;; Keywords - +; Keywords "return" @keyword.return [ - "goto" - "in" - "local" + "goto" + "in" + "local" ] @keyword (break_statement) @keyword (do_statement -[ - "do" - "end" -] @keyword) + [ + "do" + "end" + ] @keyword) (while_statement -[ - "while" - "do" - "end" -] @keyword.repeat) + [ + "while" + "do" + "end" + ] @keyword.repeat) (repeat_statement -[ - "repeat" - "until" -] @keyword.repeat) + [ + "repeat" + "until" + ] @keyword.repeat) (if_statement -[ - "if" - "elseif" - "else" - "then" - "end" -] @keyword.conditional) + [ + "if" + "elseif" + "else" + "then" + "end" + ] @keyword.conditional) (elseif_statement -[ - "elseif" - "then" - "end" -] @keyword.conditional) + [ + "elseif" + "then" + "end" + ] @keyword.conditional) (else_statement -[ - "else" - "end" -] @keyword.conditional) + [ + "else" + "end" + ] @keyword.conditional) (for_statement -[ - "for" - "do" - "end" -] @keyword.repeat) + [ + "for" + "do" + "end" + ] @keyword.repeat) (function_declaration -[ - "function" - "end" -] @keyword.function) + [ + "function" + "end" + ] @keyword.function) (function_definition -[ - "function" - "end" -] @keyword.function) - -;; Operators + [ + "function" + "end" + ] @keyword.function) +; Operators [ - "and" - "not" - "or" + "and" + "not" + "or" ] @keyword.operator [ @@ -102,8 +100,7 @@ ".." ] @operator -;; Punctuations - +; Punctuations [ ";" ":" @@ -112,19 +109,17 @@ "." ] @punctuation.delimiter -;; Brackets - +; Brackets [ - "(" - ")" - "[" - "]" - "{" - "}" + "(" + ")" + "[" + "]" + "{" + "}" ] @punctuation.bracket -;; Variables - +; Variables (identifier) @variable ((identifier) @constant.builtin @@ -145,16 +140,16 @@ (identifier) @attribute ">" @punctuation.bracket)) -;; Labels - -(label_statement (identifier) @label) - -(goto_statement (identifier) @label) +; Labels +(label_statement + (identifier) @label) -;; Constants +(goto_statement + (identifier) @label) +; Constants ((identifier) @constant - (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) (vararg_expression) @constant @@ -165,43 +160,49 @@ (true) ] @boolean -;; Tables +; Tables +(field + name: (identifier) @variable.member) -(field name: (identifier) @variable.member) - -(dot_index_expression field: (identifier) @variable.member) +(dot_index_expression + field: (identifier) @variable.member) (table_constructor -[ - "{" - "}" -] @constructor) - -;; Functions + [ + "{" + "}" + ] @constructor) -(parameters (identifier) @variable.parameter) +; Functions +(parameters + (identifier) @variable.parameter) (vararg_expression) @variable.parameter.builtin (function_declaration - name: [ - (identifier) @function - (dot_index_expression - field: (identifier) @function) - ]) - -(function_declaration - name: (method_index_expression - method: (identifier) @function.method)) - -(assignment_statement - (variable_list . - name: [ + name: + [ (identifier) @function (dot_index_expression field: (identifier) @function) ]) - (expression_list . + +(function_declaration + name: + (method_index_expression + method: (identifier) @function.method)) + +(assignment_statement + (variable_list + . + name: + [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) + (expression_list + . value: (function_definition))) (table_constructor @@ -210,13 +211,14 @@ value: (function_definition))) (function_call - name: [ - (identifier) @function.call - (dot_index_expression - field: (identifier) @function.call) - (method_index_expression - method: (identifier) @function.method.call) - ]) + name: + [ + (identifier) @function.call + (dot_index_expression + field: (identifier) @function.call) + (method_index_expression + method: (identifier) @function.method.call) + ]) (function_call (identifier) @function.builtin @@ -231,8 +233,7 @@ "__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" "__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm")) -;; Others - +; Others (comment) @comment @spell ((comment) @comment.documentation @@ -254,17 +255,21 @@ (dot_index_expression field: (identifier) @_method (#any-of? @_method "find" "match" "gmatch" "gsub")) - arguments: (arguments - . (_) - . - (string - content: (string_content) @string.regexp))) + arguments: + (arguments + . + (_) + . + (string + content: (string_content) @string.regexp))) ;("123"):match("%d+") (function_call (method_index_expression method: (identifier) @_method (#any-of? @_method "find" "match" "gmatch" "gsub")) - arguments: (arguments - . (string - content: (string_content) @string.regexp))) + arguments: + (arguments + . + (string + content: (string_content) @string.regexp))) diff --git a/queries/lua/indents.scm b/queries/lua/indents.scm index 1125e6485..2c3dc2448 100644 --- a/queries/lua/indents.scm +++ b/queries/lua/indents.scm @@ -40,4 +40,3 @@ (comment) @indent.auto (string) @indent.auto - diff --git a/queries/lua/injections.scm b/queries/lua/injections.scm index 2ce156574..6042ea260 100644 --- a/queries/lua/injections.scm +++ b/queries/lua/injections.scm @@ -1,29 +1,48 @@ ((function_call - name: [ - (identifier) @_cdef_identifier - (_ _ (identifier) @_cdef_identifier) - ] - arguments: - (arguments - (string content: _ @injection.content))) + name: + [ + (identifier) @_cdef_identifier + (_ + _ + (identifier) @_cdef_identifier) + ] + arguments: + (arguments + (string + content: _ @injection.content))) (#set! injection.language "c") (#eq? @_cdef_identifier "cdef")) ((function_call name: (_) @_vimcmd_identifier - arguments: (arguments (string content: _ @injection.content))) + arguments: + (arguments + (string + content: _ @injection.content))) (#set! injection.language "vim") (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2")) ((function_call name: (_) @_vimcmd_identifier - arguments: (arguments (string content: _ @injection.content) .)) + arguments: + (arguments + (string + content: _ @injection.content) .)) (#set! injection.language "query") (#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse")) ((function_call name: (_) @_vimcmd_identifier - arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @injection.content))) + arguments: + (arguments + . + (_) + . + (string + content: _ @_method) + . + (string + content: _ @injection.content))) (#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify") (#eq? @_method "nvim_exec_lua") (#set! injection.language "lua")) @@ -33,46 +52,52 @@ name: (_) @_vimcmd_identifier arguments: (arguments - . (_) - . + . + (_) + . (table_constructor (field name: (identifier) @_command - value: - (string content: (_) @injection.content))) - .) ; limit so only 2-argument functions gets matched before pred handle + value: + (string + content: (_) @injection.content))) .) + ; limit so only 2-argument functions gets matched before pred handle (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd") (#eq? @_command "command") (#set! injection.language "vim")) - (function_call name: (_) @_user_cmd - arguments: + arguments: (arguments - . (_) - . + . + (_) + . (string content: (_) @injection.content) - . (_) .) + . + (_) .) (#eq? @_user_cmd "vim.api.nvim_create_user_command") (#set! injection.language "vim")) (function_call name: (_) @_user_cmd - arguments: + arguments: (arguments - . (_) - . (_) - . + . + (_) + . + (_) + . (string content: (_) @injection.content) - . (_) - .) ; Limiting predicate handling to only functions with 4 arguments + . + (_) .) + ; Limiting predicate handling to only functions with 4 arguments (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") (#set! injection.language "vim")) -;; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap +; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap ; (function_call ; name: (_) @_map ; arguments: @@ -92,17 +117,17 @@ ; . (_) ; . (_) ; . (_) -; . +; . ; (string ; content: (_) @injection.content) ; . (_) .) ; (#eq? @_map "vim.api.nvim_buf_set_keymap") ; (#set! injection.language "vim")) - -;; highlight string as query if starts with `;; query` -(string content: _ @injection.content - (#lua-match? @injection.content "^%s*;+%s?query") - (#set! injection.language "query")) +; highlight string as query if starts with `;; query` +(string + content: _ @injection.content + (#lua-match? @injection.content "^%s*;+%s?query") + (#set! injection.language "query")) (comment content: (_) @injection.content @@ -111,48 +136,56 @@ (#offset! @injection.content 0 1 0 0)) ; string.match("123", "%d+") - (function_call (dot_index_expression field: (identifier) @_method (#any-of? @_method "find" "match" "gmatch" "gsub")) - arguments: (arguments - . (_) - . - (string - content: (string_content) @injection.content - (#set! injection.language "luap") - (#set! injection.include-children)))) + arguments: + (arguments + . + (_) + . + (string + content: (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children)))) ;("123"):match("%d+") - (function_call (method_index_expression method: (identifier) @_method (#any-of? @_method "find" "match" "gmatch" "gsub")) - arguments: (arguments - . (string - content: (string_content) @injection.content - (#set! injection.language "luap") - (#set! injection.include-children)))) + arguments: + (arguments + . + (string + content: (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children)))) ; string.format("pi = %.2f", 3.14159) ((function_call (dot_index_expression field: (identifier) @_method) - arguments: (arguments - . (string (string_content) @injection.content))) - (#eq? @_method "format") - (#set! injection.language "printf")) + arguments: + (arguments + . + (string + (string_content) @injection.content))) + (#eq? @_method "format") + (#set! injection.language "printf")) ; ("pi = %.2f"):format(3.14159) ((function_call (method_index_expression - table: (_ (string (string_content) @injection.content)) + table: + (_ + (string + (string_content) @injection.content)) method: (identifier) @_method)) - (#eq? @_method "format") - (#set! injection.language "printf")) + (#eq? @_method "format") + (#set! injection.language "printf")) (comment - content: (_) @injection.content + content: (_) @injection.content (#set! injection.language "comment")) diff --git a/queries/lua/locals.scm b/queries/lua/locals.scm index ef927e517..8f50e844f 100644 --- a/queries/lua/locals.scm +++ b/queries/lua/locals.scm @@ -1,5 +1,4 @@ ; Scopes - [ (chunk) (do_statement) @@ -12,27 +11,35 @@ ] @local.scope ; Definitions - (assignment_statement (variable_list (identifier) @local.definition.var)) (assignment_statement (variable_list - (dot_index_expression . (_) @local.definition.associated (identifier) @local.definition.var))) + (dot_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.var))) ((function_declaration name: (identifier) @local.definition.function) (#set! definition.function.scope "parent")) ((function_declaration - name: (dot_index_expression - . (_) @local.definition.associated (identifier) @local.definition.function)) + name: + (dot_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.function)) (#set! definition.method.scope "parent")) ((function_declaration - name: (method_index_expression - . (_) @local.definition.associated (identifier) @local.definition.method)) + name: + (method_index_expression + . + (_) @local.definition.associated + (identifier) @local.definition.method)) (#set! definition.method.scope "parent")) (for_generic_clause @@ -42,10 +49,8 @@ (for_numeric_clause name: (identifier) @local.definition.var) -(parameters (identifier) @local.definition.parameter) +(parameters + (identifier) @local.definition.parameter) ; References - -[ - (identifier) -] @local.reference +(identifier) @local.reference |
