%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: Scala file_extensions: - scala - sbt scope: source.scala variables: # lookaround for operators nonopchar: '[[[:alpha:]]0-9\s\(\)\[\]\{\}]' # From http://www.scala-lang.org/files/archive/spec/2.11/01-lexical-syntax.html disallowed_as_operator: '[^\w\[\]\(\)\{\}''";,.`_\s]' operator_character: '[\p{Sm}\p{So}[{{disallowed_as_operator}}&&[\x{20}-\x{7E}]]]' upper: '[$\p{Lu}]' # This is "letter", but without _ so we can ensure it is not last idcont: '[$\p{Lu}\p{Ll}\p{Lt}\p{Lo}\p{Nl}0-9]' # {{operator_character}}+ \ {:, =, =>, <-, @, ←, ⇒, #} op: |- (?x: [[^:=<@\x{2190}\x{21D2}#]&&{{operator_character}}]{{operator_character}}*| =[[^>]&&{{operator_character}}]+| =>{{operator_character}}+| <(?!{{operator_character}}|[[:alpha:]])| <[[^\-]&&{{operator_character}}]+| <-{{operator_character}}+| [:@\x{2190}\x{21D2}#]{{operator_character}}+ ) # {{operator_character}}+ \ {:, =, =>, <-, @, ←, ⇒, #, <%, <:, :<, +, -} typeop: |- (?x: [[^:=<@\x{2190}\x{21D2}#+\-]&&{{operator_character}}]{{operator_character}}*| =[[^>]&&{{operator_character}}]+| =>{{operator_character}}+| <(?!{{operator_character}}|[[:alpha:]])| <[[^\-%:]&&{{operator_character}}]+| <[:%\-]{{operator_character}}+| :[[^<]&&{{operator_character}}]+| :<{{operator_character}}+| [@\x{2190}\x{21D2}#+\-]{{operator_character}}+ ) idrest: '(?:(?:{{idcont}}|_(?=[^{{operator_character}}]))*(?:_{{operator_character}}+)?)' # an id that starts with lower-case OR underscore varid: '(?:(?:\p{Ll}|_+(?={{idcont}})){{idrest}})' boundvarid: '(?:`{{varid}}`|{{varid}})' plainid: '(?:{{upper}}{{idrest}}|{{varid}}|{{op}})' typeplainid: '(?:{{upper}}{{idrest}}|{{varid}}|{{typeop}})' id: '(?:{{plainid}}|`[^`\n]+`)' idorunder: '(?:{{id}}|_)' typeid: '(?:{{typeplainid}}|`[^`\n]+`)' alphaid: (?:{{upper}}{{idrest}}|{{varid}}) # Custom productions rightarrow: '=>|\x{21D2}' upperid: '(?:(\b\p{Lu}|\$){{idrest}})' typeprefix: '(:)\s*' # hack to cover up to three levels of nested parentheses withinparens: '(?:\((?:[^\(\)]|\((?:[^\(\)]|\([^\(\)]*\))*\))*\))' withinbrackets: '(?:\[(?:[^\[\]]|\[(?:[^\[\]]|\[[^\[\]]*\])*\])*\])' # This is the full XML Name production, but should not be used where namespaces # are possible. Those locations should use a qualified_name. xml_name: '[[:alpha:]:_][[:alnum:]:_.-]*' # This is the form that allows a namespace prefix (ns:) followed by a local # name. The captures are: # 1: namespace prefix name # 2: namespace prefix colon # 3: local tag name xml_qualified_name: '(?:([[:alpha:]_][[:alnum:]_.-]*)(:))?([[:alpha:]_][[:alnum:]_.-]*)' unicode_char: '\\u[0-9a-fA-F]{4}' octal_char: '\\[0-7]{1,3}' escaped_char: '\\[btnfr"''\\]|{{unicode_char}}|{{octal_char}}' contexts: prototype: - include: comments - include: block-comments main: - include: main-pre-lambdas - include: lambdas - include: main-post-lambdas main-no-lambdas: - include: main-pre-lambdas - include: main-post-lambdas main-pre-lambdas: - include: storage-modifiers - include: declarations - include: for-comprehension - include: keywords - include: imports - include: strings - include: xml-literal - include: operators - include: initialization - include: ascription - include: annotation main-post-lambdas: - include: late-keywords - include: constants - include: scala-symbol - include: braces - include: late-operators block-comments: - match: /\*\*/ scope: comment.block.empty.scala - match: /\*\* scope: punctuation.definition.comment.scala push: - meta_scope: comment.block.documentation.scala - match: \*/ scope: punctuation.definition.comment.scala pop: true - match: (@\w+\s) scope: keyword.other.documentation.scaladoc.scala - match: '\{@link\s+[^\}]*\}' scope: keyword.other.documentation.scaladoc.link.scala - include: block-comments - match: /\* push: - meta_scope: comment.block.scala - match: \*/ pop: true - include: block-comments - match: |- (?x) (?! /\*) (?! \*/) char-literal: - match: '''({{escaped_char}}|.)''' scope: constant.character.literal.scala comments: - match: (//).*$ scope: comment.line.double-slash.scala captures: 1: punctuation.definition.comment.scala ascription: - match: '{{typeprefix}}' push: single-type-expression annotation: - match: '(@)({{plainid}})(\.)' captures: 1: meta.annotation.scala punctuation.definition.annotation.scala 2: meta.annotation.identifier.scala 3: meta.annotation.identifier.scala punctuation.accessor.scala push: - meta_content_scope: meta.annotation.identifier.scala - match: '({{plainid}})(\.)' captures: 2: punctuation.accessor.scala - match: '{{plainid}}' scope: variable.annotation.scala set: annotation-parameters - match: '(@)({{plainid}})' captures: 1: meta.annotation.scala punctuation.definition.annotation.scala 2: meta.annotation.identifier.scala variable.annotation.scala push: annotation-parameters annotation-parameters: - meta_content_scope: meta.annotation.parameters.scala - match: \( scope: punctuation.section.arguments.annotation.begin.scala push: - match: ',' scope: punctuation.separator.arguments.annotation.scala - match: \) scope: punctuation.section.arguments.annotation.end.scala pop: true - include: main - match: \[ scope: punctuation.section.arguments.annotation.begin.scala push: - match: \] scope: punctuation.section.arguments.annotation.end.scala pop: true - include: delimited-type-expression - match: (?!\s*[(\[]) pop: true lambdas: # lambda lookahead - match: '(?=({{idorunder}}|{{idorunder}}\s*:\s*{{id}}\s*{{withinbrackets}}?(\s*[\.#]\s*{{id}}\s*{{withinbrackets}}?)*|{{idorunder}}\s*:\s*{{withinparens}}|{{withinparens}})\s*(?:{{rightarrow}})[[[:alpha:]]0-9\s\)\]\}])' push: - match: '{{rightarrow}}' scope: storage.type.function.arrow.scala pop: true - include: lambda-declaration lambda-declaration-base: - match: \( push: - match: \) pop: true - include: lambda-declaration-parens - match: '{{id}}' scope: variable.parameter.scala - match: '_' scope: variable.language.underscore.scala lambda-declaration-parens: - match: '{{typeprefix}}' push: - match: ',' scope: punctuation.separator.scala pop: true - match: '(?=\))' pop: true - include: delimited-type-expression - include: lambda-declaration-base lambda-declaration: - match: '{{typeprefix}}' push: - match: '(?={{nonopchar}}({{rightarrow}}){{nonopchar}})' pop: true - include: delimited-type-expression - include: lambda-declaration-base base-types: - match: \b(Unit|Boolean|Byte|Char|Short|Int|Float|Long|Double)\b scope: storage.type.primitive.scala base-constants: - match: \b(false|null|true)\b scope: constant.language.scala # TODO negation # source: http://www.scala-lang.org/files/archive/spec/2.11/01-lexical-syntax.html#floating-point-literals - match: |- (?x) \b(?:[0-9]+\.[0-9]+(?:[eE][+\-]?[0-9]+)?[fFdD]?)\b| (?:\.[0-9]+(?:[eE][+\-]?[0-9]+)?[fFdD]?)\b| \b(?:[0-9]+(?:[eE][+\-]?[0-9]+)[fFdD]?)\b| \b(?:[0-9]+(?:[eE][+\-]?[0-9]+)?[fFdD])\b scope: constant.numeric.float.scala # source: http://www.scala-lang.org/files/archive/spec/2.11/01-lexical-syntax.html#integer-literals - match: '\b(?:0[xX][0-9a-fA-F]+[lL]?)\b' scope: constant.numeric.hex.scala - match: '\b(?:(?:0|[1-9][0-9]*)[lL]?)\b' scope: constant.numeric.integer.scala - match: \b(this|super)\b scope: variable.language.scala - include: base-types constants: - include: base-constants - include: char-literal # other upper-case stuff highlights as constant - match: '{{upperid}}' scope: support.constant.scala push: try-dispatch - match: '{{id}}(?=[\(\[])' push: try-dispatch - match: '\(\)' scope: constant.language.scala try-dispatch: - match: '\(' push: - match: \) pop: true - include: main - match: '\[' push: - match: \] pop: true - include: delimited-type-expression - match: '(?=[\S\n;])' pop: true declarations: - match: '\b(def)\s+({{id}})' captures: 1: storage.type.function.scala 2: entity.name.function.scala push: function-type-parameter-list - match: '\b(case\s+)?(class|trait|object)(?:\s+({{id}}))' scope: meta.class.identifier.scala captures: 1: storage.type.class.scala 2: storage.type.class.scala 3: entity.name.class.scala set: class-type-parameter-list - match: '\b(type)\s+({{id}})' captures: 1: storage.type.scala 2: entity.name.type.scala push: - match: '(?=[\n;\}\)\]])' pop: true - match: '\[' push: - match: '\]' pop: true - include: type-constraints - include: delimited-type-expression - match: '(<:|>:)' scope: keyword.operator.bound.scala set: - match: '(?=[\n\}\)\]])' pop: true - include: delimited-type-expression - match: '=' scope: keyword.operator.assignment.scala set: type-alias-body - match: '\b(var)\s+({{id}})' captures: 1: storage.type.volatile.scala 2: entity.name.var.scala - match: '\b(val)\b' captures: 1: storage.type.stable.scala push: - match: '(?=[=\n])' pop: true - include: val-pattern-match - match: '\b(package)\s+(object)\s+({{id}})' captures: 1: keyword.control.scala 2: storage.type.class.scala 3: entity.name.class.scala push: class-inheritance-extends - match: '\b(package)\s+({{id}}(?:\.{{id}})*)\s*\{' captures: 1: keyword.control.scala 2: entity.name.namespace.scoped.scala push: - meta_scope: meta.namespace.scala - match: '\}' pop: true - include: main - match: '\b(package)\s+({{id}}(?:\.{{id}})*)' scope: meta.namespace.scala captures: 1: keyword.control.scala 2: entity.name.namespace.header.scala # what follows is identical to case-pattern, except it goes to case-body-first - match: '\b(case)\b(?!\s+class\b)' scope: keyword.other.declaration.scala push: - meta_content_scope: meta.pattern.scala - match: '(?=\bclass\b)' pop: true - match: '\b(if)\b' captures: 1: keyword.control.flow.scala set: - match: '{{rightarrow}}' scope: keyword.operator.arrow.scala set: case-body-first - include: main-no-lambdas # eliminates arrow from the pattern meta scope - match: '(?={{rightarrow}})' set: - match: '{{rightarrow}}' scope: keyword.operator.arrow.scala set: case-body-first - match: '(?=\}|\bcase\b)' # makes typing more pleasant pop: true - include: pattern-match type-alias-body: - match: \n set: type-alias-body-newline - match: '(?=[;\}\)\]])' pop: true - include: delimited-type-expression type-alias-body-newline: - include: decl-newline-double-check - match: (?=\S) set: type-alias-body case-body-first: - meta_content_scope: meta.block.case.first.scala - match: \{ scope: punctuation.section.block.begin.scala set: - meta_scope: meta.block.scala - match: \} scope: punctuation.section.block.end.scala set: case-body-first - include: main - include: case-body case-body-non-first: - meta_content_scope: meta.block.case.non-first.scala - match: \{ scope: punctuation.section.block.begin.scala set: - meta_scope: meta.block.scala - match: \} scope: punctuation.section.block.end.scala set: case-body-non-first - include: main - include: case-body # this exists to clear the meta_scope from first or non-first case-pattern: - match: '\b(case)\b' scope: keyword.other.declaration.scala set: - meta_content_scope: meta.pattern.scala - match: '\b(if)\b' captures: 1: keyword.control.flow.scala set: - match: '{{rightarrow}}' scope: keyword.operator.arrow.scala set: case-body-non-first - include: main-no-lambdas # eliminates arrow from the pattern meta scope - match: '(?={{rightarrow}})' set: - match: '{{rightarrow}}' scope: keyword.operator.arrow.scala set: case-body-non-first - match: '(?=\}|\bcase\b)' # makes typing more pleasant pop: true - include: pattern-match case-body: - match: (?=\bcase\b) set: case-pattern - match: (?=\}) pop: true - include: main braces: - match: \[ scope: punctuation.definition.generic.begin.scala push: - meta_scope: meta.generic.scala - match: \] scope: punctuation.definition.generic.end.scala pop: true - include: delimited-type-expression - match: \( scope: punctuation.section.group.begin.scala push: - meta_scope: meta.group.scala - match: \) scope: punctuation.section.group.end.scala pop: true - include: main - match: \{ scope: punctuation.section.block.begin.scala push: - meta_scope: meta.block.scala - match: \} scope: punctuation.section.block.end.scala pop: true - include: main # emulate newline inference # this is included when a single newline is found in a declaration # you should never push/set this context, only include decl-newline-double-check: - match: '(?=[\{\}\)]|\b(case|class|def|val|var|trait|object|private|protected|for|while|if|final|sealed|implicit|type)\b)' pop: true - match: '\n' pop: true function-type-parameter-list: - match: '(?=\()' set: function-parameter-list - match: '\[' push: function-tparams-brackets - match: ':' set: function-return-type-definition - match: '(?=[\{\};]|{{nonopchar}}?={{nonopchar}})' pop: true - match: (?=\S) pop: true - match: '\n' set: function-type-parameter-list-newline function-type-parameter-list-newline: - include: decl-newline-double-check - match: '(?=\S)' set: function-type-parameter-list function-tparams-brackets: - match: '\[' push: function-tparams-brackets - match: '\]' pop: true - include: type-constraints - include: delimited-type-expression function-return-type-definition: - match: '\n' set: function-return-type-definition-newline - match: '(?=[\{\};]|{{nonopchar}}?={{nonopchar}})' pop: true - include: delimited-type-expression - match: (?=\S) pop: true function-return-type-definition-newline: - include: decl-newline-double-check - match: '(?=\S)' set: function-return-type-definition function-parameter-list: - match: '\(' push: - match: '\)' pop: true - match: '({{alphaid}})(?=\s*:)' captures: 1: variable.parameter.scala push: - match: '{{typeprefix}}' set: - match: '(\*)\s*(?=[\),=])' captures: 1: keyword.operator.varargs.scala - match: '(?=\))' pop: true - match: ',' scope: punctuation.separator.scala pop: true - include: delimited-type-expression - match: '(?=[=])' pop: true - include: main - match: ':' scope: punctuation.separator.scala set: function-return-type-definition - match: '\n' set: function-parameter-list-newline - match: '(?=\S)' pop: true function-parameter-list-newline: - include: decl-newline-double-check - match: '(?=\S)' set: function-parameter-list class-type-parameter-list: - match: '\b(private|protected)\b' scope: storage.modifier.access.scala - match: '(?=\()' set: class-parameter-list - match: '\[' push: class-tparams-brackets - match: '(?=\b(extends|with)\b)' set: class-inheritance-extends - match: '(?=\{)' set: class-pre-inheritance-early-initializer - match: '\n' set: class-type-parameter-list-newline class-type-parameter-list-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-type-parameter-list class-tparams-brackets: - match: '\[' push: class-tparams-brackets - match: '\]' pop: true - match: '\b(this|super)\b' scope: variable.language.scala - include: type-constraints - include: delimited-type-expression class-parameter-list: - match: '\(' push: - match: '\)' pop: true - match: '\b(val)\b' scope: storage.type.scala - match: '({{alphaid}})(?=\s*:)' captures: 1: variable.parameter.scala push: - match: '{{typeprefix}}' set: - match: '(\*)\s*(?=[\),=])' captures: 1: keyword.operator.varargs.scala - match: '(?=\))' pop: true - match: ',' scope: punctuation.separator.scala pop: true - include: delimited-type-expression - match: '(?=[=])' pop: true - include: main - match: '(?=\b(extends|with)\b)' set: class-inheritance-extends - match: '(?=\{)' set: class-pre-inheritance-early-initializer - match: '\n' set: class-parameter-list-newline class-parameter-list-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-parameter-list class-pre-inheritance-early-initializer: - match: \{ scope: punctuation.section.braces.begin.scala push: - meta_scope: meta.class.body.scala - match: \} scope: punctuation.section.braces.end.scala pop: true - include: main - match: '(?=\b(extends|with)\b)' set: class-inheritance-extends - match: '(?=\S)' pop: true - match: '\n' set: class-pre-inheritance-early-initializer-newline class-pre-inheritance-early-initializer-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-pre-inheritance-early-initializer class-inheritance-extends: - match: \bwith\b scope: invalid.keyword.with-before-extends.scala pop: true - match: \bextends\b scope: keyword.declaration.scala set: class-inheritance-extends-token - match: '(?=\{)' pop: true - match: '\n' set: class-inheritance-extends-newline - match: (?=\S) pop: true class-inheritance-extends-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-inheritance-extends class-inheritance-extends-token: - match: '{{id}}(?=\s*\.)' scope: entity.other.inherited-class.scala - match: '(?=\.)' push: - meta_scope: entity.other.inherited-class.scala - match: \. scope: punctuation.accessor.scala pop: true - match: '{{id}}' scope: entity.other.inherited-class.scala set: class-inheritance-extends-token-after - match: \( scope: punctuation.section.parens.begin.scala set: - match: \) scope: punctuation.section.parens.end.scala set: class-inheritance-with - include: delimited-type-expression - match: '\n' set: class-inheritance-extends-token-newline - match: (?=\S) pop: true class-inheritance-extends-token-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-inheritance-extends-token class-inheritance-extends-token-after: - match: \( scope: punctuation.section.parens.begin.scala push: - match: \) scope: punctuation.section.parens.end.scala pop: true - include: main - match: \[ scope: punctuation.section.brackets.begin.scala push: - match: \] scope: punctuation.section.brackets.end.scala pop: true - include: delimited-type-expression - match: (?=\b(with|extends)\b) set: class-inheritance-with - match: (?=\{) set: class-inheritance-early-initializer - match: '\n' set: class-inheritance-extends-token-after-newline - match: (?=\S) pop: true class-inheritance-extends-token-after-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-inheritance-extends-token-after class-inheritance-early-initializer: - match: \{ scope: punctuation.section.braces.begin.scala push: - meta_scope: meta.class.body.scala - match: \} scope: punctuation.section.braces.end.scala pop: true - include: main - match: '(?=\bwith\b)' set: class-inheritance-with - match: '(?=\S)' pop: true - match: '\n' set: class-inheritance-early-initializer-newline class-inheritance-early-initializer-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-inheritance-early-initializer class-inheritance-with: - match: \bextends\b scope: invalid.keyword.extends-after-extends.scala pop: true - match: \bwith\b scope: keyword.declaration.scala set: class-inheritance-extends-token - match: '\n' set: class-inheritance-with-newline - match: '(?=\S)' pop: true class-inheritance-with-newline: - include: decl-newline-double-check - match: '(?=\S)' set: class-inheritance-with imports: - match: \b(import)\b scope: keyword.other.import.scala push: - meta_scope: meta.import.scala - match: '(?=[\n;])' pop: true - match: '(?:{{id}}\.)+{{id}}?' scope: variable.package.scala - match: '{{id}}' scope: variable.import.scala - match: '_' scope: variable.language.underscore.scala - match: "{" push: - meta_scope: meta.import.selector.scala - match: "}" pop: true - match: '({{id}})\s*({{rightarrow}})\s*({{id}})' captures: 1: variable.import.renamed-from.scala 2: keyword.operator.arrow.scala 3: variable.import.renamed-to.scala - match: '{{rightarrow}}' scope: keyword.operator.arrow.scala - match: '{{id}}' scope: variable.import.scala - match: '_' scope: variable.language.underscore.scala # we need to greedily capture operators to prevent (e.g.) :: being matched as an ascription # it would be incorrect to scope operators specially, since they are just identifiers # by pulling them out HERE though and refusing to scope them, we emulate lookbehind operators: - match: '{{op}}(?=[\(\[])' # no explicit scope, just pulling it out push: try-dispatch - match: '{{op}}' # no explicit scope, just pulling it out initialization: - match: '\b(new)(?:\s+|\b)' captures: 1: keyword.other.scala push: # anonymous inner class AnyRef declaration syntax - match: '(?=\{)' pop: true # emergency bail-out for better experience while typing - match: '(?=[\n\}\),])' pop: true - match: '(?=\S)' set: single-type-expression try-initialization: - match: (?=\s*with\b) set: single-type-expression-tail - include: try-dispatch for-comprehension: - match: '\b(for)\s*\{' captures: 1: keyword.control.flow.scala push: - match: '\}' pop: true - include: for-braces-body - match: '\b(for)\s*\(' captures: 1: keyword.control.flow.scala push: - match: '\)' pop: true - include: for-parens-body for-braces-body: - match: |- (?x) ^(?= ( [^<\x{2190}=\{\}/"] |<[^\-] |/[^/*] |"([^"\\]|\\\.)*" |/\*([^*]|\*(?!/))*\*/ )+ {{nonopchar}}(<-|\x{2190}|=){{nonopchar}} ) push: - match: '\b(val)\b' scope: storage.type.stable.scala - match: <-|\x{2190}|= scope: keyword.operator.assignment.scala pop: true - include: pattern-match - include: main - include: main for-parens-body: - match: '\b(if)\b' scope: keyword.control.flow.scala push: for-parens-expr - match: '<-|\x{2190}|=' scope: keyword.operator.assignment.scala push: for-parens-expr - match: '\b(val)\b' scope: storage.type.stable.scala - include: pattern-match for-parens-expr: - match: '(?=\))' pop: true - match: ; pop: true - include: main keywords: - match: \b(return|throw)\b scope: keyword.control.flow.jump.scala - match: \b(else|if|do|while|for|yield|match)\b scope: keyword.control.flow.scala - match: \b(catch|finally|try)\b scope: keyword.control.exception.scala - match: \b(macro)\b scope: keyword.other.scala - match: \?\?\? scope: keyword.other.scala - match: \b(eq)\b scope: keyword.operator.word.scala late-keywords: - match: \bextends\b scope: invalid.keyword.dangling-extends.scala - match: \bwith\b scope: invalid.keyword.dangling-with.scala - match: \bforSome\b scope: keyword.declaration.scala - match: '\b(?:(?:case\s+)?class|trait|object)\b' scope: storage.type.class.scala - match: \bdef\b scope: storage.type.function.scala - match: \btype\b scope: storage.type.scala - match: \bvar\b scope: storage.type.volatile.scala - match: \b(package)\b scope: keyword.control.scala late-operators: # catch all valid identifiers and let them fall through # this prevents mixed operator identifiers from being partially highlighted - match: '{{id}}' - match: '=' scope: keyword.operator.assignment.scala - match: '_' scope: variable.language.underscore.scala - match: '\.' scope: punctuation.accessor.scala - match: ',' scope: punctuation.separator.scala nest-curly-and-self: - match: '\{' scope: punctuation.section.scope.scala push: - match: '\}' scope: punctuation.section.scope.scala pop: true - include: nest-curly-and-self - include: main scala-symbol: - match: '''{{plainid}}' scope: constant.other.symbol.scala storage-modifiers: - match: '\b(private\[\S+\]|protected\[\S+\]|private|protected)\b' scope: storage.modifier.access.scala - match: \b(abstract|final|lazy|sealed|implicit|override)\b scope: storage.modifier.other.scala # see http://www.scala-lang.org/docu/files/ScalaReference.pdf part 1.3.5-6 (page 18) strings: - match: '"""' scope: punctuation.definition.string.begin.scala push: - meta_include_prototype: false - meta_scope: string.quoted.triple.scala - match: '{{unicode_char}}' scope: constant.character.escape.scala - match: '(""")(?!")' scope: punctuation.definition.string.end.scala pop: true - match: '"' scope: punctuation.definition.string.begin.scala push: - meta_include_prototype: false - meta_scope: string.quoted.double.scala - match: '"' scope: punctuation.definition.string.end.scala pop: true - match: \n scope: invalid.string.newline.scala - include: escaped - match: '(f)(""")' captures: 1: support.function.scala 2: punctuation.definition.string.begin.scala push: - include: f_string - meta_include_prototype: false - meta_scope: string.quoted.interpolated.scala - match: '"""' scope: punctuation.definition.string.end.scala pop: true - match: '({{alphaid}})(""")' captures: 1: support.function.scala 2: punctuation.definition.string.begin.scala push: - meta_include_prototype: false - meta_scope: string.quoted.triple.interpolated.scala - match: '{{unicode_char}}' scope: constant.character.escape.scala - match: '(""")(?!")' scope: punctuation.definition.string.end.scala pop: true - include: interpolated-vars-expressions - match: '(f)(")' captures: 1: support.function.scala 2: punctuation.definition.string.begin.scala push: - meta_include_prototype: false - meta_scope: string.quoted.interpolated.scala - include: f_string - match: '"' scope: punctuation.definition.string.end.scala pop: true - match: \n scope: invalid.string.newline.scala - match: '({{alphaid}})(")' captures: 1: support.function.scala 2: punctuation.definition.string.begin.scala push: - meta_include_prototype: false - meta_scope: string.quoted.interpolated.scala - match: '"' scope: punctuation.definition.string.end.scala pop: true - match: \n scope: invalid.string.newline.scala - include: escaped - include: interpolated-vars-expressions escaped: - match: '{{escaped_char}}' scope: constant.character.escape.scala - match: \\ scope: invalid.illegal.lone-escape.scala # f_string, see: # http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#detail # /!\ this implementation may allow incorrect combinaisons f_string: - include: escaped - include: interpolated-vars-expressions # constant formatting - match: '%[%n]' scope: constant.other.formatting.scala # general formatting - match: '%\-?#?[bBhHsS]' scope: constant.other.formatting.scala # character formatting - match: '%\-?[cC]' scope: constant.other.formatting.scala # date-time formatting - match: '%\-?[tT][HIklMSLNpzZsQBbhAaCYyjmdeRTrDFc]?' scope: constant.other.formatting.scala # floating point formatting - match: '%[\+\-# 0\(,]*[\.0-9]*[feEgGaA]' scope: constant.other.formatting.scala # integer formatting - match: '%[\+\-# 0\(,]*[doxX]' scope: constant.other.formatting.scala interpolated-vars-expressions: - match: '(\$){{alphaid}}' scope: variable.other.scala captures: 1: punctuation.definition.variable.scala - match: '\$\{' scope: punctuation.definition.expression.scala push: - match: '\}' scope: punctuation.definition.expression.scala pop: true - match: '' push: - clear_scopes: 1 - meta_content_scope: source.scala.embedded - match: (?=\}) pop: true - include: nest-curly-and-self - include: main xml-literal: - match: '' scope: punctuation.definition.string.end.xml pop: true - match: '?' scope: invalid.illegal.bad-closing-tag.xml - match: '(<)({{xml_qualified_name}})' captures: 1: punctuation.definition.tag.begin.xml 2: entity.name.tag.xml push: xml-tag-decl - match: '<\?\s*xml(?:\s.*[>$]|\b)' scope: invalid.illegal.reserved-proc-instr.xml - match: '(<\?)\s*({{xml_qualified_name}})' captures: 1: punctuation.definition.tag.begin.xml 2: entity.name.tag.xml push: xml-tag-decl xml-comments: - meta_scope: text.xml - meta_include_prototype: false - match: '' scope: punctuation.definition.comment.end.xml pop: true xml-tag-decl: - meta_scope: text.xml meta.tag.xml - meta_include_prototype: false - include: xml-comments - include: xml-entity - match: '\?>' scope: punctuation.definition.tag.end.xml pop: true - match: '/>' scope: punctuation.definition.tag.end.xml pop: true - match: '>' scope: punctuation.definition.tag.end.xml set: xml-mode - match: '(?:\s+|^){{xml_qualified_name}}\s*(=)' captures: 1: entity.other.attribute-name.namespace.xml 2: entity.other.attribute-name.xml punctuation.separator.namespace.xml 3: entity.other.attribute-name.localname.xml 4: punctuation.separator.key-value.xml set: xml-attribute-val - match: '(?:\s+|^)([[:alnum:]:_.-]+)\s*(=)' captures: 1: invalid.illegal.bad-attribute-name.xml 2: punctuation.separator.key-value.xml - include: xml-should-be-entity xml-attribute-val: - meta_include_prototype: false - include: xml-comments - include: xml-entity - include: xml-should-be-entity - match: '"' scope: punctuation.definition.string.begin.xml set: - meta_scope: text.xml meta.tag.xml string.quoted.double.xml - include: xml-entity - include: xml-should-be-entity - match: '"' scope: punctuation.definition.string.end.xml set: xml-tag-decl # TODO entities - match: "'" scope: punctuation.definition.string.begin.xml set: - meta_scope: text.xml meta.tag.xml string.quoted.single.xml - include: xml-entity - include: xml-should-be-entity - match: "'" scope: punctuation.definition.string.end.xml set: xml-tag-decl # TODO entities - match: '\{' scope: punctuation.definition.inline.begin.xml set: - match: '\}' scope: punctuation.definition.inline.end.xml set: xml-tag-decl - include: main xml-should-be-entity: - match: '&' scope: invalid.illegal.bad-ampersand.xml - match: '<' scope: invalid.illegal.missing-entity.xml - match: '>' scope: invalid.illegal.missing-entity.xml xml-entity: - match: '(&)(?:{{xml_name}}|#[0-9]+|#x\h+)(;)' scope: constant.character.entity.xml captures: 1: punctuation.definition.constant.xml 2: punctuation.definition.constant.xml xml-mode: - meta_content_scope: text.xml - meta_include_prototype: false - include: xml-comments - include: xml-entity - match: '\{' scope: punctuation.definition.inline.begin.xml push: - clear_scopes: 1 - match: '\}' scope: punctuation.definition.inline.end.xml pop: true - include: main - match: '()' scope: text.xml meta.tag.xml captures: 1: punctuation.definition.tag.begin.xml 2: entity.name.tag.xml 6: punctuation.definition.tag.end.xml pop: true - include: xml-literal - include: xml-should-be-entity val-pattern-match-main: - include: keywords - include: base-constants - include: char-literal - include: scala-symbol - include: strings - include: xml-literal - include: late-keywords - match: '`' scope: punctuation.definition.identifier.scala push: - match: '[`\n]' scope: punctuation.definition.identifier.scala pop: true - match: '{{varid}}(?:(\.){{varid}})+' captures: 1: punctuation.accessor.scala - match: '{{varid}}(\.)' # redundant to catch {{varid}}.{{upperid}} captures: 1: punctuation.accessor.scala - match: '(\.){{varid}}' captures: 1: punctuation.accessor.scala - match: '{{upperid}}' scope: support.constant.scala - match: '\b{{varid}}' scope: entity.name.val.scala - match: \[ push: - match: \] pop: true - include: main - match: '{{op}}' # let it fall through - match: '@' scope: keyword.operator.at.scala - match: '_\*' scope: keyword.operator.varargs.scala - match: '_' scope: variable.language.underscore.scala - match: ',' scope: punctuation.separator.scala val-pattern-match: - match: '(?:{{upperid}}|{{op}})(?=[\s=:])' scope: entity.name.val.scala - match: '{{typeprefix}}' push: - match: '(?={{nonopchar}}={{nonopchar}})' pop: true - include: delimited-type-expression - match: '(?=[\{\n])' pop: true - include: val-pattern-match-main - match: \( push: - match: \) pop: true - include: val-pattern-match-inner val-pattern-match-inner: - include: val-pattern-match-main - match: '{{upperid}}' scope: support.class.scala base-pattern-match: - include: keywords - include: base-constants - include: char-literal - include: scala-symbol - include: strings - include: xml-literal - include: late-keywords - match: '`' scope: punctuation.definition.identifier.scala push: - match: '[`\n]' scope: punctuation.definition.identifier.scala pop: true - match: '{{varid}}(?:(\.){{varid}})+' captures: 1: punctuation.accessor.scala - match: '{{varid}}(\.)' # redundant to catch {{varid}}.{{upperid}} captures: 1: punctuation.accessor.scala - match: '(\.){{varid}}' captures: 1: punctuation.accessor.scala - match: '{{upperid}}' scope: support.constant.scala - match: '\b{{varid}}' scope: variable.parameter.scala # not indexed! - match: '{{op}}' # let it fall through - match: \[ push: - match: \] pop: true - include: delimited-type-expression - match: '@' scope: keyword.operator.at.scala - match: '_\*' scope: keyword.operator.varargs.scala - match: '_' scope: variable.language.underscore.scala - match: ',' scope: punctuation.separator.scala nested-pattern-match: - include: base-pattern-match - match: '{{typeprefix}}' push: - match: '(?=[,\)@])' pop: true - include: delimited-type-expression - match: \( push: - match: \) pop: true - include: nested-pattern-match pattern-match: - include: base-pattern-match - include: ascription - match: \( push: - match: \) pop: true - include: nested-pattern-match base-type-expression: # \x{03BB} = λ, \x{03B1} = α, \x{03B2} = β - match: '\(\{\s*type\s+\x{03BB}\[\x{03B1}(\[_\])?(,\s*\x{03B2}(\[_\])?)?\]\s*=' scope: comment.block.scala push: - match: '\}\)#\x{03BB}' scope: comment.block.scala pop: true - include: delimited-type-expression - match: \( push: - match: \) pop: true - include: delimited-type-expression - match: \[ push: - match: \] pop: true - include: delimited-type-expression - match: \{ push: - match: \} pop: true - include: declarations - match: =>|\x{21D2} scope: keyword.operator.arrow.scala - match: '_\*' scope: keyword.operator.varargs.scala type-constraints: - match: '<:|>:|<%|\+|-|:' scope: keyword.operator.bound.scala delimited-type-expression: - include: annotation - match: '\b(type)\b' scope: keyword.other.scala - match: '\b(with)\b' scope: keyword.declaration.scala - match: '[\x{03B1}\x{03B2}]' # just here for type lambdas scope: comment.block.empty.scala - match: '[\.#]' scope: punctuation.accessor.scala - include: base-types - match: '\b(forSome)\b' scope: keyword.declaration.scala - match: '{{upperid}}' scope: support.class.scala - match: _ - match: '{{typeid}}' scope: support.type.scala - include: base-type-expression single-type-expression: - match: '\b(type)\b' scope: keyword.other.scala - match: '[\x{03B1}\x{03B2}]' # just here for type lambdas scope: comment.block.empty.scala - match: \b(Unit|Boolean|Byte|Char|Short|Int|Float|Long|Double)\b scope: storage.type.primitive.scala set: single-type-expression-tail - match: '\b(forSome)\b' scope: keyword.declaration.scala - match: '{{upperid}}' scope: support.class.scala set: single-type-expression-tail - match: '{{typeid}}' scope: support.type.scala set: single-type-expression-tail - match: (?=@{{plainid}}) set: single-type-expression-tail - include: base-type-expression - match: '(?=[\s,\)\}\]])' pop: true single-type-expression-tail: - match: (?=@{{plainid}}) set: - include: annotation - match: '(?=\S)' set: single-type-expression-tail - match: '[\.#]' scope: punctuation.accessor.scala set: single-type-expression - match: \[ scope: punctuation.definition.generic.begin.scala set: - meta_scope: meta.generic.scala - match: \] scope: punctuation.definition.generic.end.scala set: single-type-expression-tail - include: delimited-type-expression - match: '\b(with)(?:\s+|\b)' captures: 1: keyword.declaration.scala set: single-type-expression - match: '(?=\S)' set: try-initialization # this is needed for initialization (new ...) and doesn't HURT elsewhere