mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat(swift): add many missing highlights
This commit is contained in:
parent
45ee50d02b
commit
12e339e370
1 changed files with 83 additions and 46 deletions
|
|
@ -5,9 +5,7 @@
|
|||
","
|
||||
] @punctuation.delimiter
|
||||
|
||||
; TODO: "\\(" ")" in interpolations should be @punctuation.special
|
||||
[
|
||||
"\\("
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
|
|
@ -17,14 +15,18 @@
|
|||
] @punctuation.bracket
|
||||
|
||||
; Identifiers
|
||||
(attribute) @variable
|
||||
|
||||
(type_identifier) @type
|
||||
|
||||
(self_expression) @variable.builtin
|
||||
[
|
||||
(self_expression)
|
||||
(super_expression)
|
||||
] @variable.builtin
|
||||
|
||||
; Declarations
|
||||
"func" @keyword.function
|
||||
[
|
||||
"func"
|
||||
"deinit"
|
||||
] @keyword.function
|
||||
|
||||
[
|
||||
(visibility_modifier)
|
||||
|
|
@ -36,16 +38,17 @@
|
|||
(mutation_modifier)
|
||||
] @keyword.modifier
|
||||
|
||||
(simple_identifier) @variable
|
||||
|
||||
(function_declaration
|
||||
(simple_identifier) @function.method)
|
||||
|
||||
(protocol_function_declaration
|
||||
name: (simple_identifier) @function.method)
|
||||
|
||||
(init_declaration
|
||||
"init" @constructor)
|
||||
|
||||
(throws) @keyword
|
||||
|
||||
(where_keyword) @keyword
|
||||
|
||||
(parameter
|
||||
external_name: (simple_identifier) @variable.parameter)
|
||||
|
||||
|
|
@ -63,9 +66,6 @@
|
|||
(identifier
|
||||
(simple_identifier) @variable.parameter))
|
||||
|
||||
(pattern
|
||||
bound_identifier: (simple_identifier)) @variable
|
||||
|
||||
[
|
||||
"protocol"
|
||||
"extension"
|
||||
|
|
@ -80,6 +80,16 @@
|
|||
"unowned"
|
||||
"didSet"
|
||||
"willSet"
|
||||
"subscript"
|
||||
"let"
|
||||
"var"
|
||||
(throws)
|
||||
(where_keyword)
|
||||
(getter_specifier)
|
||||
(setter_specifier)
|
||||
(modify_specifier)
|
||||
(else)
|
||||
(as_operator)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
|
|
@ -94,12 +104,6 @@
|
|||
"await"
|
||||
] @keyword.coroutine
|
||||
|
||||
[
|
||||
(getter_specifier)
|
||||
(setter_specifier)
|
||||
(modify_specifier)
|
||||
] @keyword
|
||||
|
||||
(shebang_line) @keyword.directive
|
||||
|
||||
(class_body
|
||||
|
|
@ -116,7 +120,8 @@
|
|||
(simple_identifier) @variable.member))
|
||||
|
||||
(value_argument
|
||||
name: (value_argument_label) @variable.member)
|
||||
name: (value_argument_label
|
||||
(simple_identifier) @variable.member))
|
||||
|
||||
(import_declaration
|
||||
"import" @keyword.import)
|
||||
|
|
@ -124,14 +129,11 @@
|
|||
(enum_entry
|
||||
"case" @keyword)
|
||||
|
||||
; Attributes
|
||||
(modifiers
|
||||
(attribute) @attribute.builtin)
|
||||
|
||||
(modifiers
|
||||
(attribute
|
||||
"@" @attribute
|
||||
(user_type
|
||||
(type_identifier) @attribute.builtin)))
|
||||
(type_identifier) @attribute)))
|
||||
|
||||
; Function calls
|
||||
(call_expression
|
||||
|
|
@ -151,9 +153,30 @@
|
|||
(simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type
|
||||
(#lua-match? @type "^[A-Z]"))
|
||||
|
||||
(directive) @function.macro
|
||||
(directive) @keyword.directive
|
||||
|
||||
(diagnostic) @function.macro
|
||||
; See https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#Keywords-and-Punctuation
|
||||
[
|
||||
(diagnostic)
|
||||
"#available"
|
||||
"#unavailable"
|
||||
"#fileLiteral"
|
||||
"#colorLiteral"
|
||||
"#imageLiteral"
|
||||
"#keyPath"
|
||||
"#selector"
|
||||
"#externalMacro"
|
||||
] @function.macro
|
||||
|
||||
[
|
||||
"#column"
|
||||
"#dsohandle"
|
||||
"#fileID"
|
||||
"#filePath"
|
||||
"#file"
|
||||
"#function"
|
||||
"#line"
|
||||
] @constant.macro
|
||||
|
||||
; Statements
|
||||
(for_statement
|
||||
|
|
@ -162,13 +185,6 @@
|
|||
(for_statement
|
||||
"in" @keyword.repeat)
|
||||
|
||||
(for_statement
|
||||
(pattern) @variable)
|
||||
|
||||
(else) @keyword
|
||||
|
||||
(as_operator) @keyword
|
||||
|
||||
[
|
||||
"while"
|
||||
"repeat"
|
||||
|
|
@ -176,11 +192,6 @@
|
|||
"break"
|
||||
] @keyword.repeat
|
||||
|
||||
[
|
||||
"let"
|
||||
"var"
|
||||
] @keyword
|
||||
|
||||
(guard_statement
|
||||
"guard" @keyword.conditional)
|
||||
|
||||
|
|
@ -205,13 +216,14 @@
|
|||
[
|
||||
"?"
|
||||
":"
|
||||
] @keyword.conditional)
|
||||
] @keyword.conditional.ternary)
|
||||
|
||||
[
|
||||
(try_operator)
|
||||
"do"
|
||||
(throw_keyword)
|
||||
(catch_keyword)
|
||||
] @keyword
|
||||
] @keyword.exception
|
||||
|
||||
(statement_label) @label
|
||||
|
||||
|
|
@ -233,7 +245,7 @@
|
|||
; String literals
|
||||
(line_str_text) @string
|
||||
|
||||
(str_escaped_char) @string
|
||||
(str_escaped_char) @string.escape
|
||||
|
||||
(multi_line_str_text) @string
|
||||
|
||||
|
|
@ -241,7 +253,23 @@
|
|||
|
||||
(raw_str_end_part) @string
|
||||
|
||||
(raw_str_interpolation_start) @punctuation.special
|
||||
(line_string_literal
|
||||
[
|
||||
"\\("
|
||||
")"
|
||||
] @punctuation.special)
|
||||
|
||||
(multi_line_string_literal
|
||||
[
|
||||
"\\("
|
||||
")"
|
||||
] @punctuation.special)
|
||||
|
||||
(raw_str_interpolation
|
||||
[
|
||||
(raw_str_interpolation_start)
|
||||
")"
|
||||
] @punctuation.special)
|
||||
|
||||
[
|
||||
"\""
|
||||
|
|
@ -266,6 +294,8 @@
|
|||
|
||||
"nil" @constant.builtin
|
||||
|
||||
(wildcard_pattern) @character.special
|
||||
|
||||
; Regex literals
|
||||
(regex_literal) @string.regexp
|
||||
|
||||
|
|
@ -273,9 +303,6 @@
|
|||
(custom_operator) @operator
|
||||
|
||||
[
|
||||
"try"
|
||||
"try?"
|
||||
"try!"
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
|
|
@ -288,10 +315,13 @@
|
|||
"/="
|
||||
"<"
|
||||
">"
|
||||
"<<"
|
||||
">>"
|
||||
"<="
|
||||
">="
|
||||
"++"
|
||||
"--"
|
||||
"^"
|
||||
"&"
|
||||
"&&"
|
||||
"|"
|
||||
|
|
@ -302,9 +332,16 @@
|
|||
"!=="
|
||||
"=="
|
||||
"==="
|
||||
"?"
|
||||
"??"
|
||||
"->"
|
||||
"..<"
|
||||
"..."
|
||||
(bang)
|
||||
] @operator
|
||||
|
||||
(type_arguments
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
] @punctuation.bracket)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue