Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/lua/highlights.scm')
| -rw-r--r-- | runtime/queries/lua/highlights.scm | 94 |
1 files changed, 21 insertions, 73 deletions
diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm index 43e45b27..f48e607c 100644 --- a/runtime/queries/lua/highlights.scm +++ b/runtime/queries/lua/highlights.scm @@ -1,5 +1,9 @@ ;;; Highlighting for lua +;;; Builtins +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + ;; Keywords (if_statement @@ -115,18 +119,6 @@ "}" ] @punctuation.bracket -;; Variables -(identifier) @variable - -((identifier) @variable.builtin - (#eq? @variable.builtin "self")) - -(variable_list - (attribute - "<" @punctuation.bracket - (identifier) @attribute - ">" @punctuation.bracket)) - ; ;; Constants [ (false) @@ -138,68 +130,16 @@ ((identifier) @constant (#match? @constant "^[A-Z][A-Z_0-9]*$")) -;; Tables - -(field name: (identifier) @variable.other.member) - -(dot_index_expression field: (identifier) @variable.other.member) - -(table_constructor -[ - "{" - "}" -] @constructor) - -;; Functions +;; Parameters +(parameters + (identifier) @variable.parameter) -(parameters (identifier) @variable.parameter) +; ;; Functions +(function_declaration name: (identifier) @function) +(function_call name: (identifier) @function.call) -(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")) - -(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: [ - (identifier) @function - (dot_index_expression - field: (identifier) @function) - ]) - (expression_list . - value: (function_definition))) - -(table_constructor - (field - name: (identifier) @function - value: (function_definition))) - -;; Property -(dot_index_expression field: (identifier) @variable.other.member) - -(function_call - name: [ - (identifier) @function.call - (dot_index_expression - field: (identifier) @function.call) - (method_index_expression - method: (identifier) @function.method.call) - ]) +(function_declaration name: (dot_index_expression field: (identifier) @function)) +(function_call name: (dot_index_expression field: (identifier) @function.call)) ; TODO: incorrectly highlights variable N in `N, nop = 42, function() end` (assignment_statement @@ -213,9 +153,17 @@ ;; Nodes (comment) @comment (string) @string -(escape_sequence) @constant.character.escape (number) @constant.numeric.integer (label_statement) @label ; A bit of a tricky one, this will only match field names (field . (identifier) @variable.other.member (_)) (hash_bang_line) @comment + +;; Property +(dot_index_expression field: (identifier) @variable.other.member) + +;; Variable +(identifier) @variable + +;; Error +(ERROR) @error |