From d4a3c3b4a3ca45e06fedf81a106260583b5c10e9 Mon Sep 17 00:00:00 2001 From: doyle Date: Thu, 7 Jan 2021 10:23:02 +1100 Subject: [PATCH] Update dev environment --- Installer/_vimrc | 55 ++++++++++--------------------- Installer/clang-format-style-file | 40 ++++++++++++++++++++++ linux_install.sh | 5 +++ win32_install.bat | 9 +++++ 4 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 Installer/clang-format-style-file diff --git a/Installer/_vimrc b/Installer/_vimrc index b66d9a7..b083565 100644 --- a/Installer/_vimrc +++ b/Installer/_vimrc @@ -16,7 +16,6 @@ Plug 'https://github.com/tpope/vim-fugitive' Plug 'https://github.com/bfrg/vim-cpp-modern' Plug 'https://github.com/skywind3000/asyncrun.vim' Plug 'https://github.com/Yggdroot/LeaderF' -Plug 'https://github.com/rhysd/vim-clang-format' " Themes Plug 'https://github.com/tomasr/molokai' @@ -223,43 +222,25 @@ noremap :=printf("Leaderf! rg -e %s ", expand("")) " ============================================================================== " Clang Format " ============================================================================== -let g:clang_format#style_options = { - \ "AccessModifierOffset": -4, - \ "AlignAfterOpenBracket": "true", - \ "AlignConsecutiveAssignments": "true", - \ "AlignTrailingComments": "true", - \ "AllowAllParametersOfDeclarationOnNextLine": "true", - \ "AllowShortBlocksOnASingleLine": "false", - \ "AllowShortIfStatementsOnASingleLine": "true", - \ "AllowShortLoopsOnASingleLine": "false", - \ "AlwaysBreakAfterDefinitionReturnType": "false", - \ "AlwaysBreakBeforeMultilineStrings": "true", - \ "AlwaysBreakTemplateDeclarations": "true", - \ "BinPackArguments": "false", - \ "BinPackParameters": "false", - \ "BreakBeforeBraces": "Allman", - \ "BreakConstructorInitializersBeforeComma": "true", - \ "ColumnLimit": 120, - \ "ConstructorInitializerIndentWidth": 0, - \ "Cpp11BracedListStyle": "true", - \ "IndentCaseLabels": "true", - \ "IndentFunctionDeclarationAfterType": "false", - \ "IndentWidth": 4, - \ "MaxEmptyLinesToKeep": 1, - \ "NamespaceIndentation": "None", - \ "PointerBindsToType": "false", - \ "SpaceBeforeAssignmentOperators": "true", - \ "SpaceInEmptyParentheses": "false", - \ "SpacesBeforeTrailingComments": 1, - \ "SpacesInAngles": "false", - \ "SpacesInCStyleCastParentheses": "false", - \ "SpacesInParentheses": "false", - \ "SpacesInSquareBrackets": "false", - \ "Standard": "Cpp11", - \ "TabWidth": 4, - \ } +if s:running_windows + if has('python') + map :pyf ~/vimfiles/clang-format.py + imap :pyf ~/vimfiles/clang-format.py + elseif has('python3') + map :py3f ~/vimfiles/clang-format.py + imap :py3f ~/vimfiles/clang-format.py + endif +else + if has('python') + map :pyf ~/.vim/clang-format.py + imap :pyf ~/.vim/clang-format.py + elseif has('python3') + map :py3f ~/.vim/clang-format.py + imap :py3f ~/.vim/clang-format.py + endif +endif + -map :update!:ClangFormat " ============================================================================== " Compiling / AsyncRun diff --git a/Installer/clang-format-style-file b/Installer/clang-format-style-file new file mode 100644 index 0000000..6187cf3 --- /dev/null +++ b/Installer/clang-format-style-file @@ -0,0 +1,40 @@ +{ + AccessModifierOffset: -4, # 1 tab + AlignAfterOpenBracket: true, + AlignConsecutiveAssignments: true, + AlignConsecutiveBitfields: true, + AlignConsecutiveDeclarations: true, + AlignConsecutiveMacros: true, + AlignTrailingComments: true, + AllowAllParametersOfDeclarationOnNextLine: true, + AllowShortBlocksOnASingleLine: false, + AllowShortIfStatementsOnASingleLine: true, + AllowShortLoopsOnASingleLine: false, + AllowShortCaseLabelsOnASingleLine: true, + AllowShortLambdasOnASingleLine: false, + AlwaysBreakAfterDefinitionReturnType: false, + AlwaysBreakBeforeMultilineStrings: true, + AlwaysBreakTemplateDeclarations: true, + BinPackArguments: false, + BinPackParameters: false, + BreakBeforeBraces: Allman, + BreakConstructorInitializersBeforeComma: true, + ColumnLimit: 120, + ConstructorInitializerIndentWidth: 0, + Cpp11BracedListStyle: true, + IndentCaseLabels: true, + IndentFunctionDeclarationAfterType: false, + IndentWidth: 4, # 1 tab + MaxEmptyLinesToKeep: 1, + NamespaceIndentation: None, + PointerBindsToType: false, + SpaceBeforeAssignmentOperators: true, + SpaceInEmptyParentheses: false, + SpacesBeforeTrailingComments: 1, + SpacesInAngles: false, + SpacesInCStyleCastParentheses: false, + SpacesInParentheses: false, + SpacesInSquareBrackets: false, + Standard: Cpp11, + TabWidth: 4, +} diff --git a/linux_install.sh b/linux_install.sh index a5734a1..8fad734 100755 --- a/linux_install.sh +++ b/linux_install.sh @@ -2,6 +2,10 @@ if [[ ! -f "${HOME}/.vim/autoload/plug.vim" ]]; then wget --directory-prefix=../.vim/autoload https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim fi +if [[ ! -f "${HOME}/clang-format.py" ]]; then + wget --directory-prefix=${HOME}/.vim/clang-format.py https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format.py +fi + # # Dependencies # @@ -12,6 +16,7 @@ sudo apt install exuberant-ctags neovim clang-format ripgrep # cp --force Installer/_vimrc ~/.vimrc cp --force Installer/unix_nvim_init.vim ~/.config/nvim/init.vim +cp --force Installer/clang-format-style-file ~/_clang-format # # Ctags diff --git a/win32_install.bat b/win32_install.bat index 4c740db..59a5b80 100644 --- a/win32_install.bat +++ b/win32_install.bat @@ -32,10 +32,12 @@ REM clang-format: C/C++ formatting tool REM ctags: C/C++ code annotation generator REM scanmapset: Bind capslock to escape via registry REM uncap: Bind capslock to escape via run-time program +REM clang-format: Default clang-format style call :CopyFile "%installer_root%\win32_clang_format.exe" "%cmder_root%\bin\clang-format.exe" || exit /b call :CopyFile "%installer_root%\win32_ctags.exe" "%cmder_root%\bin\ctags.exe" || exit /b call :CopyFile "%installer_root%\win32_scanmapset.exe" "%cmder_root%\bin\scanmapset.exe" || exit /b call :CopyFile "%installer_root%\win32_uncap.exe" "%cmder_root%\bin\uncap.exe" || exit /b +call :CopyFile "%installer_root%\clang-format-style-file" "%home%\_clang-format" || exit /b REM REM GVim, Vim Plug, Vim Config @@ -61,6 +63,13 @@ if exist "%vim_plug%" ( call :DownloadFile https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim "%vim_plug%" || exit /b ) +set vim_clang_format=%vim_root%\clang-format.py +if exist "%vim_clang_format%" ( + echo - [Cache] Vim Clang Format already installed at %vim_clang_format% +) else ( + call :DownloadFile https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format.py "%vim_clang_format%" || exit /b +) + REM REM ripgrep REM