diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..0ad7134 --- /dev/null +++ b/format.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Format our code in a similar way as source/python/servo/testing_commands.py + +# Format Rust code +cargo fmt -- \ + --config unstable_features=true \ + --config binop_separator=Back \ + --config imports_granularity=Module \ + --config group_imports=StdExternalCrate + +# Format our Cargo.toml files +RUST_LOG=error taplo fmt Cargo.toml htmlshell/Cargo.toml diff --git a/htmlshell/src/vhost.rs b/htmlshell/src/vhost.rs index 7eca5a9..b56d691 100644 --- a/htmlshell/src/vhost.rs +++ b/htmlshell/src/vhost.rs @@ -50,12 +50,12 @@ fn vhost_handler(state: ServerState, request: Request) -> Option { // Currently recognized: system, shared, keyboard, homescreen, theme // TODO: don't hardcode - if app != "homescreen" - && app != "keyboard" - && app != "settings" - && app != "shared" - && app != "system" - && app != "theme" + if app != "homescreen" && + app != "keyboard" && + app != "settings" && + app != "shared" && + app != "system" && + app != "theme" { return None; } @@ -142,8 +142,7 @@ pub(crate) fn start_vhost(port: u16) { .allow_methods(Any) .allow_headers(Any); - let compression = CompressionLayer::new() - .zstd(true); + let compression = CompressionLayer::new().zstd(true); let app = Router::new() .route("/{*key}", get(get_file)) diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..0bb4f6d --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +match_block_trailing_comma = true +reorder_imports = true +style_edition = "2024" diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 0000000..a629f93 --- /dev/null +++ b/taplo.toml @@ -0,0 +1,9 @@ +# upstream files we should not format +exclude = ["third_party/**", "tests/**"] + +[formatting] +array_auto_collapse = false +array_auto_expand = false +align_comments = false +column_width = 120 +indent_string = " "