diff options
| author | Lucy <lucyperopero@gmail.com> | 2025-12-21 22:26:10 -0300 |
|---|---|---|
| committer | Lucy <lucyperopero@gmail.com> | 2025-12-21 22:26:10 -0300 |
| commit | 54d41706bff77584fafb6342d1af4748b3a40a11 (patch) | |
| tree | bf05eeba51a7aaa10ff56afcb3bacfb8af78ce6b /src | |
| parent | 93e39dcad2ad4aa5c07a0d2ff822b76d5f0e4ac5 (diff) | |
Add option to align struct value assignment
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/printer.odin | 4 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/odin/printer/printer.odin b/src/odin/printer/printer.odin index 698abb4..48897b8 100644 --- a/src/odin/printer/printer.odin +++ b/src/odin/printer/printer.odin @@ -55,6 +55,7 @@ Config :: struct { spaces_around_colons: bool, //Put spaces to the left of a colon as well as the right. `foo: bar` => `foo : bar` space_single_line_blocks: bool, align_struct_fields: bool, + align_struct_values: bool, } Brace_Style :: enum { @@ -91,7 +92,6 @@ Line_Suffix_Option :: enum { Indent, } - when ODIN_OS == .Windows { default_style := Config { spaces = 4, @@ -106,6 +106,7 @@ when ODIN_OS == .Windows { sort_imports = true, spaces_around_colons = false, align_struct_fields = true, + align_struct_values = true, } } else { default_style := Config { @@ -121,6 +122,7 @@ when ODIN_OS == .Windows { sort_imports = true, spaces_around_colons = false, align_struct_fields = true, + align_struct_values = true, } } diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 99af62e..40d3f83 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -798,7 +798,7 @@ visit_comp_lit_exprs :: proc(p: ^Printer, comp_lit: ast.Comp_Lit, options := Lis alignment := get_possible_comp_lit_alignment(comp_lit.elems) if value, ok := expr.derived.(^ast.Field_Value); ok && alignment > 0 { align := empty() - if should_align_comp_lit(p, comp_lit) { + if should_align_comp_lit(p, comp_lit) && p.config.align_struct_values { align = repeat_space(alignment - get_node_length(value.field)) } document = cons( |