From d9b25e1efaea8e6dbcbf3cf9e9c0f6a0d4a56915 Mon Sep 17 00:00:00 2001 From: "Tejasvi S. Tomar" <45873379+tejasvi@users.noreply.github.com> Date: Wed, 26 Jan 2022 15:55:50 +0530 Subject: [PATCH 1/2] Specify ContinuationIndentWidth with IndentWidth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most styles use ContinuationIndentWidth = 2*IndentWidth (google, llvm, etc). With existing arguments, shiftwidth=4 gives ```cpp constexpr operator To() const noexcept(noexcept(static_cast≺To≻(ːdeclval≺From≻()))) ⇉ return static_cast≺To≻(val) ``` instead of expected ```cpp constexpr operator To() const noexcept(noexcept(static_cast≺To≻(ːdeclval≺From≻()))) ⇉ return static_cast≺To≻(val) ``` --- autoload/clang_format.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autoload/clang_format.vim b/autoload/clang_format.vim index f4ff380..c770108 100644 --- a/autoload/clang_format.vim +++ b/autoload/clang_format.vim @@ -75,10 +75,11 @@ endfunction function! s:make_style_options() abort let extra_options = s:build_extra_options() - return printf("{BasedOnStyle: %s, IndentWidth: %d, UseTab: %s%s}", + let indentwidth = exists('*shiftwidth') ? shiftwidth() : &l:shiftwidth + return printf("{BasedOnStyle: %s, IndentWidth: %d, ContinuationIndentWidth: %d, UseTab: %s%s}", \ g:clang_format#code_style, - \ (exists('*shiftwidth') ? shiftwidth() : &l:shiftwidth), - \ &l:expandtab==1 ? 'false' : 'true', + \ indentwidth, + \ indentwidth * 2, \ extra_options) endfunction From a55eb944d81e9c65e306df0d0205c0a3d9dda75a Mon Sep 17 00:00:00 2001 From: tejasvi <45873379+tejasvi@users.noreply.github.com> Date: Wed, 26 Jan 2022 17:59:25 +0530 Subject: [PATCH 2/2] Fix typo --- autoload/clang_format.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/clang_format.vim b/autoload/clang_format.vim index c770108..2995c54 100644 --- a/autoload/clang_format.vim +++ b/autoload/clang_format.vim @@ -80,6 +80,7 @@ function! s:make_style_options() abort \ g:clang_format#code_style, \ indentwidth, \ indentwidth * 2, + \ &l:expandtab==1 ? 'false' : 'true', \ extra_options) endfunction