Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created new grammar files for html, css, javascript, typescript, python, java, swift, rust, and go #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -46,6 +56,7 @@ void main() async {
'sql',
'serverpod_protocol',
'json',
'python',
]);

// Load the default light theme and create a highlighter.
Expand Down Expand Up @@ -78,6 +89,16 @@ void main() async {
theme: darkTheme,
);

_pythonDarkHighlighter = Highlighter(
language: 'python',
theme: darkTheme,
);

_pythonLightHighlighter = Highlighter(
language: 'python',
theme: lightTheme,
);

runApp(const MyApp());
}

Expand Down Expand Up @@ -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,
),
),
),
],
),
);
Expand Down
70 changes: 47 additions & 23 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -223,7 +247,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
source_span:
dependency: transitive
description:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"
127 changes: 127 additions & 0 deletions grammars/css.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
]
}
}
}
Loading