mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 10:50:06 -04:00
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
This commit is contained in:
parent
668de0951a
commit
c80715f883
8 changed files with 189 additions and 206 deletions
|
|
@ -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
|
||||
(label_statement) @label
|
||||
|
||||
(break_statement) @keyword
|
||||
|
||||
(do_statement
|
||||
[
|
||||
"for"
|
||||
"do"
|
||||
"end"
|
||||
] @repeat)
|
||||
|
||||
(for_in_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
|
||||
;; Others
|
||||
|
||||
;; Parameters
|
||||
(parameters
|
||||
(identifier) @parameter)
|
||||
|
||||
;; 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue