Language: Cpp
Standard: c++17
UseTab: ForContinuationAndIndentation
TabWidth: 4
IndentWidth: 4
ColumnLimit: 80
ContinuationIndentWidth: 4
ConstructorInitializerIndentWidth: 0
NamespaceIndentation: All
CompactNamespaces: true
FixNamespaceComments: true

IndentAccessModifiers: false
AccessModifierOffset: -4
IndentCaseLabels: true

BreakBeforeBraces: Allman
BreakBeforeBinaryOperators: All
BreakConstructorInitializers: BeforeComma
# Currentline doesn't work
# PackConstructorInitializers: CurrentLine >= 14
BreakStringLiterals: false
# Multiline does not work in clang-format 13
# AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakTemplateDeclarations: Yes
# AfterComma does not work <= 13
#BreakInheritanceList: AfterComma
BreakInheritanceList: BeforeComma
#BreakInheritanceList: false
SpaceBeforeInheritanceColon: true

#AlignAfterOpenBracket: DontAlign
AlignAfterOpenBracket: Align
PointerAlignment: Right
ReferenceAlignment: Right
SpacesInAngles: false
SpaceBeforeAssignmentOperators: true
AlignConsecutiveDeclarations: true

#Clang>=14
#AlignArrayOfStructures: Left

AllowShortIfStatementsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false

PenaltyBreakComment: 1
PenaltyBreakAssignment: 1000
AlwaysBreakBeforeMultilineStrings: true 

PenaltyReturnTypeOnItsOwnLine: 1

# SortIncludes: CaseSensitive # >= 13!
SortIncludes: true
IncludeBlocks: Regroup

IncludeCategories:
  - Regex:           '^(("|"../)core)/'
    Priority:        20
  - Regex:           '^(("|"../)analog)/'
    Priority:        21
  - Regex:           '^(("|"../)devices)/'
    Priority:        22
  - Regex:           '^(("|"../)solver)/'
    Priority:        23
  - Regex:           '^(("|"../)plib)/'
    Priority:        30
  - Regex:           '<[([:alnum:]|_).]+>'
    Priority:        40
  - Regex:           '.*'
    Priority:        10

StatementMacros: 
  - "DIPPINS"
  - "TT_HEAD"
  - "TT_LINE"
  - "TT_FAMILY"
#  - "TRUTH_TABLE"
#  - "NETLIB_DEVICE_IMPL_NS"
#  - "TTL_7400_NAND"
#  - "TTL_7402_NOR"
#  - "NET_C"
#  - "TRUTHTABLE_ENTRY"
  - "LOCAL_LIB_ENTRY"

#StatementAttributeLikeMacros: 
#  - "NETLIST_NAME"
#  - "NETLIB_NAME"

TypenameMacros: 
  - "NETLIST_NAME"
  - "NETLIB_NAME"
  - "PENUM"

WhitespaceSensitiveMacros: 
  - "ALIAS"
  - "DIPPINS"
  - "NET_C"
  - "PENUM"

IndentPPDirectives: BeforeHash
MacroBlockBegin: "^static NETLIST_START\\(.+\\)|static TRUTHTABLE_START\\(.*\\)$"
MacroBlockEnd: "^NETLIST_END\\(\\)|TRUTHTABLE_END\\(\\)$"

# Avoid formatting 
# -- clang-tidy
#  - cspell
#  - Doxygen tables
#  - Doxygen commands
#  - ignored comments
#  - nltool parsed documentation
CommentPragmas:  '^( NOLINT.+| spell-checker.+|/ \|.+|/ \\.+|#.+|-.+)'

