Skip to content

Instantly share code, notes, and snippets.

@puhitaku
Forked from pganssle/.clang-format
Last active April 7, 2024 06:49
Show Gist options
  • Save puhitaku/b593f49c621bac13dea185d6717b0bcc to your computer and use it in GitHub Desktop.
Save puhitaku/b593f49c621bac13dea185d6717b0bcc to your computer and use it in GitHub Desktop.
Clang format style that approximates PEP 7
# Forked from https://gist.github.com/pganssle/0e3a5f828b4d07d79447f6ced8e7e4db
# Licensed under MIT License which the author permits to release with.
# Copyright 2024 Takumi Sueda
# Copyright 2019 Paul Ganssle
# A clang-format style that approximates Python's PEP 7
# Useful for IDE integration
BasedOnStyle: Google
AlwaysBreakAfterReturnType: AllDefinitions
AllowShortIfStatementsOnASingleLine: false
AlignAfterOpenBracket: Align
BreakBeforeBraces: Stroustrup
ColumnLimit: 79
DerivePointerAlignment: false
IndentWidth: 4
Language: Cpp
PointerAlignment: Right
ReflowComments: true
SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
TabWidth: 4
UseTab: Never
SortIncludes: false

This is a fork of Clang format style that approximates PEP 7 that has the following changes:

  • License under MIT license
    • The original author permits to do so
  • AlwaysBreakAfterReturnType is set to AllDefinitions instead of All
    • PEP 7 states that function definitions have to have a break after return type, not function declarations
  • SortIncludes is disabled since it rarely breaks the code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment