diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2022-01-18 22:15:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-18 22:15:26 +0100 |
| commit | c80715f883b8c7963782973b23297c5dec7924be (patch) | |
| tree | 3ae4ea4499db6824abd65be4b4f2931a6b8a2864 /queries/lua/highlights.scm | |
| parent | chore: remove swift tests for now (cause CI failure) (diff) | |
| download | nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.tar nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.tar.gz nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.tar.bz2 nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.tar.lz nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.tar.xz nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.tar.zst nvim-treesitter-c80715f883b8c7963782973b23297c5dec7924be.zip | |
feat(lua)!: switch from our fork to MunifTanjim's (#2272)
also take queries from https://github.com/MunifTanjim/nvim-treesitter-lua/tree/main/queries/lua
BREAKING CHANGE: queries are not compatible; modules will have to update
Diffstat (limited to 'queries/lua/highlights.scm')
| -rw-r--r-- | queries/lua/highlights.scm | 205 |
1 files changed, 115 insertions, 90 deletions
diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index 6433815c8..03b3090a6 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -1,36 +1,34 @@ -;;; Highlighting for lua - ;;; Builtins -(self) @variable.builtin + +[ + (false) + (true) +] @boolean + +(nil) @constant.builtin + +((identifier) @variable.builtin + (#match? @variable.builtin "self")) ;; Keywords -(if_statement -[ - "if" - "then" - "end" -] @conditional) +"return" @keyword.return [ - "else" - "elseif" - "then" -] @conditional + "goto" + "in" + "local" +] @keyword -(for_statement -[ - "for" - "do" - "end" -] @repeat) +(label_statement) @label + +(break_statement) @keyword -(for_in_statement +(do_statement [ - "for" "do" "end" -] @repeat) +] @keyword) (while_statement [ @@ -45,57 +43,90 @@ "until" ] @repeat) -(do_statement +(if_statement +[ + "if" + "elseif" + "else" + "then" + "end" +] @conditional) + +(elseif_statement +[ + "elseif" + "then" + "end" +] @conditional) + +(else_statement +[ + "else" + "end" +] @conditional) + +(for_statement [ + "for" "do" "end" -] @keyword) +] @repeat) +(function_declaration [ - "in" - "local" - (break_statement) - "goto" -] @keyword + "function" + "end" +] @keyword.function) -"return" @keyword.return +(function_definition +[ + "function" + "end" +] @keyword.function) ;; Operators [ - "not" "and" + "not" "or" ] @keyword.operator [ -"=" -"~=" -"==" -"<=" -">=" -"<" -">" -"+" -"-" -"%" -"/" -"//" -"*" -"^" -"&" -"~" -"|" -">>" -"<<" -".." -"#" - ] @operator + "+" + "-" + "*" + "/" + "%" + "^" + "#" + "==" + "~=" + "<=" + ">=" + "<" + ">" + "=" + "&" + "~" + "|" + "<<" + ">>" + "//" + ".." +] @operator -;; Punctuation -["," "." ":" ";"] @punctuation.delimiter +;; Punctuations + +[ + ";" + ":" + "," + "." +] @punctuation.delimiter ;; Brackets + [ "(" ")" @@ -106,40 +137,41 @@ ] @punctuation.bracket ;; Variables + (identifier) @variable ;; Constants -[ -(false) -(true) -] @boolean -(nil) @constant.builtin -(spread) @constant ;; "..." + +(vararg_expression) @constant + ((identifier) @constant (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) +;; Tables + +(field name: (identifier) @field) + +(dot_index_expression field: (identifier) @field) + +(table_constructor +[ + "{" + "}" +] @constructor) + ;; Functions -(function [(function_name) (identifier)] @function) -(function ["function" "end"] @keyword.function) -(local_function (identifier) @function) -(local_function ["function" "end"] @keyword.function) +(arguments (identifier) @parameter) -(variable_declaration - (variable_declarator (identifier) @function) (function_definition)) -(local_variable_declaration - (variable_declarator (identifier) @function) (function_definition)) +(parameters (identifier) @parameter) -(function_definition ["function" "end"] @keyword.function) +(function_call name: (identifier) @function) +(function_declaration name: (identifier) @function) -(property_identifier) @property +(function_call name: (dot_index_expression field: (identifier) @function)) +(function_declaration name: (dot_index_expression field: (identifier) @function)) -(function_call - [((identifier) @variable (method) @method) - ((_) (method) @method) - (identifier) @function - (field_expression (property_identifier) @function)] - . (arguments)) +(method_index_expression method: (identifier) @method) (function_call (identifier) @function.builtin @@ -150,22 +182,15 @@ "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable" "tonumber" "tostring" "type" "unpack" "xpcall")) -;; built-in next function -(next) @function.builtin - -;; Parameters -(parameters - (identifier) @parameter) +;; Others -;; Nodes -(table ["{" "}"] @constructor) (comment) @comment -(string) @string + +(hash_bang_line) @comment + (number) @number -(label_statement) @label -; A bit of a tricky one, this will only match field names -(field . (identifier) @field (_)) -(shebang) @comment + +(string) @string ;; Error (ERROR) @error |
