From c4e535792c80118074b502e583690e9df0aa23c0 Mon Sep 17 00:00:00 2001 From: We-unite <3205135446@qq.com> Date: Sat, 29 Jun 2024 14:20:02 +0800 Subject: update --- tools/.clang-format | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++ tools/compile_vim.sh | 94 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+) create mode 100644 tools/.clang-format create mode 100755 tools/compile_vim.sh (limited to 'tools') diff --git a/tools/.clang-format b/tools/.clang-format new file mode 100644 index 0000000..a1054a5 --- /dev/null +++ b/tools/.clang-format @@ -0,0 +1,121 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +... + diff --git a/tools/compile_vim.sh b/tools/compile_vim.sh new file mode 100755 index 0000000..47115a9 --- /dev/null +++ b/tools/compile_vim.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +set -e # exit when error +# environment variables here + +VIMRUNTIME=/usr/share/vim/vim91 +color_file=industry.vim + +# write a function to install sth,the parameter of the func is the packages +function install() { + sudo apt update + sudo apt upgrade + sudo apt remove vim* + sudo apt install -y git libatk1.0-dev libcairo2-dev liblua5.1-0-dev \ + libncurses5-dev libperl-dev libx11-dev libxpm-dev \ + libxt-dev lua5.1 python3-dev ruby-dev + } + +# check current user is root or not, if is, warn the user +if [ $UID -eq 0 ]; then + echo -e "\033[31mYou are root, I recommand to use a normal user to run this script.\033[0m" + exit +fi + +cd ~ +# if this is the first time to compile vim +if [ $# -eq 1 ] && [ $1 == "first" ]; then + install + if ! [ -d app ]; then + mkdir app + fi + cd app + echo -e "\033[32mGetting vim source code...\033[0m" + git clone https://github.com/vim/vim + cd vim/src +else + cd app/vim/src + sudo make uninstall + make distclean + echo -e "\033[32mGetting vim source code...\033[0m" + git pull +fi + +# get the default python version +python_version=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1"."$2}') +if [ -z $python_version ]; then + echo -e "\033[31mInstalling python3...\033[0m" + sudo apt update && sudo apt upgrade + sudo apt install python3 + python_version=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1"."$2}') +fi +# if gtk installed, remove it +if [ -d /usr/local/include/gtk-2.0 ]; then + sudo apt remove libgtk2.0-dev +fi + +echo -e "\033[32mPython version: $python_version\033[0m" + +echo -e "\033[32mConfiguring compile environment...\033[0m" +./configure \ + --with-features=huge \ + --enable-multibyte \ + --enable-rubyinterp=dynamic \ + --with-ruby-command=/usr/bin/ruby \ + --enable-luainterp\ + --enable-python3interp=dynamic \ + --with-python3-command=$(which python$python_version) \ + --with-python3-config-dir=$(python$python_version-config --configdir) \ + --enable-perlinterp=dynamic \ + --enable-largefile \ + --enable-cscope \ + --with-compiledby="An Ordinary Communist weunite1848@gmail.com" \ + --enable-fail-if-missing \ + --disable-gui \ + --prefix=/usr + +echo -e "\033[32mCompiling vim...\033[0m" +make + +echo -e "\033[32mInstalling vim...\033[0m" +sudo make install + +echo -e "\033[32;36mCompile done!\033[0m" +vim --version | head -n 3 + +# test if the terminal support 256 colors, if so, configure the color file +if [ $(tput colors) -ge 256 ]; then + color_file=$VIMRUNTIME/colors/$color_file + echo -e "\033[32mConfiguring $color_file as transparent...\033[0m" + sudo sed -i '/if s:t_Co >= 256/,/hi Normal/{s/hi Normal/" hi/}' $color_file + sudo sed -i '/if s:t_Co >= 256/,/hi EndOfBuffer/{s/hi EndOfBuffer/" hi/}' $color_file +fi + +echo -e "\033[32;36mDone.\033[0m" -- cgit v1.2.3-70-g09d2