diff options
| author | Phạm Huy Hoàng <hoangtun0810@gmail.com> | 2024-03-21 20:44:35 +0900 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-03-21 15:51:26 +0100 |
| commit | 722617e6726c1508adadf83d531f54987c703be0 (patch) | |
| tree | 951cdcf1cd2571647a3e5afdc11d6fae5e88b630 /queries/lua | |
| parent | feat(rust): improve indents (diff) | |
| download | nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.gz nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.bz2 nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.lz nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.xz nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.tar.zst nvim-treesitter-722617e6726c1508adadf83d531f54987c703be0.zip | |
refactor(format): drop extra indentation for field
Diffstat (limited to 'queries/lua')
| -rw-r--r-- | queries/lua/highlights.scm | 64 | ||||
| -rw-r--r-- | queries/lua/injections.scm | 157 | ||||
| -rw-r--r-- | queries/lua/locals.scm | 18 |
3 files changed, 109 insertions, 130 deletions
diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index 053d8116d..0c8f07f29 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -180,27 +180,24 @@ (vararg_expression) @variable.parameter.builtin (function_declaration - name: - [ - (identifier) @function - (dot_index_expression - field: (identifier) @function) - ]) + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) (function_declaration - name: - (method_index_expression - method: (identifier) @function.method)) + name: (method_index_expression + method: (identifier) @function.method)) (assignment_statement (variable_list . - name: - [ - (identifier) @function - (dot_index_expression - field: (identifier) @function) - ]) + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) (expression_list . value: (function_definition))) @@ -211,14 +208,13 @@ 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 @@ -253,21 +249,19 @@ (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/injections.scm b/queries/lua/injections.scm index d1dcf87d6..4fccbcb14 100644 --- a/queries/lua/injections.scm +++ b/queries/lua/injections.scm @@ -1,49 +1,44 @@ ((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")) @@ -51,17 +46,15 @@ ; vim.api.nvim_create_autocmd("FileType", { command = "injected here" }) (function_call name: (_) @_vimcmd_identifier - arguments: - (arguments - . - (_) - . - (table_constructor - (field - name: (identifier) @_command - value: - (string - content: (_) @injection.content))) .) + arguments: (arguments + . + (_) + . + (table_constructor + (field + name: (identifier) @_command + 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") @@ -69,31 +62,29 @@ (function_call name: (_) @_user_cmd - arguments: - (arguments - . - (_) - . - (string - content: (_) @injection.content) - . - (_) .) + 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 - . - (_) - . - (_) - . - (string - content: (_) @injection.content) - . - (_) .) + arguments: (arguments + . + (_) + . + (_) + . + (string + content: (_) @injection.content) + . + (_) .) ; Limiting predicate handling to only functions with 4 arguments (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") (#set! injection.language "vim")) @@ -141,48 +132,44 @@ (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))) + 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")) diff --git a/queries/lua/locals.scm b/queries/lua/locals.scm index 8f50e844f..c4f36e8d4 100644 --- a/queries/lua/locals.scm +++ b/queries/lua/locals.scm @@ -27,19 +27,17 @@ (#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 |
