{ "name": "Scala", "scopeName": "source.scala", "patterns": [ { "include": "#code" } ], "repository": { "block-comments": { "name": "comment.block.scala", "begin": "/\\*", "end": "\\*/", "patterns": [ { "include": "#block-comments" }, { "match": "(?x)(?! /\\*)(?! \\*/)" } ] }, "char-literal": { "name": "constant.character.literal.scala", "begin": "'", "end": "'", "patterns": [ { "name": "constant.character.escape.scala", "match": "\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})" }, { "name": "invalid.illegal.unrecognized-character-escape.scala", "match": "\\\\." }, { "name": "invalid.illegal.character-literal-too-long", "match": "[^']{2,}" }, { "name": "invalid.illegal.character-literal-too-long", "match": "(?\u003c!')[^']" } ], "beginCaptures": { "0": { "name": "punctuation.definition.character.begin.scala" } }, "endCaptures": { "0": { "name": "punctuation.definition.character.end.scala" } } }, "code": { "patterns": [ { "include": "#script-header" }, { "include": "#storage-modifiers" }, { "include": "#declarations" }, { "include": "#inheritance" }, { "include": "#imports" }, { "include": "#comments" }, { "include": "#strings" }, { "include": "#initialization" }, { "include": "#xml-literal" }, { "include": "#keywords" }, { "include": "#constants" }, { "include": "#scala-symbol" }, { "include": "#scala-quoted" }, { "include": "#special-identifier" }, { "include": "#char-literal" }, { "include": "#empty-parentheses" }, { "include": "#parameter-list" }, { "include": "#qualifiedClassName" }, { "include": "#meta-brackets" }, { "include": "#meta-bounds" }, { "include": "#meta-colons" } ] }, "comments": { "patterns": [ { "name": "comment.block.empty.scala", "match": "/\\*\\*/", "captures": { "0": { "name": "punctuation.definition.comment.scala" } } }, { "name": "comment.block.documentation.scala", "begin": "^\\s*(/\\*\\*)(?!/)", "end": "\\*/", "patterns": [ { "match": "(@param)\\s+(\\S+)", "captures": { "1": { "name": "keyword.other.documentation.scaladoc.scala" }, "2": { "name": "variable.parameter.scala" } } }, { "match": "(@(?:tparam|throws))\\s+(\\S+)", "captures": { "1": { "name": "keyword.other.documentation.scaladoc.scala" }, "2": { "name": "entity.name.class" } } }, { "name": "keyword.other.documentation.scaladoc.scala", "match": "@(return|see|note|example|usecase|author|version|since|todo|deprecated|migration|define|inheritdoc)\\b" }, { "match": "(\\[\\[)([^\\]]+)(\\]\\])", "captures": { "1": { "name": "punctuation.definition.documentation.link.scala" }, "2": { "name": "entity.other.documentation.link.scala" }, "3": { "name": "punctuation.definition.documentation.link.scala" } } } ], "beginCaptures": { "1": { "name": "punctuation.definition.comment.scala" } }, "endCaptures": { "0": { "name": "punctuation.definition.comment.scala" } } }, { "name": "comment.block.scala", "begin": "/\\*", "end": "\\*/", "captures": { "0": { "name": "punctuation.definition.comment.scala" } } }, { "begin": "(^[ \\t]+)?(?=//)", "end": "(?!\\G)", "patterns": [ { "name": "comment.line.double-slash.scala", "begin": "//", "end": "\\n", "beginCaptures": { "0": { "name": "punctuation.definition.comment.scala" } } } ], "beginCaptures": { "1": { "name": "punctuation.whitespace.comment.leading.scala" } } } ] }, "constants": { "patterns": [ { "name": "constant.language.scala", "match": "\\b(false|null|true|Nil|None)\\b" }, { "name": "constant.numeric.scala", "match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.[0-9]+)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?|[0-9]+)([LlFfDd]|UL|ul)?\\b" }, { "name": "variable.language.scala", "match": "\\b(this|super|self)\\b" }, { "name": "storage.type.primitive.scala", "match": "\\b(Unit|Boolean|Byte|Char|Short|Int|Float|Long|Double)\\b" }, { "name": "storage.type.scala", "match": "\\b(String|Symbol)\\b" } ] }, "declarations": { "patterns": [ { "match": "(?x)\\b(def)\\s+(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))", "captures": { "1": { "name": "keyword.declaration.scala" }, "2": { "name": "entity.name.function.declaration" } } }, { "match": "\\b(trait)\\s+([^\\s\\{\\(\\[]+)", "captures": { "1": { "name": "keyword.declaration.scala" }, "2": { "name": "entity.name.class.declaration" } } }, { "match": "\\b(?:(case)\\s+)?(class|object)\\s+([^\\s\\{\\(\\[]+)", "captures": { "1": { "name": "keyword.declaration.scala" }, "2": { "name": "keyword.declaration.scala" }, "3": { "name": "entity.name.class.declaration" } } }, { "match": "\\b(type)\\s+(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))", "captures": { "1": { "name": "keyword.declaration.scala" }, "2": { "name": "entity.name.type.declaration" } } }, { "match": "\\b(val)\\s+([A-Z\\p{Lt}\\p{Lu}](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?)\\b", "captures": { "1": { "name": "keyword.declaration.stable.scala" }, "2": { "name": "constant.other.declaration.scala" } } }, { "match": "\\b(?:(val)|(var))\\s+(?:(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))|(?=\\())", "captures": { "1": { "name": "keyword.declaration.stable.scala" }, "2": { "name": "keyword.declaration.volatile.scala" }, "3": { "name": "variable.other.declaration.scala" } } }, { "match": "\\b(package)\\s+(object)\\s+([^\\s\\{\\(\\[]+)", "captures": { "1": { "name": "keyword.other.scoping.scala" }, "2": { "name": "keyword.declaration.scala" }, "3": { "name": "entity.name.class.declaration" } } }, { "name": "meta.package.scala", "begin": "\\b(package)\\s+", "end": "(?\u003c=[\\n;])", "patterns": [ { "include": "#comments" }, { "name": "entity.name.package.scala", "match": "(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))" }, { "name": "punctuation.definition.package", "match": "\\." } ], "beginCaptures": { "1": { "name": "keyword.other.import.scala" } } } ] }, "empty-parentheses": { "name": "meta.parentheses.scala", "match": "(\\(\\))", "captures": { "1": { "name": "meta.bracket.scala" } } }, "imports": { "name": "meta.import.scala", "begin": "\\b(import)\\s+", "end": "(?\u003c=[\\n;])", "patterns": [ { "include": "#comments" }, { "name": "entity.name.import.scala", "match": "(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))" }, { "name": "punctuation.definition.import", "match": "\\." }, { "name": "meta.import.selector.scala", "begin": "{", "end": "}", "patterns": [ { "match": "(?x)\\s*(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))\\s*(=\u003e)\\s*(`[^`]+`|(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))\\s*", "captures": { "1": { "name": "entity.name.import.renamed-from.scala" }, "2": { "name": "keyword.other.arrow.scala" }, "3": { "name": "entity.name.import.renamed-to.scala" } } }, { "name": "entity.name.import.scala", "match": "([^\\s.,}]+)" } ], "beginCaptures": { "0": { "name": "meta.bracket.scala" } }, "endCaptures": { "0": { "name": "meta.bracket.scala" } } } ], "beginCaptures": { "1": { "name": "keyword.other.import.scala" } } }, "inheritance": { "patterns": [ { "match": "(extends|with)\\s+([^\\s\\{\\(\\[\\]]+)", "captures": { "1": { "name": "keyword.declaration.scala" }, "2": { "name": "entity.other.inherited-class.scala" } } } ] }, "initialization": { "match": "\\b(new)\\s+([^\\s,\\{\\}\\(\\)\\[\\]]+)", "captures": { "1": { "name": "keyword.declaration.scala" }, "2": { "name": "entity.name.class" } } }, "keywords": { "patterns": [ { "name": "keyword.control.flow.jump.scala", "match": "\\b(return|throw)\\b" }, { "name": "support.function.type-of.scala", "match": "\\b(classOf|isInstanceOf|asInstanceOf)\\b" }, { "name": "keyword.control.flow.scala", "match": "\\b(else|if|do|while|for|yield|match|case)\\b" }, { "name": "keyword.control.exception.scala", "match": "\\b(catch|finally|try)\\b" }, { "name": "keyword.operator.comparison.scala", "match": "(==?|!=|\u003c=|\u003e=|\u003c\u003e|\u003c|\u003e)" }, { "name": "keyword.operator.arithmetic.scala", "match": "(\\-|\\+|\\*|/(?![/*])|%|~)" }, { "name": "keyword.operator.logical.scala", "match": "(!|\u0026\u0026|\\|\\|)" }, { "name": "keyword.operator.scala", "match": "(\u003c-|←|-\u003e|→|=\u003e|⇒|\\?|\\:+|@|\\|)+" } ] }, "meta-bounds": { "name": "meta.bounds.scala", "match": "\u003c%|=:=|\u003c:\u003c|\u003c%\u003c|\u003e:|\u003c:" }, "meta-brackets": { "patterns": [ { "name": "punctuation.section.block.begin.scala", "match": "\\{" }, { "name": "punctuation.section.block.end.scala", "match": "\\}" }, { "name": "meta.bracket.scala", "match": "{|}|\\(|\\)|\\[|\\]" } ] }, "meta-colons": { "patterns": [ { "name": "meta.colon.scala", "match": "(?\u003c!:):(?!:)" } ] }, "parameter-list": { "patterns": [ { "match": "(?\u003c=[^\\._$a-zA-Z0-9])(`[^`]+`|[_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?)\\s*(:)\\s+", "captures": { "1": { "name": "variable.parameter.scala" }, "2": { "name": "meta.colon.scala" } } } ] }, "qualifiedClassName": { "match": "(\\b([A-Z][\\w]*))", "captures": { "1": { "name": "entity.name.class" } } }, "scala-quoted": { "name": "constant.other.quoted.scala", "match": "'\\{'|'\\('|'\\['|'\\{|'\\(|'\\[" }, "scala-symbol": { "name": "constant.other.symbol.scala", "match": "(?\u003e'(?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*(?:(?\u003c=_)[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]]+)?|(?:[!#%\u0026*+\\-\\/:\u003c\u003e=?@^|~[\\p{Sm}\\p{So}]])+))(?!')" }, "script-header": { "name": "comment.block.shebang.scala", "match": "^#!(.*)$", "captures": { "1": { "name": "string.unquoted.shebang.scala" } } }, "special-identifier": { "match": "\\b[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}'\"`\\w])" }, "storage-modifiers": { "patterns": [ { "name": "storage.modifier.access", "match": "\\b(private\\[\\S+\\]|protected\\[\\S+\\]|private|protected)\\b" }, { "name": "storage.modifier.other", "match": "\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|override|@transient|@native)\\b" } ] }, "string-interpolation": { "patterns": [ { "name": "constant.character.escape.interpolation.scala", "match": "\\$\\$" }, { "match": "(\\$)([[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]](?:[[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]|[0-9])*)", "captures": { "1": { "name": "punctuation.definition.template-expression.begin.scala" } } }, { "name": "punctuation.definition.template-expression.scala", "begin": "\\$\\{", "end": "\\}", "patterns": [ { "include": "#code" } ], "beginCaptures": { "0": { "name": "punctuation.definition.template-expression.begin.scala" } }, "endCaptures": { "0": { "name": "punctuation.definition.template-expression.end.scala" } } } ] }, "strings": { "patterns": [ { "name": "string.quoted.triple.scala", "begin": "\"\"\"", "end": "\"\"\"(?!\")", "patterns": [ { "name": "constant.character.escape.scala", "match": "\\\\\\\\|\\\\u[0-9A-Fa-f]{4}" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.scala" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.scala" } } }, { "begin": "\\b([[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]+)(\"\"\")", "end": "\"\"\"(?!\")", "patterns": [ { "include": "#string-interpolation" }, { "name": "constant.character.escape.scala", "match": "\\\\\\\\|\\\\u[0-9A-Fa-f]{4}" }, { "name": "string.quoted.triple.interpolated.scala", "match": "." } ], "beginCaptures": { "1": { "name": "keyword.interpolation.scala" }, "2": { "name": "string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala" } }, "endCaptures": { "0": { "name": "string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala" } } }, { "name": "string.quoted.double.scala", "begin": "\"", "end": "\"", "patterns": [ { "name": "constant.character.escape.scala", "match": "\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})" }, { "name": "invalid.illegal.unrecognized-string-escape.scala", "match": "\\\\." } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.scala" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.scala" } } }, { "begin": "\\b([[A-Z\\p{Lt}\\p{Lu}][_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]]+)(\")", "end": "\"", "patterns": [ { "include": "#string-interpolation" }, { "name": "constant.character.escape.scala", "match": "\\\\(?:[btnfr\\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})" }, { "name": "invalid.illegal.unrecognized-string-escape.scala", "match": "\\\\." }, { "name": "string.quoted.double.interpolated.scala", "match": "." } ], "beginCaptures": { "1": { "name": "keyword.interpolation.scala" }, "2": { "name": "string.quoted.double.interpolated.scala punctuation.definition.string.begin.scala" } }, "endCaptures": { "0": { "name": "string.quoted.double.interpolated.scala punctuation.definition.string.end.scala" } } } ] }, "xml-doublequotedString": { "name": "string.quoted.double.xml", "begin": "\"", "end": "\"", "patterns": [ { "include": "#xml-entity" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.xml" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.xml" } } }, "xml-embedded-content": { "patterns": [ { "name": "meta.source.embedded.scala", "begin": "{", "end": "}", "patterns": [ { "include": "#code" } ], "captures": { "0": { "name": "meta.bracket.scala" } } }, { "match": " (?:([-_a-zA-Z0-9]+)((:)))?([_a-zA-Z-]+)=", "captures": { "1": { "name": "entity.other.attribute-name.namespace.xml" }, "2": { "name": "entity.other.attribute-name.xml" }, "3": { "name": "punctuation.separator.namespace.xml" }, "4": { "name": "entity.other.attribute-name.localname.xml" } } }, { "include": "#xml-doublequotedString" }, { "include": "#xml-singlequotedString" } ] }, "xml-entity": { "name": "constant.character.entity.xml", "match": "(\u0026)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)", "captures": { "1": { "name": "punctuation.definition.constant.xml" }, "3": { "name": "punctuation.definition.constant.xml" } } }, "xml-literal": { "patterns": [ { "name": "meta.tag.no-content.xml", "begin": "(\u003c)((?:([_a-zA-Z0-9][_a-zA-Z0-9]*)((:)))?([_a-zA-Z0-9][-_a-zA-Z0-9:]*))(?=(\\s[^\u003e]*)?\u003e\u003c/\\2\u003e)", "end": "(\u003e(\u003c))/(?:([-_a-zA-Z0-9]+)((:)))?([-_a-zA-Z0-9:]*[_a-zA-Z0-9])(\u003e)", "patterns": [ { "include": "#xml-embedded-content" } ], "beginCaptures": { "1": { "name": "punctuation.definition.tag.xml" }, "3": { "name": "entity.name.tag.namespace.xml" }, "4": { "name": "entity.name.tag.xml" }, "5": { "name": "punctuation.separator.namespace.xml" }, "6": { "name": "entity.name.tag.localname.xml" } }, "endCaptures": { "1": { "name": "punctuation.definition.tag.xml" }, "2": { "name": "meta.scope.between-tag-pair.xml" }, "3": { "name": "entity.name.tag.namespace.xml" }, "4": { "name": "entity.name.tag.xml" }, "5": { "name": "punctuation.separator.namespace.xml" }, "6": { "name": "entity.name.tag.localname.xml" }, "7": { "name": "punctuation.definition.tag.xml" } } }, { "name": "meta.tag.xml", "begin": "(\u003c/?)(?:([_a-zA-Z0-9][-_a-zA-Z0-9]*)((:)))?([_a-zA-Z0-9][-_a-zA-Z0-9:]*)(?=[^\u003e]*?\u003e)", "end": "(/?\u003e)", "patterns": [ { "include": "#xml-embedded-content" } ], "captures": { "1": { "name": "punctuation.definition.tag.xml" }, "2": { "name": "entity.name.tag.namespace.xml" }, "3": { "name": "entity.name.tag.xml" }, "4": { "name": "punctuation.separator.namespace.xml" }, "5": { "name": "entity.name.tag.localname.xml" } } }, { "include": "#xml-entity" } ] }, "xml-singlequotedString": { "name": "string.quoted.single.xml", "begin": "'", "end": "'", "patterns": [ { "include": "#xml-entity" } ], "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.xml" } }, "endCaptures": { "0": { "name": "punctuation.definition.string.end.xml" } } } } }