1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:30:03 +08:00
SpaceVim/bundle/nvim-treesitter/queries/swift/highlights.scm
2022-04-14 12:01:23 +08:00

151 lines
3.1 KiB
Scheme
Vendored

[ "." ";" ":" "," ] @punctuation.delimiter
[ "\\(" "(" ")" "[" "]" "{" "}"] @punctuation.bracket ; TODO: "\\(" ")" in interpolations should be @punctuation.special
; Identifiers
(attribute) @variable
(simple_identifier) @variable
(type_identifier) @type
(self_expression) @variable.builtin
; Declarations
"func" @keyword.function
[
(visibility_modifier)
(member_modifier)
(function_modifier)
(property_modifier)
(parameter_modifier)
(inheritance_modifier)
] @keyword
(function_declaration (simple_identifier) @method)
(function_declaration ["init" @constructor])
(throws) @keyword
(async) @keyword
(where_keyword) @keyword
(parameter external_name: (simple_identifier) @parameter)
(parameter name: (simple_identifier) @parameter)
(type_parameter (type_identifier) @parameter)
(inheritance_constraint (identifier (simple_identifier) @parameter))
(equality_constraint (identifier (simple_identifier) @parameter))
[
"typealias"
"struct"
"class"
"enum"
"protocol"
"extension"
"indirect"
] @keyword
(class_body (property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @property))))
(protocol_property_declaration (value_binding_pattern (non_binding_pattern (simple_identifier) @property)))
(import_declaration ["import" @include])
(enum_entry ["case" @keyword])
; Function calls
(call_expression (simple_identifier) @function) ; foo()
(call_expression ; foo.bar.baz(): highlight the baz()
(navigation_expression
(navigation_suffix (simple_identifier) @function)))
((navigation_expression
(simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type
(#lua-match? @type "^[A-Z]"))
(directive) @function.macro
(diagnostic) @function.macro
; Statements
(for_statement ["for" @repeat])
(for_statement ["in" @repeat])
(for_statement item: (simple_identifier) @variable)
(else) @keyword
(as_operator) @keyword
["while" "repeat" "continue" "break"] @repeat
["let" "var"] @keyword
(non_binding_pattern (simple_identifier) @variable)
(guard_statement ["guard" @conditional])
(if_statement ["if" @conditional])
(switch_statement ["switch" @conditional])
(switch_entry ["case" @keyword])
(switch_entry ["fallthrough" @keyword])
(switch_entry (default_keyword) @keyword)
"return" @keyword.return
(ternary_expression
["?" ":"] @conditional)
["do" (throw_keyword) (catch_keyword)] @keyword
(statement_label) @label
; Comments
(comment) @comment
(multiline_comment) @comment
; String literals
(line_str_text) @string
(str_escaped_char) @string
(multi_line_str_text) @string
(raw_str_part) @string
(raw_str_end_part) @string
(raw_str_interpolation_start) @punctuation.special
["\"" "\"\"\""] @string
; Lambda literals
(lambda_literal ["in" @keyword.operator])
; Basic literals
[
(integer_literal)
(hex_literal)
(oct_literal)
(bin_literal)
] @number
(real_literal) @float
(boolean_literal) @boolean
"nil" @variable.builtin
; Operators
(custom_operator) @operator
[
"try"
"try?"
"try!"
"!"
"+"
"-"
"*"
"/"
"%"
"="
"+="
"-="
"*="
"/="
"<"
">"
"<="
">="
"++"
"--"
"&"
"~"
"%="
"!="
"!=="
"=="
"==="
"??"
"->"
"..<"
"..."
] @operator