From c47152488066b50eb8dd444e6bd7fbac48d65775 Mon Sep 17 00:00:00 2001 From: surtur Date: Sun, 30 Oct 2022 02:56:59 +0100 Subject: [PATCH] vimrc: add augroup clang_format --- .vim/vimrc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.vim/vimrc b/.vim/vimrc index 4264243..7992f62 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -292,6 +292,25 @@ let g:deoplete#enable_at_startup = 0 exec 'source ' . escape(expand('~/.vim'),' ') . '/' . 'deoplete.vimrc.vim' +" clang-format +let g:clang_format#auto_format=0 +let g:clang_format#detect_style_file=1 +augroup clang_format + autocmd! + autocmd FileType c,cpp,proto nnoremap cf :ClangFormat + autocmd FileType c,cpp,proto vnoremap cf :ClangFormat + + function! Formatonsave() + " alternative function to clang-format#auto_format param + if exists(':ClangFormat') + let l:formatdiff = 1 + " pyf /usr/share/clang/clang-format.py + ClangFormat + endif + endfunction + " autocmd BufWritePre *.h,*.cc,*.cpp call Formatonsave() +augroup END + let g:livepreview_cursorhold_recompile = 0 let g:livepreview_previewer = 'evince'