Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly format the file? #525

Closed
apoorv569 opened this issue Jan 31, 2024 · 2 comments
Closed

How to properly format the file? #525

apoorv569 opened this issue Jan 31, 2024 · 2 comments

Comments

@apoorv569
Copy link

apoorv569 commented Jan 31, 2024

This this is my PrettyConfig,

        PrettyConfig::new()
            .depth_limit(2)
            .separate_tuple_members(true)
            .enumerate_arrays(true)
            .struct_names(true)

and my ron generated config looks like this,

ThemeConfig(
    enable_theming: false,
    waveform_config: WaveformConfig(
        color: Color32((254, 150, 71, 255)),
    ),
    widget_config: WidgetConfig(
        button: ButtonConfig(color: Color32((60, 60, 60, 255)), rounding: Rounding(nw: 2.0, ne: 2.0, sw: 2.0, se: 2.0), padding: Vec2(x: 4.0, y: 1.0)),
        text: TextConfig(color: Color32((140, 140, 140, 255)), warn_color: Color32((255, 143, 0, 255)), error_color: Color32((255, 0, 0, 255))),
        panel: PanelConfig(panel_bg_color: Color32((27, 27, 27, 255)), faint_bg_color: Color32((5, 5, 5, 0))),
        extreme_bg_color: Color32((10, 10, 10, 255)),
    ),
    widget_shape: WidgetShape(
        shape: Circle,
    ),
)

I want for each field to be on newline (indented) like the struct fields appear with rust syntax.

if I change depth to 4, its somewhat what I want,

ThemeConfig(
    enable_theming: false,
    waveform_config: WaveformConfig(
        color: Color32((
            254,
            150,
            71,
            255,
        )),
    ),
    widget_config: WidgetConfig(
        button: ButtonConfig(
            color: Color32((
                60,
                60,
                60,
                255,
            )),
            rounding: Rounding(
                nw: 2.0,
                ne: 2.0,
                sw: 2.0,
                se: 2.0,
            ),
            padding: Vec2(
                x: 4.0,
                y: 1.0,
            ),
        ),
        text: TextConfig(
            color: Color32((
                140,
                140,
                140,
                255,
            )),
            warn_color: Color32((
                255,
                143,
                0,
                255,
            )),
            error_color: Color32((
                255,
                0,
                0,
                255,
            )),
        ),
        panel: PanelConfig(
            panel_bg_color: Color32((
                27,
                27,
                27,
                255,
            )),
            faint_bg_color: Color32((
                5,
                5,
                5,
                0,
            )),
        ),
        extreme_bg_color: Color32((
            10,
            10,
            10,
            255,
        )),
    ),
    widget_shape: WidgetShape(
        shape: Circle,
    ),
)

but I don't want each arg to be on a newline.. I want something more like this,

ThemeConfig(
    enable_theming: false,
    waveform_config: WaveformConfig(
        color: Color32((254, 150, 71, 255,)),
    ),
    widget_config: WidgetConfig(
        button: ButtonConfig(
            color: Color32((60, 60, 60, 255,)),
            rounding: Rounding(nw: 2.0, ne: 2.0, sw: 2.0, se: 2.0,),
            padding: Vec2(x: 4.0, y: 1.0,),),
        text: TextConfig(
            color: Color32((140, 140, 140, 255,)),
            warn_color: Color32((255, 143, 0, 255,)),
            error_color: Color32((255, 0, 0, 255,)),
        ),
        panel: PanelConfig(
            panel_bg_color: Color32((27, 27, 27, 255,)),
            faint_bg_color: Color32((5, 5, 5, 0,)),
        ),
        extreme_bg_color: Color32((10, 10, 10, 255,)),
    ),
    widget_shape: WidgetShape(
        shape: Circle,
    ),
)

Also is it possible to add comments and newlines manually?

@juntyr
Copy link
Member

juntyr commented Jan 31, 2024

At the moment, the best you can achieve is (probably) to set your depth limit to 3 and to disable the separate_tuple_members option. Unfortunately, ron does not offer more precise control over the formatting.

While a magic wrapper type could be added that sets a custom depth limit for a subtree of the RON document, this would probably be too specific to RON (unless there is already such a type in a general crate that other formats support and for which RON could implement support).

@apoorv569
Copy link
Author

apoorv569 commented Jan 31, 2024

At the moment, the best you can achieve is (probably) to set your depth limit to 3 and to disable the separate_tuple_members option. Unfortunately, ron does not offer more precise control over the formatting.

This works! Thanks!

While a magic wrapper type could be added that sets a custom depth limit for a subtree of the RON document, this would probably be too specific to RON (unless there is already such a type in a general crate that other formats support and for which RON could implement support).

That would be nice to have though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants