aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
commitff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch)
tree729bbcb92231538fa61dab6c3d890b025484b7f5 /runtime/queries/lua
parent376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff)
parent28c04948a1c887a1cc0cb64de79fa32631700466 (diff)
downloadrneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/queries/lua')
-rw-r--r--runtime/queries/lua/highlights.scm78
-rw-r--r--runtime/queries/lua/injections.scm123
2 files changed, 97 insertions, 104 deletions
diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm
index 0b0bf35a8b..0c8f07f290 100644
--- a/runtime/queries/lua/highlights.scm
+++ b/runtime/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,27 +208,24 @@
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
- ; format-ignore
(#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" "rawlen" "rawset" "require" "select" "setfenv" "setmetatable"
- "tonumber" "tostring" "type" "unpack" "xpcall"
- "__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc"
- "__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex"
- "__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
+ "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" "load" "loadfile"
+ "loadstring" "module" "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset"
+ "require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall"
+ "__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc" "__idiv"
+ "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex" "__pairs"
+ "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
; Others
(comment) @comment @spell
@@ -255,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/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm
index c8a1843c84..4345c71ce8 100644
--- a/runtime/queries/lua/injections.scm
+++ b/runtime/queries/lua/injections.scm
@@ -1,66 +1,69 @@
((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"))
+ (#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"))
+; exec_lua [[ ... ]] in functionaltests
+((function_call
+ name: (identifier) @_function
+ arguments: (arguments
+ (string
+ content: (string_content) @injection.content)))
+ (#eq? @_function "exec_lua")
+ (#set! injection.language "lua"))
+
; 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")
@@ -68,31 +71,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"))