|
|
|
@ -1,5 +1,10 @@
|
|
|
|
|
; Upstream: https://github.com/alex-pinkus/tree-sitter-swift/blob/8d2fd80e3322df51e3f70952e60d57f5d4077eb8/queries/highlights.scm
|
|
|
|
|
|
|
|
|
|
(line_string_literal
|
|
|
|
|
["\\(" ")"] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
["." ";" ":" "," ] @punctuation.delimiter
|
|
|
|
|
[ "\\(" "(" ")" "[" "]" "{" "}"] @punctuation.bracket ; TODO: "\\(" ")" in interpolations should be @punctuation.special
|
|
|
|
|
["(" ")" "[" "]" "{" "}"] @punctuation.bracket ; TODO: "\\(" ")" in interpolations should be @punctuation.special
|
|
|
|
|
|
|
|
|
|
; Identifiers
|
|
|
|
|
(attribute) @variable
|
|
|
|
@ -18,7 +23,7 @@
|
|
|
|
|
] @keyword
|
|
|
|
|
|
|
|
|
|
(function_declaration (simple_identifier) @function.method)
|
|
|
|
|
(function_declaration ["init" @constructor])
|
|
|
|
|
(function_declaration "init" @constructor)
|
|
|
|
|
(throws) @keyword
|
|
|
|
|
"async" @keyword
|
|
|
|
|
(where_keyword) @keyword
|
|
|
|
@ -27,16 +32,21 @@
|
|
|
|
|
(type_parameter (type_identifier) @variable.parameter)
|
|
|
|
|
(inheritance_constraint (identifier (simple_identifier) @variable.parameter))
|
|
|
|
|
(equality_constraint (identifier (simple_identifier) @variable.parameter))
|
|
|
|
|
(non_binding_pattern bound_identifier: (simple_identifier)) @variable
|
|
|
|
|
(pattern bound_identifier: (simple_identifier)) @variable
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
"typealias"
|
|
|
|
|
"struct"
|
|
|
|
|
"class"
|
|
|
|
|
"actor"
|
|
|
|
|
"enum"
|
|
|
|
|
"protocol"
|
|
|
|
|
"extension"
|
|
|
|
|
"indirect"
|
|
|
|
|
"nonisolated"
|
|
|
|
|
"override"
|
|
|
|
|
"convenience"
|
|
|
|
|
"required"
|
|
|
|
|
"some"
|
|
|
|
|
] @keyword
|
|
|
|
|
|
|
|
|
@ -46,12 +56,12 @@
|
|
|
|
|
(modify_specifier)
|
|
|
|
|
] @keyword
|
|
|
|
|
|
|
|
|
|
(class_body (property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @variable.other.member))))
|
|
|
|
|
(protocol_property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @variable.other.member)))
|
|
|
|
|
(class_body (property_declaration (pattern (simple_identifier) @variable.other.member)))
|
|
|
|
|
(protocol_property_declaration (pattern (simple_identifier) @variable.other.member))
|
|
|
|
|
|
|
|
|
|
(import_declaration ["import" @keyword.control.import])
|
|
|
|
|
(import_declaration "import" @keyword.control.import)
|
|
|
|
|
|
|
|
|
|
(enum_entry ["case" @keyword])
|
|
|
|
|
(enum_entry "case" @keyword)
|
|
|
|
|
|
|
|
|
|
; Function calls
|
|
|
|
|
(call_expression (simple_identifier) @function) ; foo()
|
|
|
|
@ -66,8 +76,8 @@
|
|
|
|
|
(diagnostic) @function.macro
|
|
|
|
|
|
|
|
|
|
; Statements
|
|
|
|
|
(for_statement ["for" @keyword.control.repeat])
|
|
|
|
|
(for_statement ["in" @keyword.control.repeat])
|
|
|
|
|
(for_statement "for" @keyword.control.repeat)
|
|
|
|
|
(for_statement "in" @keyword.control.repeat)
|
|
|
|
|
(for_statement item: (simple_identifier) @variable)
|
|
|
|
|
(else) @keyword
|
|
|
|
|
(as_operator) @keyword
|
|
|
|
@ -75,15 +85,14 @@
|
|
|
|
|
["while" "repeat" "continue" "break"] @keyword.control.repeat
|
|
|
|
|
|
|
|
|
|
["let" "var"] @keyword
|
|
|
|
|
(non_binding_pattern (simple_identifier) @variable)
|
|
|
|
|
|
|
|
|
|
(guard_statement ["guard" @keyword.control.conditional])
|
|
|
|
|
(if_statement ["if" @keyword.control.conditional])
|
|
|
|
|
(switch_statement ["switch" @keyword.control.conditional])
|
|
|
|
|
(switch_entry ["case" @keyword])
|
|
|
|
|
(switch_entry ["fallthrough" @keyword])
|
|
|
|
|
(guard_statement "guard" @keyword.control.conditional)
|
|
|
|
|
(if_statement "if" @keyword.control.conditional)
|
|
|
|
|
(switch_statement "switch" @keyword.control.conditional)
|
|
|
|
|
(switch_entry "case" @keyword)
|
|
|
|
|
(switch_entry "fallthrough" @keyword)
|
|
|
|
|
(switch_entry (default_keyword) @keyword)
|
|
|
|
|
"return" @keyword.control.return
|
|
|
|
|
"return" @keyword.return
|
|
|
|
|
(ternary_expression
|
|
|
|
|
["?" ":"] @keyword.control.conditional)
|
|
|
|
|
|
|
|
|
@ -92,8 +101,8 @@
|
|
|
|
|
(statement_label) @label
|
|
|
|
|
|
|
|
|
|
; Comments
|
|
|
|
|
(comment) @comment.line
|
|
|
|
|
(multiline_comment) @comment.block
|
|
|
|
|
(comment) @comment
|
|
|
|
|
(multiline_comment) @comment
|
|
|
|
|
|
|
|
|
|
; String literals
|
|
|
|
|
(line_str_text) @string
|
|
|
|
@ -101,25 +110,29 @@
|
|
|
|
|
(multi_line_str_text) @string
|
|
|
|
|
(raw_str_part) @string
|
|
|
|
|
(raw_str_end_part) @string
|
|
|
|
|
(raw_str_interpolation_start) @string.special
|
|
|
|
|
(raw_str_interpolation_start) @punctuation.special
|
|
|
|
|
["\"" "\"\"\""] @string
|
|
|
|
|
|
|
|
|
|
; Lambda literals
|
|
|
|
|
(lambda_literal ["in" @keyword.operator])
|
|
|
|
|
(lambda_literal "in" @keyword.operator)
|
|
|
|
|
|
|
|
|
|
; Basic literals
|
|
|
|
|
(integer_literal) @constant.numeric.integer
|
|
|
|
|
[
|
|
|
|
|
(hex_literal)
|
|
|
|
|
(oct_literal)
|
|
|
|
|
(bin_literal)
|
|
|
|
|
] @constant.numeric
|
|
|
|
|
(integer_literal) @constant.numeric.integer
|
|
|
|
|
(real_literal) @constant.numeric.float
|
|
|
|
|
(boolean_literal) @constant.builtin.boolean
|
|
|
|
|
"nil" @variable.builtin
|
|
|
|
|
|
|
|
|
|
"?" @type
|
|
|
|
|
(type_annotation "!" @type)
|
|
|
|
|
|
|
|
|
|
(simple_identifier) @variable
|
|
|
|
|
|
|
|
|
|
; Operators
|
|
|
|
|
(custom_operator) @operator
|
|
|
|
|
[
|
|
|
|
|
"try"
|
|
|
|
|
"try?"
|
|
|
|
@ -154,5 +167,5 @@
|
|
|
|
|
|
|
|
|
|
"..<"
|
|
|
|
|
"..."
|
|
|
|
|
(custom_operator)
|
|
|
|
|
] @operator
|
|
|
|
|
|
|
|
|
|