From f6af32126dfe2d75326a9f587f193a12414cd1ac Mon Sep 17 00:00:00 2001 From: DustVoice Date: Sun, 20 Sep 2020 20:09:21 +0200 Subject: [PATCH] Adapt clang-format default behaviour --- init.vim | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/init.vim b/init.vim index 2b01d4f..07371d8 100644 --- a/init.vim +++ b/init.vim @@ -306,13 +306,74 @@ call plug#end() " === if g:use_clang_format == 1 let g:clang_format#detect_style_file = 1 - let g:clang_format#enable_fallback_style = 0 + let g:clang_format#enable_fallback_style = 1 + + let g:clang_format#style = "Microsoft" + let g:clang_format#style_options = { + \ "BasedOnStyle" : "Microsoft", + \ "AccessModifierOffset" : -4, + \ "AlignAfterOpenBracket" : "Align", + \ "AlignConsecutiveAssignments" : "false", + \ "AlignConsecutiveDeclarations" : "false", + \ "AlignEscapedNewlinesLeft" : "false", + \ "AlignOperands" : "true", + \ "AlignTrailingComments" : "false", + \ "AllowAllParametersOfDeclarationOnNextLine" : "false", + \ "AllowShortBlocksOnASingleLine" : "false", + \ "AllowShortCaseLabelsOnASingleLine" : "false", + \ "AllowShortFunctionsOnASingleLine" : "All", + \ "AllowShortIfStatementsOnASingleLine" : "false", + \ "AllowShortLoopsOnASingleLine" : "false", + \ "AlwaysBreakAfterDefinitionReturnType" : "None", + \ "AlwaysBreakAfterReturnType" : "None", + \ "AlwaysBreakBeforeMultilineStrings" : "false", + \ "AlwaysBreakTemplateDeclarations" : "true", + \ "BinPackArguments" : "false", + \ "BinPackParameters" : "false", + \ "BreakAfterJavaFieldAnnotations" : "false", + \ "BreakBeforeBinaryOperators" : "NonAssignment", + \ "BreakBeforeBraces" : "Allman", + \ "BreakBeforeTernaryOperators" : "true", + \ "BreakConstructorInitializersBeforeComma" : "false", + \ "BreakStringLiterals" : "false", + \ "ColumnLimit" : 0, + \ "ConstructorInitializerAllOnOneLineOrOnePerLine" : "true", + \ "ConstructorInitializerIndentWidth" : 4, + \ "ContinuationIndentWidth" : 4, + \ "Cpp11BracedListStyle" : "false", + \ "DerivePointerAlignment" : "false", + \ "DisableFormat" : "false", + \ "ExperimentalAutoDetectBinPacking" : "false", + \ "IndentCaseLabels" : "true", + \ "IndentWidth" : 4, + \ "IndentWrappedFunctionNames" : "true", + \ "KeepEmptyLinesAtTheStartOfBlocks" : "false", + \ "Language" : "Cpp", + \ "MaxEmptyLinesToKeep" : 1, + \ "NamespaceIndentation" : "Inner", + \ "PointerAlignment" : "Left", + \ "ReflowComments" : "false", + \ "SortIncludes" : "true", + \ "SpaceAfterCStyleCast" : "true", + \ "SpaceBeforeAssignmentOperators" : "true", + \ "SpaceBeforeParens" : "ControlStatements", + \ "SpaceInEmptyParentheses" : "false", + \ "SpacesInAngles" : "false", + \ "SpacesInCStyleCastParentheses" : "false", + \ "SpacesInContainerLiterals" : "true", + \ "SpacesInParentheses" : "false", + \ "SpacesInSquareBrackets" : "false", + \ "Standard" : "Cpp11", + \ "TabWidth" : 4, + \ "UseTab" : "Never" } + + let g:clang_format#auto_format = 1 + let g:clang_format#auto_format_on_insert_leave = 0 autocmd FileType c,cpp,objc nnoremap cf :ClangFormat autocmd FileType c,cpp,objc vnoremap cf :ClangFormat - autocmd FileType c,cpp,objc let g:clang_format#auto_format = 1 - autocmd FileType c,cpp,objc let g:clang_format#auto_format_on_insert_leave = 0 + nmap ct :ClangFormatAutoToggle endif " ===