diff --git a/example/lib/main.dart b/example/lib/main.dart index e8d486f..c2e304b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -29,12 +29,22 @@ fields: const _json = '{"name":"John", "age":30, "car":null}'; +const _python = ''' + +def hello(): + print('Hello, World!') + +hello() +'''; + late final Highlighter _dartLightHighlighter; late final Highlighter _dartDarkHighlighter; late final Highlighter _serverpodProtocolLightYamlHighlighter; late final Highlighter _serverpodProtocolDarkYamlHighlighter; late final Highlighter _jsonLightHighlighter; late final Highlighter _jsonDarkHighlighter; +late final Highlighter _pythonLightHighlighter; +late final Highlighter _pythonDarkHighlighter; void main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -46,6 +56,7 @@ void main() async { 'sql', 'serverpod_protocol', 'json', + 'python', ]); // Load the default light theme and create a highlighter. @@ -78,6 +89,16 @@ void main() async { theme: darkTheme, ); + _pythonDarkHighlighter = Highlighter( + language: 'python', + theme: darkTheme, + ); + + _pythonLightHighlighter = Highlighter( + language: 'python', + theme: lightTheme, + ); + runApp(const MyApp()); } @@ -177,6 +198,30 @@ class MyHomePage extends StatelessWidget { ), ), ), + Container( + padding: const EdgeInsets.all(16), + color: Colors.white, + child: Text.rich( + // Highlight the code. + _pythonLightHighlighter.highlight(_python), + style: GoogleFonts.jetBrainsMono( + fontSize: 14, + height: 1.3, + ), + ), + ), + Container( + padding: const EdgeInsets.all(16), + color: Colors.black, + child: Text.rich( + // Highlight the code. + _pythonDarkHighlighter.highlight(_python), + style: GoogleFonts.jetBrainsMono( + fontSize: 14, + height: 1.3, + ), + ), + ), ], ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index 78cb033..707f5f1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" crypto: dependency: transitive description: @@ -115,6 +115,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" + url: "https://pub.dev" + source: hosted + version: "10.0.7" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" + url: "https://pub.dev" + source: hosted + version: "3.0.8" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -127,34 +151,34 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.15.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_provider: dependency: transitive description: @@ -223,7 +247,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -236,10 +260,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" stream_channel: dependency: transitive description: @@ -252,10 +276,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" syntax_highlight: dependency: "direct main" description: @@ -275,10 +299,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.3" typed_data: dependency: transitive description: @@ -295,14 +319,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + name: vm_service + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "14.3.0" win32: dependency: transitive description: @@ -320,5 +344,5 @@ packages: source: hosted version: "1.0.1" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.3.0" + dart: ">=3.4.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/grammars/css.json b/grammars/css.json new file mode 100644 index 0000000..729bc4c --- /dev/null +++ b/grammars/css.json @@ -0,0 +1,127 @@ +{ + "name": "CSS", + "version": "1.0.0", + "fileTypes": ["css"], + "scopeName": "source.css", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#rules" + }, + { + "include": "#mediaQueries" + }, + { + "include": "#keyframes" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.block.css", + "begin": "/\\*", + "end": "\\*/", + "captures": { + "0": { "name": "punctuation.definition.comment.css" } + } + } + ] + }, + "rules": { + "patterns": [ + { + "name": "meta.rule-set.css", + "begin": "([a-zA-Z0-9\\-_*#.:\\[\\]\\s]+)\\s*(\\{)", + "beginCaptures": { + "1": { "name": "entity.name.selector.css" }, + "2": { "name": "punctuation.definition.block.begin.css" } + }, + "end": "\\}", + "endCaptures": { + "0": { "name": "punctuation.definition.block.end.css" } + }, + "patterns": [ + { + "include": "#properties" + } + ] + } + ] + }, + "properties": { + "patterns": [ + { + "name": "meta.property.css", + "match": "\\b([a-zA-Z-]+)\\s*:", + "captures": { + "1": { "name": "support.type.property-name.css" } + } + }, + { + "name": "meta.value.css", + "match": "(\\b[a-zA-Z0-9%\\#\\.,()\\s-]+)(;)?", + "captures": { + "1": { "name": "support.constant.property-value.css" }, + "2": { "name": "punctuation.terminator.rule.css" } + } + } + ] + }, + "mediaQueries": { + "patterns": [ + { + "name": "meta.at-rule.media.css", + "begin": "@media\\s+([^{]+)\\s*\\{", + "beginCaptures": { + "1": { "name": "support.type.media-query.css" } + }, + "end": "\\}", + "endCaptures": { + "0": { "name": "punctuation.definition.block.end.css" } + }, + "patterns": [ + { + "include": "#rules" + } + ] + } + ] + }, + "keyframes": { + "patterns": [ + { + "name": "meta.at-rule.keyframes.css", + "begin": "@(keyframes|\\-webkit\\-keyframes)\\s+[a-zA-Z0-9-_]+\\s*\\{", + "beginCaptures": { + "1": { "name": "support.type.keyframes.css" } + }, + "end": "\\}", + "endCaptures": { + "0": { "name": "punctuation.definition.block.end.css" } + }, + "patterns": [ + { + "name": "meta.keyframe-block.css", + "begin": "([0-9]+%|from|to)\\s*\\{", + "beginCaptures": { + "1": { "name": "constant.numeric.keyframe-offset.css" } + }, + "end": "\\}", + "endCaptures": { + "0": { "name": "punctuation.definition.block.end.css" } + }, + "patterns": [ + { + "include": "#properties" + } + ] + } + ] + } + ] + } + } +} diff --git a/grammars/go.json b/grammars/go.json new file mode 100644 index 0000000..38fc2ee --- /dev/null +++ b/grammars/go.json @@ -0,0 +1,180 @@ +{ + "name": "Go", + "version": "1.0.0", + "fileTypes": ["go"], + "scopeName": "source.go", + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + "patterns": [ + { + "name": "meta.package.go", + "begin": "^\\s*package\\b", + "end": "$", + "patterns": [ + { + "include": "#identifier" + } + ] + }, + { + "name": "meta.import.go", + "begin": "^\\s*import\\b", + "end": "(?=^[^\\s]|\\Z)", + "patterns": [ + { + "name": "string.quoted.double.go", + "match": "\"[^\"]*\"" + }, + { + "include": "#identifier" + } + ] + }, + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#constants" + }, + { + "include": "#operators" + }, + { + "include": "#strings" + }, + { + "include": "#punctuation" + }, + { + "include": "#functions" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.double-slash.go", + "match": "//.*$" + }, + { + "name": "comment.block.go", + "begin": "/\\*", + "end": "\\*/" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.go", + "match": "\\b(if|else|for|range|switch|case|select|break|continue|fallthrough|return|go|defer|goto|default)\\b" + }, + { + "name": "keyword.declaration.go", + "match": "\\b(var|const|type|struct|interface|func|package|import|map|chan)\\b" + }, + { + "name": "keyword.storage.go", + "match": "\\b(bool|byte|complex64|complex128|error|float32|float64|int|int8|int16|int32|int64|rune|string|uint|uint8|uint16|uint32|uint64|uintptr)\\b" + } + ] + }, + "constants": { + "patterns": [ + { + "name": "constant.language.go", + "match": "\\b(true|false|iota|nil)\\b" + }, + { + "name": "constant.numeric.go", + "match": "\\b\\d+(_\\d+)*\\.?\\d*([eE][+-]?\\d+)?\\b" + }, + { + "name": "constant.character.escape.go", + "match": "\\\\." + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.go", + "match": "\\+\\+|--|==|!=|<=|>=|&&|\\|\\||<<|>>|&\\^|\\+=|-=|\\*=|/=|%=" + }, + { + "name": "keyword.operator.assignment.go", + "match": "=" + }, + { + "name": "keyword.operator.arithmetic.go", + "match": "[+\\-*/%]" + }, + { + "name": "keyword.operator.bitwise.go", + "match": "[&|^]" + }, + { + "name": "keyword.operator.logical.go", + "match": "&&|\\|\\||!" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.go", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.go", + "match": "\\\\." + } + ] + }, + { + "name": "string.quoted.raw.go", + "begin": "`", + "end": "`" + } + ] + }, + "punctuation": { + "patterns": [ + { + "name": "punctuation.separator.go", + "match": "[,;]" + }, + { + "name": "punctuation.bracket.go", + "match": "[\\[\\](){}]" + } + ] + }, + "functions": { + "patterns": [ + { + "name": "meta.function.go", + "begin": "\\bfunc\\b", + "end": "(?=\\{)", + "patterns": [ + { + "include": "#identifier" + } + ] + } + ] + }, + "identifier": { + "patterns": [ + { + "name": "variable.other.go", + "match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b" + } + ] + } + } +} diff --git a/grammars/html.json b/grammars/html.json new file mode 100644 index 0000000..13a1d09 --- /dev/null +++ b/grammars/html.json @@ -0,0 +1,143 @@ +{ + "name": "HTML", + "version": "1.0.0", + "fileTypes": ["html", "htm"], + "scopeName": "text.html.basic", + "patterns": [ + { + "include": "#tags" + }, + { + "include": "#comments" + }, + { + "include": "#entities" + }, + { + "include": "#embeddedCode" + } + ], + "repository": { + "tags": { + "patterns": [ + { + "name": "meta.tag.html", + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.html" } + }, + "patterns": [ + { + "include": "#attributes" + } + ] + } + ] + }, + "attributes": { + "patterns": [ + { + "name": "entity.other.attribute-name.html", + "match": "\\b([a-zA-Z_:][a-zA-Z0-9_\\-:.]*)\\b" + }, + { + "name": "string.quoted.double.html", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.html" } + }, + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.html" } + }, + "patterns": [ + { + "name": "constant.character.entity.html", + "match": "&[a-zA-Z0-9#]+;" + } + ] + }, + { + "name": "string.quoted.single.html", + "begin": "'", + "end": "'", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.html" } + }, + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.html" } + }, + "patterns": [ + { + "name": "constant.character.entity.html", + "match": "&[a-zA-Z0-9#]+;" + } + ] + } + ] + }, + "comments": { + "patterns": [ + { + "name": "comment.block.html", + "begin": "", + "captures": { + "0": { "name": "punctuation.definition.comment.html" } + } + } + ] + }, + "entities": { + "patterns": [ + { + "name": "constant.character.entity.html", + "match": "&[a-zA-Z0-9#]+;" + } + ] + }, + "embeddedCode": { + "patterns": [ + { + "name": "meta.embedded.script.html", + "begin": "(]*?>)", + "beginCaptures": { + "1": { "name": "entity.name.tag.script.html" }, + "2": { "name": "punctuation.definition.tag.html" } + }, + "end": "()", + "endCaptures": { + "1": { "name": "entity.name.tag.script.html" } + }, + "patterns": [ + { + "include": "source.js" + } + ] + }, + { + "name": "meta.embedded.style.html", + "begin": "(]*?>)", + "beginCaptures": { + "1": { "name": "entity.name.tag.style.html" }, + "2": { "name": "punctuation.definition.tag.html" } + }, + "end": "()", + "endCaptures": { + "1": { "name": "entity.name.tag.style.html" } + }, + "patterns": [ + { + "include": "source.css" + } + ] + } + ] + } + } +} diff --git a/grammars/java.json b/grammars/java.json new file mode 100644 index 0000000..0874fad --- /dev/null +++ b/grammars/java.json @@ -0,0 +1,142 @@ +{ + "name": "Java", + "version": "1.0.0", + "fileTypes": ["java"], + "scopeName": "source.java", + + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#constants" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#types" + }, + { + "include": "#annotations" + } + ], + + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.block.java", + "begin": "/\\*", + "end": "\\*/" + }, + { + "name": "comment.block.documentation.java", + "begin": "/\\*\\*", + "end": "\\*/", + "patterns": [ + { + "name": "entity.name.tag.documentation.java", + "match": "@[a-zA-Z]+" + } + ] + }, + { + "name": "comment.line.double-slash.java", + "match": "//.*$" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.java", + "match": "\\b(if|else|for|while|do|switch|case|break|continue|return|try|catch|finally|throw|assert)\\b" + }, + { + "name": "keyword.declaration.java", + "match": "\\b(public|private|protected|static|final|abstract|synchronized|volatile|transient|native|strictfp)\\b" + }, + { + "name": "keyword.operator.java", + "match": "\\b(new|instanceof)\\b" + }, + { + "name": "keyword.other.java", + "match": "\\b(import|package|class|interface|enum|extends|implements|throws)\\b" + } + ] + }, + "constants": { + "patterns": [ + { + "name": "constant.language.java", + "match": "\\b(true|false|null)\\b" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.java", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.java", + "match": "\\\\." + } + ] + }, + { + "name": "string.quoted.single.java", + "begin": "'", + "end": "'", + "patterns": [ + { + "name": "constant.character.escape.java", + "match": "\\\\." + } + ] + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.java", + "match": "\\b([+-]?\\d+(\\.\\d+)?([eE][+-]?\\d+)?[fFdDlL]?)\\b" + } + ] + }, + "types": { + "patterns": [ + { + "name": "support.type.primitive.java", + "match": "\\b(byte|short|int|long|float|double|boolean|char|void)\\b" + }, + { + "name": "entity.name.type.class.java", + "match": "\\b([A-Z][a-zA-Z0-9_]*)\\b" + } + ] + }, + "annotations": { + "patterns": [ + { + "name": "meta.annotation.java", + "match": "@[a-zA-Z][a-zA-Z0-9_]*" + } + ] + } + } +} diff --git a/grammars/javascript.json b/grammars/javascript.json new file mode 100644 index 0000000..065e149 --- /dev/null +++ b/grammars/javascript.json @@ -0,0 +1,173 @@ +{ + "name": "JavaScript", + "version": "1.0.0", + "fileTypes": ["js", "mjs", "cjs"], + "scopeName": "source.js", + + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + + "patterns": [ + { + "name": "meta.preprocessor.script.js", + "match": "^(#!.*)$" + }, + { + "name": "meta.import-export.js", + "begin": "\\b(import|export)\\b", + "beginCaptures": { + "0": { + "name": "keyword.control.import.js" + } + }, + "end": ";", + "endCaptures": { + "0": { + "name": "punctuation.terminator.js" + } + }, + "patterns": [ + { + "include": "#strings" + }, + { + "include": "#comments" + }, + { + "name": "keyword.control.import.js", + "match": "\\b(as|from)\\b" + } + ] + }, + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#constants-and-special-vars" + }, + { + "include": "#operators" + }, + { + "include": "#strings" + } + ], + + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.block.js", + "begin": "/\\*", + "end": "\\*/" + }, + { + "name": "comment.line.double-slash.js", + "match": "//.*$" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.js", + "match": "\\b(if|else|for|while|do|switch|case|default|break|continue|return|throw|try|catch|finally)\\b" + }, + { + "name": "keyword.operator.js", + "match": "\\b(instanceof|typeof|new|delete|in|void)\\b" + }, + { + "name": "storage.type.js", + "match": "\\b(var|let|const|function|class|extends)\\b" + }, + { + "name": "keyword.declaration.js", + "match": "\\b(export|import|default)\\b" + } + ] + }, + "constants-and-special-vars": { + "patterns": [ + { + "name": "constant.language.js", + "match": "\\b(true|false|null|undefined|NaN|Infinity)\\b" + }, + { + "name": "constant.numeric.js", + "match": "\\b(0x[0-9A-Fa-f]+|[0-9]+\\.?[0-9]*(e[+-]?[0-9]+)?)\\b" + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.assignment.js", + "match": "(=|\\+=|-=|\\*=|/=|%=|\\|=|&=|\\^=|<<=|>>=|>>>=)" + }, + { + "name": "keyword.operator.comparison.js", + "match": "(==|!=|===|!==|<|<=|>|>=)" + }, + { + "name": "keyword.operator.logical.js", + "match": "(&&|\\|\\||!)" + }, + { + "name": "keyword.operator.arithmetic.js", + "match": "(-|\\+|\\*|/|%)" + }, + { + "name": "keyword.operator.bitwise.js", + "match": "(\\||&|\\^|~|<<|>>|>>>)" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.js", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "include": "#string-interpolation" + } + ] + }, + { + "name": "string.quoted.single.js", + "begin": "'", + "end": "'", + "patterns": [ + { + "include": "#string-interpolation" + } + ] + }, + { + "name": "string.template.js", + "begin": "`", + "end": "`", + "patterns": [ + { + "include": "#string-interpolation" + } + ] + } + ] + }, + "string-interpolation": { + "patterns": [ + { + "name": "variable.parameter.js", + "begin": "\\$\\{", + "end": "\\}" + } + ] + } + } +} diff --git a/grammars/kotlin.json b/grammars/kotlin.json new file mode 100644 index 0000000..a46d504 --- /dev/null +++ b/grammars/kotlin.json @@ -0,0 +1,160 @@ +{ + "name": "Kotlin", + "version": "1.0.0", + "fileTypes": ["kt", "kts"], + "scopeName": "source.kotlin", + + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#strings" + }, + { + "include": "#numbers" + }, + { + "include": "#functions" + }, + { + "include": "#annotations" + }, + { + "include": "#types" + }, + { + "include": "#operators" + } + ], + + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.block.kotlin", + "begin": "/\\*", + "end": "\\*/" + }, + { + "name": "comment.block.documentation.kotlin", + "begin": "/\\*\\*", + "end": "\\*/", + "patterns": [ + { + "name": "entity.name.tag.documentation.kotlin", + "match": "@[a-zA-Z]+" + } + ] + }, + { + "name": "comment.line.double-slash.kotlin", + "match": "//.*$" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.kotlin", + "match": "\\b(if|else|for|while|do|when|try|catch|finally|throw|break|continue|return)\\b" + }, + { + "name": "keyword.declaration.kotlin", + "match": "\\b(fun|val|var|class|object|interface|enum|sealed|companion|inline|data|lateinit|init|constructor)\\b" + }, + { + "name": "keyword.modifier.kotlin", + "match": "\\b(public|private|protected|internal|abstract|open|final|override|const|tailrec|suspend|external|annotation)\\b" + }, + { + "name": "keyword.operator.kotlin", + "match": "\\b(as|is|in|out)\\b" + }, + { + "name": "keyword.other.kotlin", + "match": "\\b(import|package|typealias)\\b" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.kotlin", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.kotlin", + "match": "\\\\." + }, + { + "name": "string.template.expression.kotlin", + "begin": "\\$\\{", + "end": "\\}" + }, + { + "name": "string.template.simple.kotlin", + "match": "\\$[a-zA-Z_][a-zA-Z0-9_]*" + } + ] + }, + { + "name": "string.quoted.triple.kotlin", + "begin": "\"\"\"", + "end": "\"\"\"" + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.kotlin", + "match": "\\b([+-]?\\d+(\\.\\d+)?([eE][+-]?\\d+)?[fFbBlL]?)\\b" + } + ] + }, + "functions": { + "patterns": [ + { + "name": "entity.name.function.kotlin", + "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?=\\()" + } + ] + }, + "annotations": { + "patterns": [ + { + "name": "meta.annotation.kotlin", + "match": "@[a-zA-Z][a-zA-Z0-9_]*" + } + ] + }, + "types": { + "patterns": [ + { + "name": "support.type.primitive.kotlin", + "match": "\\b(Byte|Short|Int|Long|Float|Double|Boolean|Char|Unit|String|Any|Nothing)\\b" + }, + { + "name": "entity.name.type.class.kotlin", + "match": "\\b([A-Z][a-zA-Z0-9_]*)\\b" + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.kotlin", + "match": "(\\+|-|\\*|/|%|==|!=|<=|>=|&&|\\|\\||!|\\.|::|\\+=|-=|\\*=|/=|%=)" + } + ] + } + } +} diff --git a/grammars/python.json b/grammars/python.json new file mode 100644 index 0000000..85dd5f0 --- /dev/null +++ b/grammars/python.json @@ -0,0 +1,98 @@ +{ + "name": "Python", + "version": "1.0.0", + "fileTypes": ["py"], + "scopeName": "source.python", + "foldingStartMarker": "\\b(?:def|class)\\s*[^:]*:\\s*$", + "foldingStopMarker": "^\\s*\\}", + "patterns": [ + { "include": "#comments" }, + { "include": "#keywords" }, + { "include": "#constants-and-special-vars" }, + { "include": "#operators" }, + { "include": "#strings" } + ], + "repository": { + "comments": { + "patterns": [ + { "name": "comment.line.hash.python", "match": "#.*$" }, + { "name": "comment.block.python", "begin": "'''", "end": "'''" }, + { "name": "comment.block.python", "begin": "\"\"\"", "end": "\"\"\"" } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.python", + "match": "\\b(?:if|else|while|for|in|break|continue|return)\\b" + }, + { + "name": "keyword.operator.logical.python", + "match": "\\b(?:and|or|not)\\b" + }, + { "name": "keyword.operator.assignment.python", "match": "=" }, + { "name": "storage.modifier.python", "match": "\\b(?:def|class)\\b" } + ] + }, + "constants-and-special-vars": { + "patterns": [ + { + "name": "constant.language.python", + "match": "\\b(?:True|False|None)\\b" + }, + { "name": "variable.language.python", "match": "\\b(?:self)\\b" }, + { + "name": "constant.numeric.python", + "match": "\\b(?:\\d+\\.?\\d*|\\.\\d+)\\b" + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.arithmetic.python", + "match": "\\b(?:\\+|-|\\*|/|%|//)\\b" + }, + { + "name": "keyword.operator.comparison.python", + "match": "\\b(?:==|!=|<|<=|>|>=)\\b" + }, + { + "name": "keyword.operator.logical.python", + "match": "\\b(?:and|or|not)\\b" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.triple.double.python", + "begin": "\"\"\"", + "end": "\"\"\"" + }, + { + "name": "string.quoted.triple.single.python", + "begin": "'''", + "end": "'''" + }, + { + "name": "string.quoted.double.python", + "begin": "\"", + "end": "\"", + "patterns": [{ "include": "#string-escape" }] + }, + { + "name": "string.quoted.single.python", + "begin": "'", + "end": "'", + "patterns": [{ "include": "#string-escape" }] + } + ] + }, + "string-escape": { + "patterns": [ + { "name": "constant.character.escape.python", "match": "\\\\[\"']" } + ] + } + } +} diff --git a/grammars/rust.json b/grammars/rust.json new file mode 100644 index 0000000..f045cc5 --- /dev/null +++ b/grammars/rust.json @@ -0,0 +1,148 @@ +{ + "name": "Rust", + "version": "1.0.0", + "fileTypes": ["rs"], + "scopeName": "source.rust", + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + "patterns": [ + { + "name": "meta.preprocessor.rust", + "match": "^(#!.*)$" + }, + { + "name": "meta.use-declaration.rust", + "begin": "^\\s*use\\b", + "end": ";", + "patterns": [ + { + "include": "#strings" + }, + { + "name": "keyword.control.rust", + "match": "\\b(as)\\b" + } + ] + }, + { + "include": "#comments" + }, + { + "include": "#punctuation" + }, + { + "include": "#keywords" + }, + { + "include": "#constants" + }, + { + "include": "#operators" + }, + { + "include": "#strings" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.double-slash.rust", + "match": "//.*$" + }, + { + "name": "comment.block.rust", + "begin": "/\\*", + "end": "\\*/" + } + ] + }, + "punctuation": { + "patterns": [ + { + "name": "punctuation.semi-colon.rust", + "match": ";" + }, + { + "name": "punctuation.comma.rust", + "match": "," + }, + { + "name": "punctuation.bracket.rust", + "match": "[\\[\\]{}()]" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.rust", + "match": "\\b(if|else|match|loop|while|for|break|continue|return|yield)\\b" + }, + { + "name": "keyword.declaration.rust", + "match": "\\b(let|const|static|mut|ref|fn|struct|enum|impl|trait|type|mod|use|crate|extern|pub|self|super)\\b" + }, + { + "name": "storage.modifier.rust", + "match": "\\b(async|move|unsafe|dyn)\\b" + } + ] + }, + "constants": { + "patterns": [ + { + "name": "constant.language.rust", + "match": "\\b(true|false|null)\\b" + }, + { + "name": "constant.numeric.rust", + "match": "\\b\\d+(\\.\\d+)?([eE][+-]?\\d+)?\\b" + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.rust", + "match": "(\\+=|\\-=|\\*=|/=|%=|&=|\\|=|\\^=|<<=|>>=|==|!=|<=|>=|&&|\\|\\||!|\\-|\\+|\\*|/|%|&|\\||\\^|<<|>>)" + }, + { + "name": "keyword.operator.assignment.rust", + "match": "=" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.rust", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.rust", + "match": "\\\\." + } + ] + }, + { + "name": "string.quoted.raw.rust", + "begin": "r#\"", + "end": "\"#" + }, + { + "name": "string.quoted.char.rust", + "begin": "'", + "end": "'", + "patterns": [ + { + "name": "constant.character.escape.rust", + "match": "\\\\." + } + ] + } + ] + } + } +} diff --git a/grammars/swift.json b/grammars/swift.json new file mode 100644 index 0000000..196cb16 --- /dev/null +++ b/grammars/swift.json @@ -0,0 +1,163 @@ +{ + "name": "Swift", + "version": "1.0.0", + "fileTypes": ["swift"], + "scopeName": "source.swift", + + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + + "patterns": [ + { + "name": "meta.declaration.swift", + "begin": "\\b(import|class|struct|protocol|extension|enum|func|let|var|typealias|init|deinit)\\b", + "beginCaptures": { + "0": { + "name": "keyword.other.declaration.swift" + } + }, + "end": "(?=\\{)|;", + "patterns": [ + { + "include": "#type-annotations" + }, + { + "include": "#comments" + } + ] + }, + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#constants-and-literals" + }, + { + "include": "#operators" + }, + { + "include": "#strings" + } + ], + + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.block.documentation.swift", + "begin": "/\\*\\*", + "end": "\\*/", + "patterns": [ + { + "include": "#swiftdoc" + } + ] + }, + { + "name": "comment.block.swift", + "begin": "/\\*", + "end": "\\*/" + }, + { + "name": "comment.line.double-slash.swift", + "match": "//.*$" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.swift", + "match": "\\b(if|else|for|while|switch|case|break|continue|fallthrough|return|throw|defer|guard|repeat|do|catch|try)\\b" + }, + { + "name": "keyword.control.async.swift", + "match": "\\b(async|await)\\b" + }, + { + "name": "keyword.declaration.swift", + "match": "\\b(import|class|struct|enum|protocol|extension|func|var|let|typealias|init|deinit|subscript)\\b" + }, + { + "name": "keyword.access.swift", + "match": "\\b(public|private|internal|fileprivate|open)\\b" + }, + { + "name": "keyword.other.swift", + "match": "\\b(static|mutating|nonmutating|override|final|required|lazy|weak|unowned|dynamic|optional)\\b" + } + ] + }, + "constants-and-literals": { + "patterns": [ + { + "name": "constant.language.swift", + "match": "\\b(true|false|nil)\\b" + }, + { + "name": "constant.numeric.swift", + "match": "\\b([0-9]+(\\.[0-9]+)?)\\b" + }, + { + "name": "constant.character.escape.swift", + "match": "\\\\." + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.assignment.swift", + "match": "(=)" + }, + { + "name": "keyword.operator.arithmetic.swift", + "match": "(\\+|\\-|\\*|\\/|%)" + }, + { + "name": "keyword.operator.comparison.swift", + "match": "(==|!=|<=?|>=?)" + }, + { + "name": "keyword.operator.logical.swift", + "match": "(\\!|&&|\\|\\|)" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.swift", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "string.interpolated.swift", + "begin": "\\\\\\(", + "end": "\\)" + } + ] + }, + { + "name": "string.quoted.single.swift", + "match": "'(?:\\\\.|[^'\\\\])*'" + } + ] + }, + "type-annotations": { + "patterns": [ + { + "match": ":\\s*([A-Z][a-zA-Z0-9]*)", + "captures": { + "1": { + "name": "entity.name.type.swift" + } + } + } + ] + } + } +} diff --git a/grammars/typescript.json b/grammars/typescript.json new file mode 100644 index 0000000..7cda738 --- /dev/null +++ b/grammars/typescript.json @@ -0,0 +1,196 @@ +{ + "name": "TypeScript", + "version": "1.0.0", + "fileTypes": ["ts", "tsx"], + "scopeName": "source.ts", + + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + + "patterns": [ + { + "name": "meta.declaration.typescript", + "begin": "\\b(import|export|class|interface|enum|type|function|var|let|const|namespace|module)\\b", + "beginCaptures": { + "0": { + "name": "keyword.declaration.typescript" + } + }, + "end": "(\\{|;|$)", + "patterns": [ + { + "include": "#type-annotations" + }, + { + "include": "#comments" + } + ] + }, + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#constants-and-literals" + }, + { + "include": "#operators" + }, + { + "include": "#strings" + }, + { + "include": "#templates" + } + ], + + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.block.documentation.typescript", + "begin": "/\\*\\*", + "end": "\\*/", + "patterns": [ + { + "include": "#tsdoc" + } + ] + }, + { + "name": "comment.block.typescript", + "begin": "/\\*", + "end": "\\*/" + }, + { + "name": "comment.line.double-slash.typescript", + "match": "//.*$" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.typescript", + "match": "\\b(if|else|for|while|do|switch|case|break|continue|return|try|catch|finally|throw|yield|await)\\b" + }, + { + "name": "keyword.control.async.typescript", + "match": "\\b(async|await)\\b" + }, + { + "name": "keyword.declaration.typescript", + "match": "\\b(class|interface|enum|type|function|namespace|module|abstract|extends|implements)\\b" + }, + { + "name": "keyword.other.typescript", + "match": "\\b(public|private|protected|static|readonly|declare|const|let|var|new|delete|in|of|instanceof|typeof|void)\\b" + } + ] + }, + "constants-and-literals": { + "patterns": [ + { + "name": "constant.language.typescript", + "match": "\\b(true|false|null|undefined|NaN|Infinity)\\b" + }, + { + "name": "constant.numeric.typescript", + "match": "\\b(-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?)\\b" + }, + { + "name": "constant.character.escape.typescript", + "match": "\\\\." + } + ] + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.assignment.typescript", + "match": "(=|\\+=|-=|\\*=|/=|%=|&&=|\\|\\|=|\\^=|<<=|>>=|>>>=)" + }, + { + "name": "keyword.operator.arithmetic.typescript", + "match": "(\\+|-|\\*|\\/|%)" + }, + { + "name": "keyword.operator.comparison.typescript", + "match": "(==|===|!=|!==|<=?|>=?)" + }, + { + "name": "keyword.operator.logical.typescript", + "match": "(\\!|&&|\\|\\|)" + }, + { + "name": "keyword.operator.bitwise.typescript", + "match": "(\\&|\\||\\^|<<|>>|>>>)" + }, + { + "name": "keyword.operator.ternary.typescript", + "match": "(\\?|:)" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.typescript", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.typescript", + "match": "\\\\." + } + ] + }, + { + "name": "string.quoted.single.typescript", + "begin": "'", + "end": "'", + "patterns": [ + { + "name": "constant.character.escape.typescript", + "match": "\\\\." + } + ] + } + ] + }, + "templates": { + "patterns": [ + { + "name": "string.quoted.template.typescript", + "begin": "`", + "end": "`", + "patterns": [ + { + "name": "string.interpolated.typescript", + "begin": "\\$\\{", + "end": "\\}" + }, + { + "name": "constant.character.escape.typescript", + "match": "\\\\." + } + ] + } + ] + }, + "type-annotations": { + "patterns": [ + { + "match": ":\\s*([a-zA-Z_$][\\w$]*)", + "captures": { + "1": { + "name": "entity.name.type.typescript" + } + } + } + ] + } + } +}