fredrikekre / Runic.jl

A code formatter for Julia with rules set in stone.
MIT License
86 stars 2 forks source link

Allow multiple trailing zeros in floating point literals #14

Open fredrikekre opened 1 month ago

fredrikekre commented 1 month ago

Currently multiple trailing zeros are removed. These are sometimes used for alignment in e.g. literal arrays. Currently

 [
-    0.100 0.123
-    0.123 0.100
+    0.1 0.123
+    0.123 0.1
 ]

Perhaps this should be allowed, or atleast be disabled inside array literals?

kdheepak commented 1 month ago

With JuliaFormatter, I have had to do:

      #! format: off
      arr[:, :] .= [
      #  foobarbaz   baz    qux  
         34.36       5.89   20.28   # class_a
          0.29       0.00    0.00   # class_b
      ]
      #! format: on

Specifically, here we wanted to align the data along with the comment names.

Maybe just having a way to turn off formatting for a section would be a good feature to have?

fredrikekre commented 1 month ago

I think it should be sufficient to right justify columns and allow trailing zeros to pad with.