diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
commit | 931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch) | |
tree | d8c1843a95da5ea0bb4acc09f7e37843d9995c86 /runtime/queries/lua | |
parent | 142d9041391780ac15b89886a54015fdc5c73995 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-userreg.tar.gz rneovim-userreg.tar.bz2 rneovim-userreg.zip |
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'runtime/queries/lua')
-rw-r--r-- | runtime/queries/lua/folds.scm | 10 | ||||
-rw-r--r-- | runtime/queries/lua/highlights.scm | 86 | ||||
-rw-r--r-- | runtime/queries/lua/injections.scm | 33 |
3 files changed, 101 insertions, 28 deletions
diff --git a/runtime/queries/lua/folds.scm b/runtime/queries/lua/folds.scm new file mode 100644 index 0000000000..d8f0b42df3 --- /dev/null +++ b/runtime/queries/lua/folds.scm @@ -0,0 +1,10 @@ +[ + (do_statement) + (while_statement) + (repeat_statement) + (if_statement) + (for_statement) + (function_declaration) + (function_definition) + (table_constructor) +] @fold diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm index 2c0dc5447a..96ffeae793 100644 --- a/runtime/queries/lua/highlights.scm +++ b/runtime/queries/lua/highlights.scm @@ -8,8 +8,6 @@ "local" ] @keyword -(label_statement) @label - (break_statement) @keyword (do_statement @@ -109,6 +107,7 @@ [ ";" ":" + "::" "," "." ] @punctuation.delimiter @@ -128,13 +127,28 @@ (identifier) @variable +((identifier) @constant.builtin + (#eq? @constant.builtin "_VERSION")) + ((identifier) @variable.builtin - (#eq? @variable.builtin "self")) + (#eq? @variable.builtin "self")) + +((identifier) @namespace.builtin + (#any-of? @namespace.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8")) + +((identifier) @keyword.coroutine + (#eq? @keyword.coroutine "coroutine")) (variable_list - attribute: (attribute - (["<" ">"] @punctuation.bracket - (identifier) @attribute))) + attribute: (attribute + (["<" ">"] @punctuation.bracket + (identifier) @attribute))) + +;; Labels + +(label_statement (identifier) @label) + +(goto_statement (identifier) @label) ;; Constants @@ -166,13 +180,40 @@ (parameters (identifier) @parameter) -(function_call name: (identifier) @function.call) -(function_declaration name: (identifier) @function) +(function_declaration + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) -(function_call name: (dot_index_expression field: (identifier) @function.call)) -(function_declaration name: (dot_index_expression field: (identifier) @function)) +(function_declaration + name: (method_index_expression + method: (identifier) @method)) + +(assignment_statement + (variable_list . + name: [ + (identifier) @function + (dot_index_expression + field: (identifier) @function) + ]) + (expression_list . + value: (function_definition))) + +(table_constructor + (field + name: (identifier) @function + value: (function_definition))) -(method_index_expression method: (identifier) @method) +(function_call + name: [ + (identifier) @function.call + (dot_index_expression + field: (identifier) @function.call) + (method_index_expression + method: (identifier) @method.call) + ]) (function_call (identifier) @function.builtin @@ -180,20 +221,29 @@ ;; 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")) + "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 -(comment) @spell +(comment) @comment @spell -(hash_bang_line) @comment +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-][-]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-](%s?)@")) + +(hash_bang_line) @preproc (number) @number -(string) @string -(string) @spell +(string) @string @spell + +(escape_sequence) @string.escape ;; Error (ERROR) @error diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm index 0e67329139..dbfe75ae31 100644 --- a/runtime/queries/lua/injections.scm +++ b/runtime/queries/lua/injections.scm @@ -3,20 +3,33 @@ (identifier) @_cdef_identifier (_ _ (identifier) @_cdef_identifier) ] - arguments: (arguments (string content: _ @c))) + arguments: + (arguments + (string content: _ @injection.content))) + (#set! injection.language "c") (#eq? @_cdef_identifier "cdef")) ((function_call name: (_) @_vimcmd_identifier - arguments: (arguments (string content: _ @vim))) - (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_cmd")) + 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: _ @query) .)) -; (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query")) +((function_call + name: (_) @_vimcmd_identifier + 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))) + (#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify") + (#eq? @_method "nvim_exec_lua") + (#set! injection.language "lua")) -; ;; highlight string as query if starts with `;; query` -; ((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?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) @comment |