Я пытаюсь использовать clang-формат (в коде VS) для форматирования файлов C ++ и настройки его в соответствии с моим предпочтительным стилем. Для массива структур (для getopts) это добавляет нагрузку лишних пробелов и портит скобки:
Я добавлю свой .clang-формат в конце этого запроса
Вот как я хочу, чтобы мой массив отображался:
int main()
{
const struct option longopts[]=
{
{"log-file", required_argument, 0, LOGFILE},
{"log-level", required_argument, 0, LOGLEVEL},
{nullptr, 0, nullptr, 0}
};
}
Вот как это выглядит на самом деле:
int main()
{
const struct option longopts[] =
{
{"log-file", required_argument, 0, LOGFILE},
{"log-level", required_argument, 0, LOGLEVEL},
{nullptr, 0, nullptr, 0}};
}
Мой файл в формате .clang содержит:
BasedOnStyle: LLVM
IndentWidth: 2
AlignAfterOpenBracket: Align
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: false
IndentCaseLabels: true
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: All
PointerAlignment: Right
SortIncludes: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesInContainerLiterals: false
SpacesInAngles: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
UseTab: Never
Любые решения приветствуются!