nvim-treesitter/queries/teal/highlights.scm

136 lines
3.3 KiB
Scheme
Raw Normal View History

2020-10-04 19:39:12 -05:00
2021-03-23 16:06:02 -05:00
;; Primitives
(boolean) @boolean
2022-09-26 10:19:02 +01:00
(comment) @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-][-]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
(shebang_comment) @preproc
2021-03-23 16:06:02 -05:00
(identifier) @variable
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
(nil) @constant.builtin
(number) @number
(string) @string
(table_constructor ["{" "}"] @constructor)
(varargs "..." @constant.builtin)
[ "," "." ":" ";" ] @punctuation.delimiter
(escape_sequence) @string.escape
(format_specifier) @string.escape
2020-12-16 16:42:33 -06:00
;; Basic statements/Keywords
[ "if" "then" "elseif" "else" ] @conditional
[ "for" "while" "repeat" "until" ] @repeat
"return" @keyword.return
2021-07-25 15:27:51 +02:00
[ "in" "local" (break) (goto) "do" "end" ] @keyword
2020-10-04 19:39:12 -05:00
(label) @label
2020-12-16 16:42:33 -06:00
;; Global isn't a real keyword, but it gets special treatment in these places
2020-10-04 19:39:12 -05:00
(var_declaration "global" @keyword)
2020-12-16 16:42:33 -06:00
(type_declaration "global" @keyword)
2020-10-04 19:39:12 -05:00
(function_statement "global" @keyword)
2020-12-16 16:42:33 -06:00
(record_declaration "global" @keyword)
(enum_declaration "global" @keyword)
2020-10-04 19:39:12 -05:00
2020-12-03 20:55:11 +01:00
;; Ops
2021-03-23 16:06:02 -05:00
(bin_op (op) @operator)
(unary_op (op) @operator)
[ "=" "as" ] @operator
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
;; Functions
(function_statement
"function" @keyword.function
. name: (_) @function)
(anon_function
"function" @keyword.function)
(function_body "end" @keyword.function)
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
(arg name: (identifier) @parameter)
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
(function_signature
(arguments
. (arg name: (identifier) @variable.builtin))
(#eq? @variable.builtin "self"))
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
(typeargs
"<" @punctuation.bracket
2021-01-05 09:33:11 -06:00
. (_) @parameter
. ("," . (_) @parameter)*
2020-12-16 16:42:33 -06:00
. ">" @punctuation.bracket)
2020-10-04 19:39:12 -05:00
(function_call
2020-12-16 16:42:33 -06:00
(identifier) @function . (arguments))
(function_call
(index (_) key: (identifier) @function) . (arguments))
(function_call
(method_index (_) key: (identifier) @function) . (arguments))
2020-10-04 19:39:12 -05:00
2020-12-16 16:42:33 -06:00
;; Types
(record_declaration
. "record" @keyword
name: (identifier) @type)
(anon_record . "record" @keyword)
(record_body
2021-07-25 15:27:51 +02:00
(record_declaration
. [ "record" ] @keyword
. name: (identifier) @type))
(record_body
(enum_declaration
. [ "enum" ] @keyword
. name: (identifier) @type))
2021-01-05 09:33:11 -06:00
(record_body
2021-07-25 15:27:51 +02:00
(typedef
2020-12-16 16:42:33 -06:00
. "type" @keyword
2021-07-25 15:27:51 +02:00
. name: (identifier) @type . "="))
2021-01-05 09:33:11 -06:00
(record_body
(metamethod "metamethod" @keyword))
(record_body
(userdata) @keyword)
2020-12-16 16:42:33 -06:00
(enum_declaration
"enum" @keyword
name: (identifier) @type)
2020-10-04 19:39:12 -05:00
(type_declaration "type" @keyword)
2021-07-25 15:27:51 +02:00
(type_declaration (identifier) @type)
2021-11-03 11:25:14 +00:00
(simple_type name: (identifier) @type)
(type_index (identifier) @type)
2020-12-16 16:42:33 -06:00
(type_union "|" @operator)
2020-10-04 19:39:12 -05:00
(function_type "function" @type)
2020-12-16 16:42:33 -06:00
;; The rest of it
(var_declaration
2021-07-25 15:27:51 +02:00
declarators: (var_declarators
(var name: (identifier) @variable)))
2020-12-16 16:42:33 -06:00
(var_declaration
2021-07-25 15:27:51 +02:00
declarators: (var_declarators
(var
"<" @punctuation.bracket
. attribute: (attribute) @attribute
. ">" @punctuation.bracket)))
2020-12-16 16:42:33 -06:00
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
2021-03-23 16:06:02 -05:00
;; Only highlight format specifiers in calls to string.format
;; string.format('...')
;(function_call
; called_object: (index
; (identifier) @base
; key: (identifier) @entry)
; arguments: (arguments .
; (string (format_specifier) @string.escape))
;
; (#eq? @base "string")
; (#eq? @entry "format"))
;; ('...'):format()
;(function_call
; called_object: (method_index
; (string (format_specifier) @string.escape)
; key: (identifier) @func-name)
; (#eq? @func-name "format"))
2020-10-04 19:39:12 -05:00
(ERROR) @error