Clang-format setting that not touches nested structs

Viewed 46

I'm using VisualStudioCode and the C++ extension. In a C language file I have some nested structs like

struct NewMenu appMenu[] =
{
  { NM_TITLE,  "Project",                      0 , 0, 0, 0 },
  {  NM_ITEM,  "Open..",                      "O", 0, 0, (APTR)MID_ProjectOpenAnim },
  {  NM_ITEM,  "Save",                         0 , 0, 0, (APTR)MID_ProjectSave },
  {  NM_ITEM,  "Save as..",                   "S", 0, 0, (APTR)MID_ProjectSaveAs },
  {  NM_ITEM,  "Export",                       0,  0, 0, 0 },
  {    NM_SUB, "IFF ILBM Sheet",               0,  0, 0, (APTR)MID_ProjectExportToIlbm },
  {    NM_SUB, "AMOS ABK",                     0,  0, 0, (APTR)MID_ProjectExportToAbk },
  {  NM_ITEM,  NM_BARLABEL,                    0 , 0, 0, 0, },
  {  NM_ITEM,  "About",                        0 , 0, 0, (APTR)MID_ProjectAbout },
  {  NM_ITEM,  NM_BARLABEL,                    0 , 0, 0, 0, },
  {  NM_ITEM,  "Quit",                        "Q", 0, 0, (APTR)MID_ProjectQuit },
  { NM_TITLE,  "Anim sheet",                   0 , 0, 0, 0, },
  {  NM_ITEM,  "Append..",                     0 , 0, 0, (APTR)MID_SheetAppend },
  {  NM_ITEM,  "Fit to raster (horiz.)",       0 , 0, 0, (APTR)MID_SheetFitToRaster },
  { NM_TITLE,  "Tools",                        0 , 0, 0, 0, },
  {  NM_ITEM,  "Print frame mask (planar)",   "P", 0, 0, (APTR)MID_ToolsPrintFrameMask },
  {  NM_ITEM,  "Print frame mask (interl.)",  "I", 0, 0, (APTR)MID_ToolsPrintInterleavedFrameMask },
  {  NM_ITEM,  "Print mask of whole picture", "M", 0, 0, (APTR)MID_ToolsPrintFullMask },
  { NM_END,    0,                              0 , 0, 0, 0, },
};

After running clang-format on the file the this struct looks like

struct NewMenu appMenu[] = {
  {NM_TITLE, "Project", 0, 0, 0, 0},
  {NM_ITEM, "Open..", "O", 0, 0, (APTR)MID_ProjectOpenAnim},
  {NM_ITEM, "Save", 0, 0, 0, (APTR)MID_ProjectSave},
  {NM_ITEM, "Save as..", "S", 0, 0, (APTR)MID_ProjectSaveAs},
  {NM_ITEM, "Export", 0, 0, 0, 0},
  {NM_SUB, "IFF ILBM Sheet", 0, 0, 0, (APTR)MID_ProjectExportToIlbm},
  {NM_SUB, "AMOS ABK", 0, 0, 0, (APTR)MID_ProjectExportToAbk},
  {
    NM_ITEM,
    NM_BARLABEL,
    0,
    0,
    0,
    0,
  },
  {NM_ITEM, "About", 0, 0, 0, (APTR)MID_ProjectAbout},
  {
    NM_ITEM,
    NM_BARLABEL,
    0,
    0,
    0,
    0,
  },
  
  ...
  
}

How can I change the .clang-format file to leave nested structs untouched?

Edit: I wasn't able to put my .clang-format file here because that would've resulted in a question that mainly consists of code which isn't allowed by Stackoverflow.

0 Answers
Related