diff --git a/pack/vim-clang-format/opt/vim-clang-format b/pack/vim-clang-format/opt/vim-clang-format new file mode 160000 index 0000000..6b79182 --- /dev/null +++ b/pack/vim-clang-format/opt/vim-clang-format @@ -0,0 +1 @@ +Subproject commit 6b791825ff478061ad1c57b21bb1ed5a5fd0eb29 diff --git a/vimfiles.stefan/after/ftplugin/c.vim b/vimfiles.stefan/after/ftplugin/c.vim index c17fe6c..ab24302 100644 --- a/vimfiles.stefan/after/ftplugin/c.vim +++ b/vimfiles.stefan/after/ftplugin/c.vim @@ -33,11 +33,6 @@ if (g:os == 'linux') endif setlocal suffixesadd=.h -" set clang-format for gq, if exists -if exists('*ClangFormat()') - setlocal formatexpr=ClangFormat() -endif - " commenting " ---------- let b:commentstring = "\/\/" diff --git a/vimfiles.stefan/plugin/vimsuite.vim b/vimfiles.stefan/plugin/vimsuite.vim index 2838da9..fd92a0a 100644 --- a/vimfiles.stefan/plugin/vimsuite.vim +++ b/vimfiles.stefan/plugin/vimsuite.vim @@ -210,19 +210,6 @@ endfunction " Formatting Functions " -------------------- -" hint: formatexpr=ClangFormat() is set in ft/c.vim -command! ClangFormat call ClangFormat() -function ClangFormat() - if (v:count > 0) - let startline = v:lnum - let endline = v:lnum + v:count - let l:lines = startline.':'.endline - else - let l:lines='all' - endif - py3file /usr/share/vim/addons/syntax/clang-format.py -endfunction - " delete all multiple empty lines command -range=% DelAllMultipleEmptyLines call DelAllMultipleEmptyLines(,) function DelAllMultipleEmptyLines(fromline, toline) diff --git a/vimfiles.stefan/vimrc b/vimfiles.stefan/vimrc index d65b797..20d6741 100644 --- a/vimfiles.stefan/vimrc +++ b/vimfiles.stefan/vimrc @@ -61,6 +61,7 @@ packadd! tcomment packadd! termdebug packadd! vc packadd! vimagit +packadd! vim-clang-format packadd! VisIncr packadd! xml packadd! yapf @@ -288,6 +289,15 @@ command PyFlake Flake8 " ----- command PyIsort Isort +" ----------- +" ClangFormat +" ----------- +let g:clang_format#command = 'clang-format-15' +let g:clang_format#detect_style_file = 1 +let g:clang_format#auto_format = 1 +let g:clang_format#auto_format_on_insert_leave = 1 +let g:clang_format#auto_formatexpr = 1 + " ------------- " YouCompleteMe " -------------