Reputation: 1867
Using clang-format 17 with the following .clang-format
file:
# other languages ...
---
Language: "Proto"
BasedOnStyle: Google
UseTab: Never
TabWidth: 4
LineEnding: LF
InsertNewlineAtEOF: true
ColumnLimit: 120
IndentWidth: 4
ContinuationIndentWidth: 4
BreakBeforeBraces: Allman
AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
AlignTrailingComments: true
SpacesBeforeTrailingComments: 1
...
I get the following:
message AssignUserTickets
{
int64 user_id = 1;
int64 ticket_type_id = 2;
optional google.protobuf.Timestamp expires_at = 3;
int32 num_tickets = 4;
}
When the expected result is:
message AssignUserTickets
{
int64 user_id = 1;
int64 ticket_type_id = 2;
optional google.protobuf.Timestamp expires_at = 3;
int32 num_tickets = 4;
}
Removing the optional
keyword gives the desired formatting, but we don't want to do that1.
How can I achieve the desired formatting without changing the message definition?
1 I know that optional
is not required in this case, since Timestamp
is a Message
and therefore has explicit presence by default, but we still want to use it for consistency with simple types and as documentation to the user of the protocol that omitting it has specific meaning.
Upvotes: 0
Views: 244