Search code examples
atom-editorcode-formattingauto-indent

Indent settings for atom-beautify with uncrustify for C/C++?


Where can the indent settings (tab width) be set for uncrustify run by the Atom package atom-beautify (on Windows)? While the package settings offer to specify a path for an uncrustify config file (separately for C and C++), I can't figure out where the default settings come from.


Solution

  • The package directory is

    • Windows: C:\Users\<user>\.atom\packages\atom-beautify\src\beautifiers\uncrustify

    Uncrustify is run via index.coffee, resulting in arguments like:

    C:\uncrustify\uncrustify.exe
    -c
    C:\Users\<user>\AppData\Local\Temp\.....cfg
    -f
    C:\Users\<user>\AppData\Local\Temp\input...
    -o
    C:\Users\<user>\AppData\Local\Temp\output...
    -l
    CPP
    

    If no path is configured in settings, it generates a temporary config via cfg.coffee. It may just look like

    indent_with_tabs = 0
    output_tab_size = 2
    input_tab_size = 2
    

    This may not be enough for uncrustify to modify the source as intended. I am not sure from where these settings originate (Atom Editor Settings?). So I just modified default.cfg in the package directory (reduce tab width to 4, spaces for tabs -- not sure which parameter did it), added that to the settings, et voila...