feat!: drop modules, general refactor and cleanup

This commit is contained in:
Christian Clason 2023-06-12 09:54:30 -06:00
parent c13e28f894
commit 2c8f2f2fad
829 changed files with 4905 additions and 8010 deletions

View file

@ -0,0 +1,188 @@
[ "." ";" ":" "," ] @punctuation.delimiter
; TODO: "\\(" ")" in interpolations should be @punctuation.special
[ "\\(" "(" ")" "[" "]" "{" "}"] @punctuation.bracket
; Identifiers
(attribute) @variable
(type_identifier) @type
(self_expression) @variable.builtin
; Declarations
"func" @keyword.function
[
(visibility_modifier)
(member_modifier)
(function_modifier)
(property_modifier)
(parameter_modifier)
(inheritance_modifier)
(mutation_modifier)
] @type.qualifier
(function_declaration (simple_identifier) @method)
(function_declaration ["init" @constructor])
(throws) @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))
(pattern bound_identifier: (simple_identifier)) @variable
[
"typealias"
"struct"
"class"
"actor"
"enum"
"protocol"
"extension"
"indirect"
"nonisolated"
"override"
"convenience"
"required"
"some"
] @keyword
[
"async"
"await"
] @keyword.coroutine
[
(getter_specifier)
(setter_specifier)
(modify_specifier)
] @keyword
(class_body (property_declaration (pattern (simple_identifier) @property)))
(protocol_property_declaration (pattern (simple_identifier) @property))
(navigation_expression
(navigation_suffix (simple_identifier) @property))
(value_argument
name: (simple_identifier) @property)
(import_declaration ["import" @include])
(enum_entry ["case" @keyword])
; Function calls
(call_expression (simple_identifier) @function.call) ; foo()
(call_expression ; foo.bar.baz(): highlight the baz()
(navigation_expression
(navigation_suffix (simple_identifier) @function.call)))
(call_expression
(prefix_expression (simple_identifier) @function.call)) ; .foo()
((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 (pattern) @variable)
(else) @keyword
(as_operator) @keyword
["while" "repeat" "continue" "break"] @repeat
["let" "var"] @keyword
(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)
(multiline_comment)
] @comment @spell
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))
((comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))
((multiline_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
; 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" @constant.builtin
; Regex literals
(regex_literal) @string.regex
; Operators
(custom_operator) @operator
[
"try"
"try?"
"try!"
"+"
"-"
"*"
"/"
"%"
"="
"+="
"-="
"*="
"/="
"<"
">"
"<="
">="
"++"
"--"
"&"
"~"
"%="
"!="
"!=="
"=="
"==="
"??"
"->"
"..<"
"..."
(bang)
] @operator

View file

@ -0,0 +1,92 @@
[
; ... refers to the section that will get affected by this indent.begin capture
(protocol_body) ; protocol Foo { ... }
(class_body) ; class Foo { ... }
(enum_class_body) ; enum Foo { ... }
(function_declaration) ; func Foo (...) {...}
(computed_property) ; { ... }
(subscript_declaration) ; subscript Foo(...) { ... }
(computed_getter) ; get { ... }
(computed_setter) ; set { ... }
(assignment) ; a = b
(control_transfer_statement) ; return ...
(for_statement)
(while_statement)
(repeat_while_statement)
(do_statement)
(if_statement)
(switch_statement)
(guard_statement)
(type_parameters) ; x<Foo>
(tuple_type) ; (...)
(array_type) ; [String]
(dictionary_type) ; [Foo: Bar]
(call_expression) ; callFunc(...)
(tuple_expression) ; ( foo + bar )
(array_literal) ; [ foo, bar ]
(dictionary_literal) ; [ foo: bar, x: y ]
(lambda_literal)
] @indent.begin
; @something(...)
((modifiers
(attribute) @indent.begin))
(function_declaration
(modifiers
.
(attribute)
(_)* @indent.branch)
.
_ @indent.branch
(#not-has-type? @indent.branch type_parameters parameter))
(ERROR
[
"<"
"{"
"("
"["
]
) @indent.begin
; if-elseif
(if_statement
(if_statement) @indent.dedent)
; case Foo:
; default Foo:
; @attribute default Foo:
(switch_entry . _ @indent.branch)
(function_declaration ")" @indent.branch)
(type_parameters ">" @indent.branch @indent.end .)
(tuple_expression ")" @indent.branch @indent.end)
(value_arguments ")" @indent.branch @indent.end)
(tuple_type ")" @indent.branch @indent.end)
(modifiers
(attribute ")" @indent.branch @indent.end))
[
"}"
"]"
] @indent.branch @indent.end
[
; (ERROR)
(comment)
(multiline_comment)
(raw_str_part)
(multi_line_string_literal)
] @indent.auto
(directive) @indent.ignore

View file

@ -0,0 +1,18 @@
(import_declaration (identifier) @definition.import)
(function_declaration name: (simple_identifier) @definition.function)
; Scopes
[
(statements)
(for_statement)
(while_statement)
(repeat_while_statement)
(do_statement)
(if_statement)
(guard_statement)
(switch_statement)
(property_declaration)
(function_declaration)
(class_declaration)
(protocol_declaration)
] @scope