From e928fca39094c53a2d34618dd68699d2e003b42c Mon Sep 17 00:00:00 2001 From: Nicolas BACQUEY Date: Wed, 22 Feb 2023 16:07:45 +0100 Subject: [PATCH] Format our query files with Topiary --- languages/bash.scm | 35 +++++++++++------- languages/nickel.scm | 2 +- languages/ocaml.scm | 85 +++++++++++++++++++++++--------------------- languages/rust.scm | 4 +-- languages/toml.scm | 4 +-- 5 files changed, 73 insertions(+), 57 deletions(-) diff --git a/languages/bash.scm b/languages/bash.scm index 1189a988..01c8e714 100644 --- a/languages/bash.scm +++ b/languages/bash.scm @@ -276,35 +276,43 @@ ) (if_statement - . _ "then" + . + _ + "then" [(command) (list) (pipeline) (compound_statement) (subshell) (redirected_statement) (variable_assignment)] @append_hardline . "\n" ) (elif_clause - . _ "then" + . + _ + "then" [(command) (list) (pipeline) (compound_statement) (subshell) (redirected_statement) (variable_assignment)] @append_hardline . "\n" ) (else_clause - . "else" + . + "else" [(command) (list) (pipeline) (compound_statement) (subshell) (redirected_statement) (variable_assignment)] @append_hardline . "\n" ) (case_item - . _ ")" + . + _ + ")" [(command) (list) (pipeline) (compound_statement) (subshell) (redirected_statement) (variable_assignment)] @append_hardline . "\n" ) (do_group - . "do" + . + "do" [(command) (list) (pipeline) (compound_statement) (subshell) (redirected_statement) (variable_assignment)] @append_hardline . "\n" @@ -324,7 +332,7 @@ ) (pipeline - [(_) "|" "|&" ] @append_space + [(_) "|" "|&"] @append_space . _ ) @@ -418,7 +426,8 @@ [ (if_statement) (elif_clause) -] "then" @append_hardline @append_indent_start +] +"then" @append_hardline @append_indent_start ; New line after "else" and start indent block (else_clause @@ -442,7 +451,6 @@ ";"* @do_nothing . "then" @prepend_delimiter @prepend_space - (#delimiter! ";") ) @@ -459,8 +467,8 @@ ; in the context of a (test_command); it does work in other contexts ; See https://github.com/tweag/topiary/pull/155#issuecomment-1364143677 (binary_expression - left: _ @append_space - right: _ @prepend_space + left: _ @append_space + right: _ @prepend_space ) ;; Case Statements @@ -468,7 +476,11 @@ ; Indentation block between the "in" and the "esac" (case_statement . - "case" . _ . "in" @append_hardline @append_indent_start + "case" + . + _ + . + "in" @append_hardline @append_indent_start _ "esac" @prepend_hardline @prepend_indent_end . @@ -523,7 +535,6 @@ ";"* @do_nothing . (do_group) @prepend_delimiter @prepend_space - (#delimiter! ";") ) diff --git a/languages/nickel.scm b/languages/nickel.scm index 3280c05c..40b6c58c 100644 --- a/languages/nickel.scm +++ b/languages/nickel.scm @@ -20,7 +20,7 @@ ( (comment) @append_input_softline . - [ "," ";" ]* @do_nothing + ["," ";"]* @do_nothing ) ; Surround spaces diff --git a/languages/ocaml.scm b/languages/ocaml.scm index 33fbdb0e..0daeb032 100644 --- a/languages/ocaml.scm +++ b/languages/ocaml.scm @@ -45,9 +45,10 @@ (exception_definition) (external) (floating_attribute) - ; equivalence class - (include_module) - (include_module_type) + ; start equivalence class + (include_module) + (include_module_type) + ; end equivalence class (inheritance_definition) (inheritance_specification) (instance_variable_definition) @@ -98,9 +99,10 @@ ; Append line break after module include, except if it's alone in a single-lined struct ( [ - ; equivalence class + ; start equivalence class (include_module) (include_module_type) + ; end equivalence class ] @append_hardline . "end"? @do_nothing @@ -109,9 +111,10 @@ "struct" . [ - ; equivalence class + ; start equivalence class (include_module) (include_module_type) + ; end equivalence class ] @append_spaced_softline . "end" @@ -203,28 +206,28 @@ ; Those keywords are not expected to come right after an open parenthesis. [ - "as" - "constraint" - "do" - "done" - "downto" - "else" - "in" - "nonrec" - "of" - "rec" - "then" - "to" - "virtual" - "when" - "with" - "|" - "->" - "<-" - "+=" - ":=" - ":>" - "::" + "as" + "constraint" + "do" + "done" + "downto" + "else" + "in" + "nonrec" + "of" + "rec" + "then" + "to" + "virtual" + "when" + "with" + "|" + "->" + "<-" + "+=" + ":=" + ":>" + "::" ] @prepend_space ; let-like and and-like operators are only followed by a closing parenthesis @@ -431,10 +434,11 @@ (field_get_expression) (hash_type) (labeled_argument) - ; equivalence class - (extended_module_path) - (module_path) - (module_type_path) + ; start equivalence class + (extended_module_path) + (module_path) + (module_type_path) + ; end equivalence class (number) (parenthesized_expression) (parenthesized_pattern) @@ -477,10 +481,11 @@ (field_get_expression) (local_open_pattern) (labeled_argument) - ; equivalence class - (extended_module_path) - (module_path) - (module_type_path) + ; start equivalence class + (extended_module_path) + (module_path) + (module_type_path) + ; end equivalence class (number) (parenthesized_expression) (parenthesized_pattern) @@ -522,7 +527,6 @@ ] @append_space ) - ; Some kinds of colons should have a space in front. ( [ @@ -820,9 +824,10 @@ [ (value_specification) (type_definition) - ; equivalence class - (include_module) - (include_module_type) + ; start equivalence class + (include_module) + (include_module_type) + ; end equivalence class ] @append_spaced_softline ) @@ -1497,5 +1502,5 @@ ( (comment) @append_input_softline . - [ "," ";" ]* @do_nothing + ["," ";"]* @do_nothing ) diff --git a/languages/rust.scm b/languages/rust.scm index 124c718e..51d6f439 100644 --- a/languages/rust.scm +++ b/languages/rust.scm @@ -66,7 +66,7 @@ ( (block_comment) @append_input_softline . - [ "," ";" ]* @do_nothing + ["," ";"]* @do_nothing ) ; Append line breaks. If there is a comment following, we don't add anything, @@ -101,7 +101,7 @@ ";" ] @append_spaced_softline . - [ (block_comment) (line_comment) ]* @do_nothing + [(block_comment) (line_comment)]* @do_nothing ) ; Prepend softlines before dots diff --git a/languages/toml.scm b/languages/toml.scm index 6d3c021f..133aa1ad 100644 --- a/languages/toml.scm +++ b/languages/toml.scm @@ -28,13 +28,13 @@ ) (table - [ (bare_key) (dotted_key) ] + [(bare_key) (dotted_key)] . "]" @append_hardline ) (table_array_element - [ (bare_key) (dotted_key) ] + [(bare_key) (dotted_key)] . "]]" @append_hardline )