summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--rust/format/src/main.rs20
-rw-r--r--src/keymaps/soispha/layout/keymap.h2
2 files changed, 20 insertions, 2 deletions
diff --git a/rust/format/src/main.rs b/rust/format/src/main.rs
index 3554087..9c167eb 100644
--- a/rust/format/src/main.rs
+++ b/rust/format/src/main.rs
@@ -10,12 +10,25 @@ fn main() {
         .read_to_string(&mut keymap_h)
         .expect("Failed to read keymap_h");
 
+    let mut lines: Vec<_> = keymap_h.lines().collect();
+    if lines[0] == "// clang-format off" {
+        lines.remove(0);
+    }
+    if lines.last().expect("Exists") == &"// clang-format on" {
+        lines.remove(lines.len() - 1);
+    }
+
+    keymap_h = lines.join("\n");
+
     let mut c_column_max = [0; 14];
 
     let out = calculate(&mut c_column_max, keymap_h);
     let output = calculate(&mut c_column_max, out.join("\n"));
 
-    print!("{}", output.join("\n"));
+    print!(
+        "// clang-format off\n{}\n// clang-format on",
+        output.join("\n")
+    );
 }
 
 fn calculate(c_column_max: &mut [usize; 14], keymap_h: String) -> Vec<String> {
@@ -35,7 +48,10 @@ fn calculate(c_column_max: &mut [usize; 14], keymap_h: String) -> Vec<String> {
                 }
                 '[' => {
                     // Start of a new layer
-                    assert!(c_layer.is_empty(), "No new layer, without empty");
+                    assert!(
+                        c_layer.is_empty(),
+                        "A new layer cannot start, when the current layer is not empty."
+                    );
                     output.push(format!("  {}", line));
                 }
                 ')' => {
diff --git a/src/keymaps/soispha/layout/keymap.h b/src/keymaps/soispha/layout/keymap.h
index e6697d8..e5cbfc1 100644
--- a/src/keymaps/soispha/layout/keymap.h
+++ b/src/keymaps/soispha/layout/keymap.h
@@ -1,3 +1,4 @@
+// clang-format off
 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   [0] = LAYOUT_moonlander( // Dvorak
     KK_TP,         KK_TP,              KK_TP,             KK_TP,               KK_TP,         KK_TP,        QK_BOOT,           QK_BOOT,       KK_TP,       KK_TP,        KK_TP,       KK_TP,       KK_TP,          VERSION_NUMBER,
@@ -90,3 +91,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 
   ),
 };
+// clang-format on