diff options
author | 2024-06-29 14:20:02 +0800 | |
---|---|---|
committer | 2024-06-29 14:26:46 +0800 | |
commit | c4e535792c80118074b502e583690e9df0aa23c0 (patch) | |
tree | 5ace915de19fc8958de029ff7b5c7690cebfe26b | |
parent | afa8fcdfd84544356a052ea0673b04fd5018bd41 (diff) | |
download | Pardon-c4e535792c80118074b502e583690e9df0aa23c0.tar.gz Pardon-c4e535792c80118074b502e583690e9df0aa23c0.zip |
updatemain
-rw-r--r-- | README.md | 31 | ||||
-rwxr-xr-x | mypath/ast.sh | 11 | ||||
-rwxr-xr-x | mypath/clang-tidy-check.sh | 13 | ||||
-rwxr-xr-x | mypath/compare.sh | 14 | ||||
-rwxr-xr-x | mypath/compile-tiny.sh | 61 | ||||
-rwxr-xr-x | mypath/compile.sh | 41 | ||||
-rwxr-xr-x | mypath/count.sh | 30 | ||||
-rwxr-xr-x | mypath/gitadd.sh | 68 | ||||
-rwxr-xr-x | mypath/gitk.sh | 2 | ||||
-rwxr-xr-x | mypath/gui.py | 52 | ||||
-rwxr-xr-x | mypath/md2html.sh | 2 | ||||
-rw-r--r-- | mypath/runjv.c | 39 | ||||
-rwxr-xr-x | mypath/runjv.sh | 17 | ||||
-rwxr-xr-x | mypath/search.sh | 52 | ||||
-rwxr-xr-x | mypath/tokei | bin | 0 -> 7416736 bytes | |||
-rw-r--r-- | tools/.clang-format | 121 | ||||
-rwxr-xr-x | tools/compile_vim.sh | 94 | ||||
-rw-r--r-- | vim/vimrc.tiny | 13 | ||||
-rw-r--r-- | vim/vimrc_origin | 55 | ||||
-rw-r--r-- | vim/vimrcs/codecmd.vim | 9 | ||||
-rw-r--r-- | vim/vimrcs/keybind.vim | 4 | ||||
-rw-r--r-- | vim/vimrcs/match.vim | 9 | ||||
-rw-r--r-- | vim/vimrcs/plugs.vim | 3 | ||||
-rw-r--r-- | vim/vimscript.vim | 295 |
24 files changed, 511 insertions, 525 deletions
@@ -1,3 +1,30 @@ | |||
1 | [Pardon?] | 1 | 这里是我自己用的一些小零件的暂存。 |
2 | 2 | ||
3 | 这里是我自己用的一些代码的暂存。 | 3 | ```plaintext |
4 | . | ||
5 | ├── mypath # 个人使用内容 | ||
6 | │ ├── ast.sh # 使用clang打印c/cpp的ast树 | ||
7 | │ ├── clang-tidy-check.sh # 使用clang-tidy的指定规则检查代码 | ||
8 | │ ├── compile.sh # 使用ohos ndk进行cmake交叉编译 | ||
9 | │ ├── compile-tiny.sh # 使用ohos ndk对单个c/cpp文件交叉编译 | ||
10 | │ ├── dif.sh # 使用diff工具对比两个文件的差别 | ||
11 | │ ├── exe.sh # 对本路径下的脚本创建无后缀文件,方便日常使用 | ||
12 | │ ├── gitadd.sh # (在服务器上)快速添加一个远程库 | ||
13 | │ ├── gui.py # 在Linux下绘制ohos机器人得到的地图 | ||
14 | │ ├── md2html.sh # 使用pandoc将md文件转换为html文件 | ||
15 | │ ├── search.sh # 在当前路径下所有文件中查找指定内容 | ||
16 | │ └── tokei # 使用tokei统计代码行数 | ||
17 | ├── README.md | ||
18 | ├── tools | ||
19 | │ ├── compile_vim.sh # 自己编译vim | ||
20 | │ └── .clang-format # clang-format配置文件 | ||
21 | └── vim | ||
22 | ├── vimrc # vim配置文件,放置在/etc/vim/目录下 | ||
23 | └── vimrcs | ||
24 | ├── codecmd.vim | ||
25 | ├── keybind.vim | ||
26 | ├── match.vim | ||
27 | ├── myset.vim | ||
28 | ├── plugs.vim | ||
29 | └── statusline.vim | ||
30 | ``` | ||
diff --git a/mypath/ast.sh b/mypath/ast.sh new file mode 100755 index 0000000..6ea2adc --- /dev/null +++ b/mypath/ast.sh | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : ast.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2024-06-02 15:00:21 | ||
9 | ########################################################################## | ||
10 | |||
11 | /home/player/app/llvm-project/build/bin/clang -cc1 -ast-dump $1 | ||
diff --git a/mypath/clang-tidy-check.sh b/mypath/clang-tidy-check.sh new file mode 100755 index 0000000..cea6e36 --- /dev/null +++ b/mypath/clang-tidy-check.sh | |||
@@ -0,0 +1,13 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : clang-tidy-check.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2024-04-28 16:50:37 | ||
9 | ########################################################################## | ||
10 | |||
11 | set -e | ||
12 | |||
13 | clang-tidy -checks="-*,$2" -header-filter=.* $1 -- -I/usr/include | ||
diff --git a/mypath/compare.sh b/mypath/compare.sh deleted file mode 100755 index 2643b42..0000000 --- a/mypath/compare.sh +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | file1="file1.txt" | ||
4 | file2="file2.txt" | ||
5 | |||
6 | diff_output=$(diff "$file1" "$file2") | ||
7 | |||
8 | if [ -z "$diff_output" ]; then | ||
9 | echo "两个文件完全一致" | ||
10 | else | ||
11 | echo "两个文件不完全一致" | ||
12 | echo "$diff_output" | ||
13 | fi | ||
14 | |||
diff --git a/mypath/compile-tiny.sh b/mypath/compile-tiny.sh new file mode 100755 index 0000000..2bfdada --- /dev/null +++ b/mypath/compile-tiny.sh | |||
@@ -0,0 +1,61 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : compile-tiny.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2024-04-16 13:06:58 | ||
9 | ########################################################################## | ||
10 | |||
11 | set -e | ||
12 | # 如果是root,报错 | ||
13 | if [ $(id -u) -eq 0 ]; then | ||
14 | echo "Do not run as root" | ||
15 | exit 1 | ||
16 | fi | ||
17 | |||
18 | if [ $# -ne 2 ]; then | ||
19 | echo "Usage: $0 <src file> [armv8-a|armv7-a]" | ||
20 | exit 1 | ||
21 | fi | ||
22 | |||
23 | native=~/app/native | ||
24 | file=$1 | ||
25 | targetFile=${file%.*} | ||
26 | arch=$2 | ||
27 | |||
28 | case $arch in | ||
29 | armv8-a) | ||
30 | compiler=$native/llvm/bin/aarch64-unknown-linux-ohos | ||
31 | targetPlatform=aarch64-linux-ohos | ||
32 | ;; | ||
33 | armv7-a) | ||
34 | compiler=$native/llvm/bin/armv7-unknown-linux-ohos | ||
35 | targetPlatform=arm-linux-ohos | ||
36 | ;; | ||
37 | *) | ||
38 | echo "Unsupported arch" | ||
39 | exit 1 | ||
40 | ;; | ||
41 | esac | ||
42 | |||
43 | case ${file##*.} in | ||
44 | c) | ||
45 | compiler=$compiler-clang | ||
46 | ;; | ||
47 | cpp) | ||
48 | compiler=$compiler-clang++ | ||
49 | ;; | ||
50 | *) | ||
51 | echo "Unsupported file type" | ||
52 | exit 1 | ||
53 | ;; | ||
54 | esac | ||
55 | |||
56 | export CPATH= | ||
57 | |||
58 | $compiler -o $targetFile $file -Wall \ | ||
59 | --target=$targetPlatform \ | ||
60 | --sysroot=$native/sysroot \ | ||
61 | -march=$arch -mfloat-abi=softfp | ||
diff --git a/mypath/compile.sh b/mypath/compile.sh new file mode 100755 index 0000000..2948e8f --- /dev/null +++ b/mypath/compile.sh | |||
@@ -0,0 +1,41 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : compile.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2024-02-29 15:19:15 | ||
9 | ########################################################################## | ||
10 | |||
11 | set -e | ||
12 | |||
13 | if [ $UID -eq 0 ]; then | ||
14 | echo "Please do not run this script as root" | ||
15 | exit 1 | ||
16 | fi | ||
17 | |||
18 | if [ $# -ne 2 ]; then | ||
19 | echo "Usage: $0 <static|shared> <v7|v8>" | ||
20 | exit 1 | ||
21 | fi | ||
22 | |||
23 | if [ $2 == "v8" ]; then | ||
24 | arch=arm64-v8a | ||
25 | elif [ $2 == "v7" ]; then | ||
26 | arch=armeabi-v7a | ||
27 | else | ||
28 | echo "Usage: $0 <static|shared> <v7|v8>" | ||
29 | exit 1 | ||
30 | fi | ||
31 | |||
32 | link=$1 # static or shared | ||
33 | native_path=~/app/native | ||
34 | |||
35 | export PATH=$native_path/build-tools/cmake/bin:$PATH | ||
36 | # 清空CPATH,防止影响编译 | ||
37 | export CPATH= | ||
38 | |||
39 | # 使用cmake编译,编译生成的文件运行在rk3568上 | ||
40 | cmake -B build -D OHOS_STL=c++_$link -D OHOS_ARCH=$arch -D OHOS_PLATFORM=OHOS -D CMAKE_TOOLCHAIN_FILE=$(find $native_path -name ohos.toolchain.cmake) | ||
41 | cmake --build build | ||
diff --git a/mypath/count.sh b/mypath/count.sh deleted file mode 100755 index 5105b42..0000000 --- a/mypath/count.sh +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | count_lines() { | ||
4 | local filename=$1 | ||
5 | local sum=0 | ||
6 | local buf | ||
7 | |||
8 | while IFS= read -r buf; do | ||
9 | ((sum++)) | ||
10 | done < "$filename" | ||
11 | |||
12 | echo "$sum" | ||
13 | } | ||
14 | |||
15 | extensions=("c" "tex" "cpp" "py" "h") | ||
16 | sum=0 | ||
17 | |||
18 | for extension in "${extensions[@]}"; do | ||
19 | files=$(find . -type f -name "*.$extension") | ||
20 | for file in $files; do | ||
21 | tmp=$(count_lines "$file") | ||
22 | ((sum+=tmp)) | ||
23 | echo "文件路径: $file" | ||
24 | echo "行数: $tmp" | ||
25 | echo | ||
26 | done | ||
27 | done | ||
28 | |||
29 | echo "总行数: $sum" | ||
30 | |||
diff --git a/mypath/gitadd.sh b/mypath/gitadd.sh index 79e750f..0ac59fa 100755 --- a/mypath/gitadd.sh +++ b/mypath/gitadd.sh | |||
@@ -1,45 +1,27 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | read -p "Local repo name: " local_name | 3 | ########################################################################## |
4 | read -p "Remote repo name: " remote_name | 4 | # File Name : gitadd.sh |
5 | 5 | # Encoding : utf-8 | |
6 | # 远程仓库创建 | 6 | # Author : We-unite |
7 | tmp="ssh aliyun-git git init --bare $remote_name.git" | 7 | # Email : weunite1848@gmail.com |
8 | eval "$tmp" | 8 | # Created Time : 2024-03-21 19:26:53 |
9 | 9 | ########################################################################## | |
10 | # 本地仓库创建 | 10 | |
11 | mkdir "$local_name" | 11 | set -e |
12 | cd "$local_name" | 12 | |
13 | git init | 13 | repo_name="" |
14 | 14 | # 判断参数个数 | |
15 | # 本地仓库初始化 | 15 | if [ $# -ne 1 ]; then |
16 | # 编写.gitignore | 16 | echo "Input repository name: " |
17 | cat > .gitignore << EOF | 17 | read name |
18 | *.sh | 18 | repo_name=$name |
19 | *.bat | 19 | else |
20 | *.exe | 20 | repo_name=$1 |
21 | *.[oa] | 21 | fi |
22 | *.pyc | 22 | |
23 | __pycache__ | 23 | sudo -u git -H bash -c "cd ~ && git init --bare $repo_name.git" |
24 | *.vscode | 24 | echo "Input description for the repository:" |
25 | *.swp | 25 | read desc |
26 | EOF | 26 | sudo -u git -H bash -c "echo $desc > ~/$repo_name.git/description" |
27 | 27 | echo "Repository $1.git created successfully!" | |
28 | # 编写push.sh | ||
29 | cat > push.sh << EOF | ||
30 | git add . | ||
31 | git commit | ||
32 | git push | ||
33 | EOF | ||
34 | chmod +x push.sh | ||
35 | |||
36 | # 提交初始化commit | ||
37 | git add . | ||
38 | git commit -m "Initial commit" | ||
39 | tmp="git remote add origin aliyun-git:$remote_name.git" | ||
40 | eval "$tmp" | ||
41 | git push --set-upstream origin master | ||
42 | git push | ||
43 | |||
44 | echo "Success!" | ||
45 | |||
diff --git a/mypath/gitk.sh b/mypath/gitk.sh deleted file mode 100755 index aa6e515..0000000 --- a/mypath/gitk.sh +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | git log --oneline --all --graph | ||
diff --git a/mypath/gui.py b/mypath/gui.py new file mode 100755 index 0000000..2835e96 --- /dev/null +++ b/mypath/gui.py | |||
@@ -0,0 +1,52 @@ | |||
1 | #!/usr/bin/env python | ||
2 | import matplotlib.pyplot as plt | ||
3 | from matplotlib.widgets import Button, TextBox | ||
4 | from tkinter.filedialog import askopenfilename | ||
5 | from scipy.ndimage import binary_dilation | ||
6 | import numpy as np | ||
7 | import os | ||
8 | |||
9 | def load_and_process_image(file_path, structure_size): | ||
10 | with open(file_path, 'r') as f: | ||
11 | f.readline() # 忽略第一行 | ||
12 | lines = f.readlines() | ||
13 | lines = lines[::-1] # 颠倒一下,第一行在最下面 | ||
14 | |||
15 | image_data = [list(map(int, line.strip().split())) for line in lines] | ||
16 | image_array = np.array(image_data) | ||
17 | structure = np.ones((structure_size, structure_size)) | ||
18 | image_array = binary_dilation(image_array, structure) | ||
19 | return image_array | ||
20 | |||
21 | def on_button_click(event): | ||
22 | global file_path | ||
23 | file_path = askopenfilename() | ||
24 | structure_size = int(text_box.text) | ||
25 | image_array = load_and_process_image(file_path, structure_size) | ||
26 | ax.cla() | ||
27 | ax.imshow(image_array, cmap='gray', interpolation='nearest') | ||
28 | ax.set_title(file_path) | ||
29 | fig.canvas.draw() | ||
30 | |||
31 | def update_cursor_position(event): | ||
32 | if event.inaxes == ax: | ||
33 | x, y = event.xdata, event.ydata | ||
34 | x -= 900 | ||
35 | y -= 900 | ||
36 | ax.set_title(f'{file_path} | Cursor: ({x:.2f}, {-y:.2f})') | ||
37 | fig.canvas.draw_idle() | ||
38 | |||
39 | if __name__ == '__main__': | ||
40 | fig, ax = plt.subplots() | ||
41 | ax_button = plt.axes([0.05, 0.85, 0.1, 0.075]) | ||
42 | button = Button(ax_button, 'Open') | ||
43 | file_path = os.getcwd() | ||
44 | button.on_clicked(on_button_click) | ||
45 | |||
46 | ax_text_box = plt.axes([0.05, 0.95, 0.1, 0.05]) | ||
47 | text_box = TextBox(ax_text_box, 'Size') | ||
48 | text_box.set_val(1) | ||
49 | |||
50 | fig.canvas.mpl_connect('motion_notify_event', update_cursor_position) | ||
51 | |||
52 | plt.show() \ No newline at end of file | ||
diff --git a/mypath/md2html.sh b/mypath/md2html.sh index e71f1d3..c520736 100755 --- a/mypath/md2html.sh +++ b/mypath/md2html.sh | |||
@@ -28,4 +28,4 @@ sed -i '/<style/,/<\/style>/d' $dst | |||
28 | sed -i 's/<body>/<body>\n<div class="pandoc">\n<div class="main">/' $dst | 28 | sed -i 's/<body>/<body>\n<div class="pandoc">\n<div class="main">/' $dst |
29 | sed -i 's/<\/body>/<script src="https:\/\/test.qin-juan-ge-zhu.top\/common\/js\/comment.js"><\/script>\n<\/div>\n<\/div>\n<\/body>/' $dst | 29 | sed -i 's/<\/body>/<script src="https:\/\/test.qin-juan-ge-zhu.top\/common\/js\/comment.js"><\/script>\n<\/div>\n<\/div>\n<\/body>/' $dst |
30 | sed -i 's/\t/ /g' $dst | 30 | sed -i 's/\t/ /g' $dst |
31 | sed -i 's/<\/head>/<link rel="stylesheet" href="https:\/\/test.qin-juan-ge-zhu.top\/common\/CSS\/pandoc.css">\n<script type="text/javascript" src="https://test.qin-juan-ge-zhu.top/common/js/myhighlight.js"></script>\n<script type="text\/javascript" src="https:\/\/test.qin-juan-ge-zhu.top\/common\/script4code.js"><\/script><\/head>/' $dst | 31 | sed -i 's/<\/head>/<link rel="stylesheet" href="https:\/\/test.qin-juan-ge-zhu.top\/common\/CSS\/pandoc.css">\n<script type="text\/javascript" src="https:\/\/test.qin-juan-ge-zhu.top\/common\/js\/myhighlight.js"><\/script>\n<script type="text\/javascript" src="https:\/\/test.qin-juan-ge-zhu.top\/common\/script4code.js"><\/script><\/head>/' $dst |
diff --git a/mypath/runjv.c b/mypath/runjv.c deleted file mode 100644 index 74efb72..0000000 --- a/mypath/runjv.c +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include <string.h> | ||
4 | |||
5 | #ifdef _WIN32 | ||
6 | #define DELETE_COMMAND "del" | ||
7 | #else | ||
8 | #define DELETE_COMMAND "rm -rf" | ||
9 | #endif | ||
10 | |||
11 | |||
12 | int main(int argc, char* argv[]) | ||
13 | { | ||
14 | char* command; | ||
15 | if(argc!=2) | ||
16 | { | ||
17 | printf("Number of parameters Wrong!\n"); | ||
18 | printf("Usage: runjv <filename>\n"); | ||
19 | return 1; | ||
20 | } | ||
21 | command=(char*)malloc(sizeof(char)*(strlen(argv[1])+10)); | ||
22 | |||
23 | char* classname=strtok(argv[1],"."); | ||
24 | |||
25 | sprintf(command,"javac %s.java",classname); | ||
26 | int command_status=system(command); | ||
27 | |||
28 | if(command_status!=0) | ||
29 | { | ||
30 | printf("Compile Failed!\n"); | ||
31 | return -1; | ||
32 | } | ||
33 | sprintf(command,"java %s",classname); | ||
34 | system(command); | ||
35 | |||
36 | sprintf(command,"%s %s.class",DELETE_COMMAND,classname); | ||
37 | system(command); | ||
38 | return 0; | ||
39 | } | ||
diff --git a/mypath/runjv.sh b/mypath/runjv.sh deleted file mode 100755 index 56eaa05..0000000 --- a/mypath/runjv.sh +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # 检查参数数量 | ||
4 | if [ $# -ne 1 ]; then | ||
5 | echo "请提供一个Java文件名作为参数" | ||
6 | exit 1 | ||
7 | fi | ||
8 | |||
9 | filename=$1 | ||
10 | classname="${filename%.*}" | ||
11 | javac "$filename" | ||
12 | if [ $? -eq 0 ]; then | ||
13 | java "$classname" | ||
14 | rm "$classname.class" | ||
15 | else | ||
16 | echo "Java文件编译失败!" | ||
17 | fi | ||
diff --git a/mypath/search.sh b/mypath/search.sh new file mode 100755 index 0000000..f55f748 --- /dev/null +++ b/mypath/search.sh | |||
@@ -0,0 +1,52 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : search.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2024-03-26 01:15:43 | ||
9 | ########################################################################## | ||
10 | |||
11 | set -e | ||
12 | |||
13 | # 在当前文件夹下查找含有指定内容的文件,并输出其文件名、行号和上下文 | ||
14 | # 每个文件先输出文件名,然后输出包含指定内容的行号和上下文 | ||
15 | # 用法:./search.sh <search_content> <context_lines> | ||
16 | # 允许按顺序缺省参数 | ||
17 | |||
18 | # 检查参数个数 | ||
19 | if [ $# -lt 1 ]; then | ||
20 | echo "Usage: $0 <search_content> <path> <file_type>" | ||
21 | exit 1 | ||
22 | fi | ||
23 | |||
24 | # 检查参数是否为空 | ||
25 | if [ -z "$1" ]; then | ||
26 | echo "Error: search_content is empty" | ||
27 | exit 1 | ||
28 | fi | ||
29 | |||
30 | if [ -z "$2" ]; then | ||
31 | context_lines=3 | ||
32 | else | ||
33 | if [ -z "$(echo $2 | grep -E '^[0-9]+$')" ]; then | ||
34 | echo "Error: context_lines $2 is invalid" | ||
35 | exit 1 | ||
36 | fi | ||
37 | context_lines=$2 | ||
38 | fi | ||
39 | |||
40 | # 查找文件 | ||
41 | find . -type f | while read file; do | ||
42 | # 查找文件中包含指定内容的行,存储到变量中 | ||
43 | lines=$(grep -C "$context_lines" -n "$1" $file | sed 's/:/ /') | ||
44 | if [ "$lines" == "" ]; then | ||
45 | continue | ||
46 | else | ||
47 | # 彩色输出文件名 | ||
48 | echo -e "\033[1;32m$file\033[0m" | ||
49 | # 输出包含指定内容的行号和上下文 | ||
50 | echo -e "$lines" | ||
51 | fi | ||
52 | done | ||
diff --git a/mypath/tokei b/mypath/tokei new file mode 100755 index 0000000..2c4e5ec --- /dev/null +++ b/mypath/tokei | |||
Binary files differ | |||
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 @@ | |||
1 | --- | ||
2 | Language: Cpp | ||
3 | # BasedOnStyle: LLVM | ||
4 | AccessModifierOffset: -2 | ||
5 | AlignAfterOpenBracket: Align | ||
6 | AlignConsecutiveAssignments: false | ||
7 | AlignConsecutiveDeclarations: false | ||
8 | AlignEscapedNewlines: Right | ||
9 | AlignOperands: true | ||
10 | AlignTrailingComments: true | ||
11 | AllowAllParametersOfDeclarationOnNextLine: true | ||
12 | AllowShortBlocksOnASingleLine: false | ||
13 | AllowShortCaseLabelsOnASingleLine: false | ||
14 | AllowShortFunctionsOnASingleLine: All | ||
15 | AllowShortIfStatementsOnASingleLine: false | ||
16 | AllowShortLoopsOnASingleLine: false | ||
17 | AlwaysBreakAfterDefinitionReturnType: None | ||
18 | AlwaysBreakAfterReturnType: None | ||
19 | AlwaysBreakBeforeMultilineStrings: false | ||
20 | AlwaysBreakTemplateDeclarations: MultiLine | ||
21 | BinPackArguments: true | ||
22 | BinPackParameters: true | ||
23 | BraceWrapping: | ||
24 | AfterClass: false | ||
25 | AfterControlStatement: false | ||
26 | AfterEnum: false | ||
27 | AfterFunction: false | ||
28 | AfterNamespace: false | ||
29 | AfterObjCDeclaration: false | ||
30 | AfterStruct: false | ||
31 | AfterUnion: false | ||
32 | AfterExternBlock: false | ||
33 | BeforeCatch: false | ||
34 | BeforeElse: false | ||
35 | IndentBraces: false | ||
36 | SplitEmptyFunction: true | ||
37 | SplitEmptyRecord: true | ||
38 | SplitEmptyNamespace: true | ||
39 | BreakBeforeBinaryOperators: None | ||
40 | BreakBeforeBraces: Attach | ||
41 | BreakBeforeInheritanceComma: false | ||
42 | BreakInheritanceList: BeforeColon | ||
43 | BreakBeforeTernaryOperators: true | ||
44 | BreakConstructorInitializersBeforeComma: false | ||
45 | BreakConstructorInitializers: BeforeColon | ||
46 | BreakAfterJavaFieldAnnotations: false | ||
47 | BreakStringLiterals: true | ||
48 | ColumnLimit: 80 | ||
49 | CommentPragmas: '^ IWYU pragma:' | ||
50 | CompactNamespaces: false | ||
51 | ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
52 | ConstructorInitializerIndentWidth: 4 | ||
53 | ContinuationIndentWidth: 4 | ||
54 | Cpp11BracedListStyle: true | ||
55 | DerivePointerAlignment: false | ||
56 | DisableFormat: false | ||
57 | ExperimentalAutoDetectBinPacking: false | ||
58 | FixNamespaceComments: true | ||
59 | ForEachMacros: | ||
60 | - foreach | ||
61 | - Q_FOREACH | ||
62 | - BOOST_FOREACH | ||
63 | IncludeBlocks: Preserve | ||
64 | IncludeCategories: | ||
65 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
66 | Priority: 2 | ||
67 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
68 | Priority: 3 | ||
69 | - Regex: '.*' | ||
70 | Priority: 1 | ||
71 | IncludeIsMainRegex: '(Test)?$' | ||
72 | IndentCaseLabels: false | ||
73 | IndentPPDirectives: None | ||
74 | IndentWidth: 4 | ||
75 | IndentWrappedFunctionNames: false | ||
76 | JavaScriptQuotes: Leave | ||
77 | JavaScriptWrapImports: true | ||
78 | KeepEmptyLinesAtTheStartOfBlocks: true | ||
79 | MacroBlockBegin: '' | ||
80 | MacroBlockEnd: '' | ||
81 | MaxEmptyLinesToKeep: 1 | ||
82 | NamespaceIndentation: None | ||
83 | ObjCBinPackProtocolList: Auto | ||
84 | ObjCBlockIndentWidth: 2 | ||
85 | ObjCSpaceAfterProperty: false | ||
86 | ObjCSpaceBeforeProtocolList: true | ||
87 | PenaltyBreakAssignment: 2 | ||
88 | PenaltyBreakBeforeFirstCallParameter: 19 | ||
89 | PenaltyBreakComment: 300 | ||
90 | PenaltyBreakFirstLessLess: 120 | ||
91 | PenaltyBreakString: 1000 | ||
92 | PenaltyBreakTemplateDeclaration: 10 | ||
93 | PenaltyExcessCharacter: 1000000 | ||
94 | PenaltyReturnTypeOnItsOwnLine: 60 | ||
95 | PointerAlignment: Right | ||
96 | ReflowComments: true | ||
97 | SortIncludes: true | ||
98 | SortUsingDeclarations: true | ||
99 | SpaceAfterCStyleCast: false | ||
100 | SpaceAfterTemplateKeyword: true | ||
101 | SpaceBeforeAssignmentOperators: true | ||
102 | SpaceBeforeCpp11BracedList: false | ||
103 | SpaceBeforeCtorInitializerColon: true | ||
104 | SpaceBeforeInheritanceColon: true | ||
105 | SpaceBeforeParens: ControlStatements | ||
106 | SpaceBeforeRangeBasedForLoopColon: true | ||
107 | SpaceInEmptyParentheses: false | ||
108 | SpacesBeforeTrailingComments: 1 | ||
109 | SpacesInAngles: false | ||
110 | SpacesInContainerLiterals: true | ||
111 | SpacesInCStyleCastParentheses: false | ||
112 | SpacesInParentheses: false | ||
113 | SpacesInSquareBrackets: false | ||
114 | Standard: Cpp11 | ||
115 | StatementMacros: | ||
116 | - Q_UNUSED | ||
117 | - QT_REQUIRE_VERSION | ||
118 | TabWidth: 8 | ||
119 | UseTab: Never | ||
120 | ... | ||
121 | |||
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 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -e # exit when error | ||
4 | # environment variables here | ||
5 | |||
6 | VIMRUNTIME=/usr/share/vim/vim91 | ||
7 | color_file=industry.vim | ||
8 | |||
9 | # write a function to install sth,the parameter of the func is the packages | ||
10 | function install() { | ||
11 | sudo apt update | ||
12 | sudo apt upgrade | ||
13 | sudo apt remove vim* | ||
14 | sudo apt install -y git libatk1.0-dev libcairo2-dev liblua5.1-0-dev \ | ||
15 | libncurses5-dev libperl-dev libx11-dev libxpm-dev \ | ||
16 | libxt-dev lua5.1 python3-dev ruby-dev | ||
17 | } | ||
18 | |||
19 | # check current user is root or not, if is, warn the user | ||
20 | if [ $UID -eq 0 ]; then | ||
21 | echo -e "\033[31mYou are root, I recommand to use a normal user to run this script.\033[0m" | ||
22 | exit | ||
23 | fi | ||
24 | |||
25 | cd ~ | ||
26 | # if this is the first time to compile vim | ||
27 | if [ $# -eq 1 ] && [ $1 == "first" ]; then | ||
28 | install | ||
29 | if ! [ -d app ]; then | ||
30 | mkdir app | ||
31 | fi | ||
32 | cd app | ||
33 | echo -e "\033[32mGetting vim source code...\033[0m" | ||
34 | git clone https://github.com/vim/vim | ||
35 | cd vim/src | ||
36 | else | ||
37 | cd app/vim/src | ||
38 | sudo make uninstall | ||
39 | make distclean | ||
40 | echo -e "\033[32mGetting vim source code...\033[0m" | ||
41 | git pull | ||
42 | fi | ||
43 | |||
44 | # get the default python version | ||
45 | python_version=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1"."$2}') | ||
46 | if [ -z $python_version ]; then | ||
47 | echo -e "\033[31mInstalling python3...\033[0m" | ||
48 | sudo apt update && sudo apt upgrade | ||
49 | sudo apt install python3 | ||
50 | python_version=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1"."$2}') | ||
51 | fi | ||
52 | # if gtk installed, remove it | ||
53 | if [ -d /usr/local/include/gtk-2.0 ]; then | ||
54 | sudo apt remove libgtk2.0-dev | ||
55 | fi | ||
56 | |||
57 | echo -e "\033[32mPython version: $python_version\033[0m" | ||
58 | |||
59 | echo -e "\033[32mConfiguring compile environment...\033[0m" | ||
60 | ./configure \ | ||
61 | --with-features=huge \ | ||
62 | --enable-multibyte \ | ||
63 | --enable-rubyinterp=dynamic \ | ||
64 | --with-ruby-command=/usr/bin/ruby \ | ||
65 | --enable-luainterp\ | ||
66 | --enable-python3interp=dynamic \ | ||
67 | --with-python3-command=$(which python$python_version) \ | ||
68 | --with-python3-config-dir=$(python$python_version-config --configdir) \ | ||
69 | --enable-perlinterp=dynamic \ | ||
70 | --enable-largefile \ | ||
71 | --enable-cscope \ | ||
72 | --with-compiledby="An Ordinary Communist weunite1848@gmail.com" \ | ||
73 | --enable-fail-if-missing \ | ||
74 | --disable-gui \ | ||
75 | --prefix=/usr | ||
76 | |||
77 | echo -e "\033[32mCompiling vim...\033[0m" | ||
78 | make | ||
79 | |||
80 | echo -e "\033[32mInstalling vim...\033[0m" | ||
81 | sudo make install | ||
82 | |||
83 | echo -e "\033[32;36mCompile done!\033[0m" | ||
84 | vim --version | head -n 3 | ||
85 | |||
86 | # test if the terminal support 256 colors, if so, configure the color file | ||
87 | if [ $(tput colors) -ge 256 ]; then | ||
88 | color_file=$VIMRUNTIME/colors/$color_file | ||
89 | echo -e "\033[32mConfiguring $color_file as transparent...\033[0m" | ||
90 | sudo sed -i '/if s:t_Co >= 256/,/hi Normal/{s/hi Normal/" hi/}' $color_file | ||
91 | sudo sed -i '/if s:t_Co >= 256/,/hi EndOfBuffer/{s/hi EndOfBuffer/" hi/}' $color_file | ||
92 | fi | ||
93 | |||
94 | echo -e "\033[32;36mDone.\033[0m" | ||
diff --git a/vim/vimrc.tiny b/vim/vimrc.tiny deleted file mode 100644 index 890037a..0000000 --- a/vim/vimrc.tiny +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | " Vim configuration file, in effect when invoked as "vi". The aim of this | ||
2 | " configuration file is to provide a Vim environment as compatible with the | ||
3 | " original vi as possible. Note that ~/.vimrc configuration files as other | ||
4 | " configuration files in the runtimepath are still sourced. | ||
5 | " When Vim is invoked differently ("vim", "view", "evim", ...) this file is | ||
6 | " _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are. | ||
7 | |||
8 | " Debian system-wide default configuration Vim | ||
9 | set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after | ||
10 | |||
11 | set compatible | ||
12 | |||
13 | " vim: set ft=vim: | ||
diff --git a/vim/vimrc_origin b/vim/vimrc_origin deleted file mode 100644 index 1fcd4d7..0000000 --- a/vim/vimrc_origin +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by | ||
2 | " the call to :runtime you can find below. If you wish to change any of those | ||
3 | " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim | ||
4 | " will be overwritten everytime an upgrade of the vim packages is performed. | ||
5 | " It is recommended to make changes after sourcing debian.vim since it alters | ||
6 | " the value of the 'compatible' option. | ||
7 | |||
8 | runtime! debian.vim | ||
9 | |||
10 | " Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc. | ||
11 | " This happens after /etc/vim/vimrc(.local) are loaded, so it will override | ||
12 | " any settings in these files. | ||
13 | " If you don't want that to happen, uncomment the below line to prevent | ||
14 | " defaults.vim from being loaded. | ||
15 | " let g:skip_defaults_vim = 1 | ||
16 | |||
17 | " Uncomment the next line to make Vim more Vi-compatible | ||
18 | " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous | ||
19 | " options, so any other options should be set AFTER setting 'compatible'. | ||
20 | "set compatible | ||
21 | |||
22 | " Vim5 and later versions support syntax highlighting. Uncommenting the next | ||
23 | " line enables syntax highlighting by default. | ||
24 | if has("syntax") | ||
25 | syntax on | ||
26 | endif | ||
27 | |||
28 | " If using a dark background within the editing area and syntax highlighting | ||
29 | " turn on this option as well | ||
30 | "set background=dark | ||
31 | |||
32 | " Uncomment the following to have Vim jump to the last position when | ||
33 | " reopening a file | ||
34 | "au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | ||
35 | |||
36 | " Uncomment the following to have Vim load indentation rules and plugins | ||
37 | " according to the detected filetype. | ||
38 | "filetype plugin indent on | ||
39 | |||
40 | " The following are commented out as they cause vim to behave a lot | ||
41 | " differently from regular Vi. They are highly recommended though. | ||
42 | "set showcmd " Show (partial) command in status line. | ||
43 | "set showmatch " Show matching brackets. | ||
44 | "set ignorecase " Do case insensitive matching | ||
45 | "set smartcase " Do smart case matching | ||
46 | "set incsearch " Incremental search | ||
47 | "set autowrite " Automatically save before commands like :next and :make | ||
48 | "set hidden " Hide buffers when they are abandoned | ||
49 | "set mouse=a " Enable mouse usage (all modes) | ||
50 | |||
51 | " Source a global configuration file if available | ||
52 | if filereadable("/etc/vim/vimrc.local") | ||
53 | source /etc/vim/vimrc.local | ||
54 | endif | ||
55 | |||
diff --git a/vim/vimrcs/codecmd.vim b/vim/vimrcs/codecmd.vim index cbe08bf..278e4f0 100644 --- a/vim/vimrcs/codecmd.vim +++ b/vim/vimrcs/codecmd.vim | |||
@@ -5,9 +5,10 @@ set softtabstop=4 | |||
5 | autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab | 5 | autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab |
6 | 6 | ||
7 | set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处 | 7 | set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处 |
8 | set wrap " 设置自动折行 | 8 | set nowrap " 设置自动折行 |
9 | |||
9 | set textwidth=500 " 设置自动换行的长度 | 10 | set textwidth=500 " 设置自动换行的长度 |
10 | set lbr | 11 | set lbr " 设置自动换行 |
11 | set foldmethod=syntax " 设置按语法折叠代码 | 12 | set foldmethod=syntax " 设置按语法折叠代码 |
12 | set nofoldenable " 在打开文件时不要折叠 | 13 | set nofoldenable " 在打开文件时不要折叠 |
13 | 14 | ||
@@ -21,12 +22,12 @@ autocmd FileType php set omnifunc=phpcomplete#CompletePHP | |||
21 | autocmd FileType c set omnifunc=ccomplete#Complete | 22 | autocmd FileType c set omnifunc=ccomplete#Complete |
22 | 23 | ||
23 | " 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 | 24 | " 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 |
24 | autocmd BufReadPost,BufWritePre *.html,*.vim normal! g1G=G`"z<CR> | 25 | autocmd BufReadPost,BufWritePre *.html,*.vim,*.sh,*.py normal! g1G=G`"z<CR> |
25 | " 在保存时自动使用clang-format格式化代码 | 26 | " 在保存时自动使用clang-format格式化代码 |
26 | augroup FormatAutocmd | 27 | augroup FormatAutocmd |
27 | autocmd! | 28 | autocmd! |
28 | autocmd BufWritePre *.c,*.cpp,*.h :normal! ggVG | ||
29 | autocmd BufWritePre *.c,*.cpp,*.h :let save_cursor = getpos(".") | 29 | autocmd BufWritePre *.c,*.cpp,*.h :let save_cursor = getpos(".") |
30 | autocmd BufWritePre *.c,*.cpp,*.h :normal! ggVG | ||
30 | autocmd BufWritePre *.c,*.cpp,*.h :ClangFormat | 31 | autocmd BufWritePre *.c,*.cpp,*.h :ClangFormat |
31 | autocmd BufWritePost *.c,*.cpp,*.h :call setpos('.', save_cursor) | 32 | autocmd BufWritePost *.c,*.cpp,*.h :call setpos('.', save_cursor) |
32 | augroup END | 33 | augroup END |
diff --git a/vim/vimrcs/keybind.vim b/vim/vimrcs/keybind.vim index 123c82d..5f90e19 100644 --- a/vim/vimrcs/keybind.vim +++ b/vim/vimrcs/keybind.vim | |||
@@ -3,9 +3,9 @@ map H 0 | |||
3 | map J :<C-u>exe "normal! ".v:count1*10."j"<CR> | 3 | map J :<C-u>exe "normal! ".v:count1*10."j"<CR> |
4 | map K :<C-u>exe "normal! ".v:count1*10."k"<CR> | 4 | map K :<C-u>exe "normal! ".v:count1*10."k"<CR> |
5 | map L $ | 5 | map L $ |
6 | nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面 | 6 | nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面 |
7 | nmap <c-s> :w !sudo tee %<cr>L<cr> | 7 | nmap <c-s> :w !sudo tee %<cr>L<cr> |
8 | nmap <leader>p <c-x><c-f> "补全路径 | 8 | nmap <leader>p <c-x><c-f> "补全路径 |
9 | " nmap <C-tab> :tabn<CR> | 9 | " nmap <C-tab> :tabn<CR> |
10 | nmap <tab> :tabp<CR> | 10 | nmap <tab> :tabp<CR> |
11 | " nmap <alt-tab> :tabnew<CR> | 11 | " nmap <alt-tab> :tabnew<CR> |
diff --git a/vim/vimrcs/match.vim b/vim/vimrcs/match.vim index 0b2c19b..897b3c7 100644 --- a/vim/vimrcs/match.vim +++ b/vim/vimrcs/match.vim | |||
@@ -1,17 +1,14 @@ | |||
1 | " 各类符号自动匹配 | 1 | " 各类符号自动匹配 |
2 | inoremap { {<CR>}<ESC>O | ||
3 | " :inoremap { {}<ESC>i | ||
4 | " :inoremap } <c-r>=ClosePair('}')<CR> | ||
5 | :inoremap ( ()<ESC>i | 2 | :inoremap ( ()<ESC>i |
6 | :inoremap ) <c-r>=ClosePair(')')<CR> | 3 | :inoremap ) <c-r>=ClosePair(')')<CR> |
7 | :inoremap [ []<ESC>i | 4 | :inoremap [ []<ESC>i |
8 | :inoremap ] <c-r>=ClosePair(']')<CR> | 5 | :inoremap ] <c-r>=ClosePair(']')<CR> |
9 | :inoremap " ""<ESC>i | 6 | :inoremap { {}<ESC>i |
10 | :inoremap ' ''<ESC>i | 7 | :inoremap } <c-r>=ClosePair('}')<CR> |
11 | 8 | ||
12 | function ClosePair(char) | 9 | function ClosePair(char) |
13 | if getline('.')[col('.') - 1] == a:char | 10 | if getline('.')[col('.') - 1] == a:char |
14 | return "<Right>" | 11 | return "\<Right>" |
15 | else | 12 | else |
16 | return a:char | 13 | return a:char |
17 | endif | 14 | endif |
diff --git a/vim/vimrcs/plugs.vim b/vim/vimrcs/plugs.vim index d71b846..3426b6a 100644 --- a/vim/vimrcs/plugs.vim +++ b/vim/vimrcs/plugs.vim | |||
@@ -53,7 +53,6 @@ let NERDTreeShowHidden=1 " | |||
53 | let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] " 过滤: 所有指定文件和文件夹不显示 | 53 | let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] " 过滤: 所有指定文件和文件夹不显示 |
54 | autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif " 在每个标签页打开相同的文件树 | 54 | autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif " 在每个标签页打开相同的文件树 |
55 | 55 | ||
56 | |||
57 | " nerdtree-git-plugin | 56 | " nerdtree-git-plugin |
58 | let g:NERDTreeGitStatusIndicatorMapCustom = { | 57 | let g:NERDTreeGitStatusIndicatorMapCustom = { |
59 | \ 'Dirty' :'Dty', | 58 | \ 'Dirty' :'Dty', |
@@ -115,7 +114,7 @@ map <F3> :silent Tlist<CR> " 按下F3就可以呼出了 | |||
115 | map <space>tl :silent Tlist<CR> " 按下<space>tl就可以呼出了 | 114 | map <space>tl :silent Tlist<CR> " 按下<space>tl就可以呼出了 |
116 | let Tlist_Ctags_Cmd='/usr/local/bin/ctags' " 因为我们放在环境变量里,所以可以直接执行 | 115 | let Tlist_Ctags_Cmd='/usr/local/bin/ctags' " 因为我们放在环境变量里,所以可以直接执行 |
117 | let Tlist_Use_Right_Window=1 " 让窗口显示在右边,0的话就是显示在左边 | 116 | let Tlist_Use_Right_Window=1 " 让窗口显示在右边,0的话就是显示在左边 |
118 | let Tlist_Show_One_File=0 " 让taglist可以同时展示多个文件的函数列表 | 117 | let Tlist_Show_One_File=1 " 让taglist可以同时展示多个文件的函数列表 |
119 | let Tlist_File_Fold_Auto_Close=0 " 非当前文件列表折叠隐藏 | 118 | let Tlist_File_Fold_Auto_Close=0 " 非当前文件列表折叠隐藏 |
120 | let Tlist_Exit_OnlyWindow=1 " 当taglist是最后一个分割窗口时,自动推出vim | 119 | let Tlist_Exit_OnlyWindow=1 " 当taglist是最后一个分割窗口时,自动推出vim |
121 | let Tlist_Process_File_Always=1 " 是否一直处理tags.1:处理;0:不处理 | 120 | let Tlist_Process_File_Always=1 " 是否一直处理tags.1:处理;0:不处理 |
diff --git a/vim/vimscript.vim b/vim/vimscript.vim deleted file mode 100644 index 001b060..0000000 --- a/vim/vimscript.vim +++ /dev/null | |||
@@ -1,295 +0,0 @@ | |||
1 | " 主要参考 http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html | ||
2 | " 额外添加了 ctags, YouCompleteMe等 | ||
3 | " 主要特点 | ||
4 | |||
5 | "1.按F5可以直接编译并执行C、C++、java代码以及执行shell脚本,按“F8”可进行C、C++代码的调试 | ||
6 | "2.自动插入文件头 ,新建C、C++源文件时自动插入表头:包括文件名、作者、联系方式、建立时间等,读者可根据需求自行更改 | ||
7 | "3.映射“Ctrl + A”为全选并复制快捷键,方便复制代码 | ||
8 | "4.按“F2”可以直接消除代码中的空行 | ||
9 | "5.“F3”可列出当前目录文件,打开树状文件目录 | ||
10 | "6. 支持鼠标选择、方向键移动 | ||
11 | "7. 代码高亮,自动缩进,显示行号,显示状态行 | ||
12 | "8. 按“Ctrl + P”可自动补全 | ||
13 | "9. []、{}、()、""、‘ ‘等都自动补全 --- 如果需要{}做函数形式的补全(右括号自动换行,加一个空行,光标定位到空行,可以看下面的修改提示) | ||
14 | "10. 使用YouCompleteMe提供C++的自动补全提示,效果类似 Visual Studio那种,可以解析系统头文件 | ||
15 | |||
16 | |||
17 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
18 | " """""""""""""" Suzzz """"""""""""""""""""" | ||
19 | "https://github.com/gmarik/Vundle.vim#about | ||
20 | |||
21 | set nocompatible " be iMproved, required | ||
22 | filetype off " required | ||
23 | |||
24 | set rtp+=~/.vim/bundle/Vundle.vim | ||
25 | |||
26 | call vundle#begin() | ||
27 | " let Vundle manage Vundle, required | ||
28 | Plugin "gmarik/Vundle.vim" | ||
29 | " plugin on GitHub repo 添加github上的vimn插件,形式非常简单 | ||
30 | Plugin "tpope/vim-fugitive" | ||
31 | "语法检查 | ||
32 | Plugin "scrooloose/syntastic" | ||
33 | "让 syntastic忽略 python 文件 | ||
34 | let g:syntastic_ignore_files=[".*\.py$"] | ||
35 | "补全 python | ||
36 | Plugin "davidhalter/jedi" | ||
37 | Plugin "rstacruz/sparkup", {"rtp": "vim/"} | ||
38 | " YouCompleteMe插件,很好的智能提示,基本达到 IDE 级别 | ||
39 | Plugin "Valloric/YouCompleteMe" | ||
40 | |||
41 | call vundle#end() " required | ||
42 | |||
43 | filetype plugin indent on " required | ||
44 | " To ignore plugin indent changes, instead use: | ||
45 | "filetype plugin on | ||
46 | " YouCompleteMe 通过这个cm_global_ycm_extra_conf来获得补全规则,可以如下指定,也可以每次放置在工作目录 | ||
47 | let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘ | ||
48 | "让YouCompleteMe同时利用原来的ctags | ||
49 | let g:ycm_collect_identifiers_from_tag_files = 1 | ||
50 | |||
51 | " """"""""""""" By ma6174 """"""""""""""""""""" | ||
52 | " 显示相关 | ||
53 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
54 | autocmd InsertLeave * se nocul " 用浅色高亮当前行 | ||
55 | autocmd InsertEnter * se cul " 用浅色高亮当前行 | ||
56 | "set ruler " 显示标尺 | ||
57 | set showcmd " 输入的命令显示出来,看的清楚些 | ||
58 | "set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议) | ||
59 | "set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 | ||
60 | set novisualbell " 不要闪烁(不明白) | ||
61 | "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容 | ||
62 | set laststatus=2 " 启动显示状态行(1),总是显示状态行(2) | ||
63 | "set foldenable " 允许折叠 | ||
64 | "set foldmethod=manual " 手动折叠 | ||
65 | "set background=dark "背景使用黑色 | ||
66 | " 显示中文帮助 | ||
67 | if version >= 603 | ||
68 | set helplang=cn | ||
69 | set encoding=utf-8 | ||
70 | endif | ||
71 | |||
72 | set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 | ||
73 | set termencoding=utf-8 | ||
74 | set encoding=utf-8 | ||
75 | set fileencodings=ucs-bom,utf-8,cp936 | ||
76 | set fileencoding=utf-8 | ||
77 | |||
78 | "键盘命令 | ||
79 | |||
80 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
81 | |||
82 | "map <C-A> ggVGY | ||
83 | "map! <C-A> <Esc>ggVGY | ||
84 | "map <F12> gg=G | ||
85 | ""去空行 | ||
86 | "nnoremap <F2> :g/^\s*$/d<CR> | ||
87 | |||
88 | "比较文件 | ||
89 | nnoremap <C-F2> :vert diffsplit | ||
90 | |||
91 | "列出当前目录文件 | ||
92 | map <F3> :tabnew .<CR> | ||
93 | |||
94 | "打开树状文件目录 | ||
95 | map <C-F3> \be | ||
96 | |||
97 | "C,C++ 按F5编译运行 | ||
98 | map <F5> :call CompileRunGcc()<CR> | ||
99 | |||
100 | func! CompileRunGcc() | ||
101 | |||
102 | exec "w" | ||
103 | if &filetype == ‘c‘ | ||
104 | exec "!g++ % -o %<" | ||
105 | exec "! ./%<" | ||
106 | elseif &filetype == ‘cpp‘ | ||
107 | exec "!g++ % -o %<" | ||
108 | exec "! ./%<" | ||
109 | elseif &filetype == ‘java‘ | ||
110 | exec "!javac %" | ||
111 | exec "!java %<" | ||
112 | elseif &filetype == ‘sh‘ | ||
113 | :!./% | ||
114 | endif | ||
115 | endfunc | ||
116 | |||
117 | "C,C++的调试 | ||
118 | |||
119 | map <F8> :call Rungdb()<CR> | ||
120 | |||
121 | func! Rungdb() | ||
122 | exec "w" | ||
123 | exec "!g++ % -g -o %<" | ||
124 | exec "!gdb ./%<" | ||
125 | endfunc | ||
126 | |||
127 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
128 | |||
129 | ""实用设置 | ||
130 | |||
131 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
132 | |||
133 | " 设置当文件被改动时自动载入 | ||
134 | set autoread | ||
135 | |||
136 | " quickfix模式 | ||
137 | autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr> | ||
138 | |||
139 | "代码补全 | ||
140 | set completeopt=preview,menu | ||
141 | |||
142 | "允许插件 | ||
143 | filetype plugin on | ||
144 | |||
145 | "共享剪贴板 | ||
146 | set clipboard+=unnamed | ||
147 | |||
148 | "从不备份 | ||
149 | "set nobackup | ||
150 | |||
151 | "make 运行 | ||
152 | :set makeprg=g++\ -Wall\ \ % | ||
153 | |||
154 | "自动保存 | ||
155 | set autowrite | ||
156 | |||
157 | set ruler " 打开状态栏标尺 | ||
158 | set cursorline " 突出显示当前行 | ||
159 | set magic " 设置魔术 | ||
160 | set guioptions-=T " 隐藏工具栏 | ||
161 | set guioptions-=m " 隐藏菜单栏 | ||
162 | " 设置在状态行显示的信息 | ||
163 | "set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ | ||
164 | |||
165 | "set foldcolumn=0 | ||
166 | "set foldmethod=indent | ||
167 | "set foldlevel=3 | ||
168 | "set foldenable " 开始折叠 | ||
169 | |||
170 | " 去掉输入错误的提示声音 | ||
171 | set noeb | ||
172 | |||
173 | " 在处理未保存或只读文件的时候,弹出确认 | ||
174 | set confirm | ||
175 | |||
176 | " 自动缩进 | ||
177 | "set autoindent | ||
178 | "set cindent | ||
179 | |||
180 | " 在行和段开始处使用制表符 | ||
181 | set smarttab | ||
182 | |||
183 | " 历史记录数 | ||
184 | set history=1000 | ||
185 | |||
186 | "禁止生成临时文件 | ||
187 | set noswapfile | ||
188 | |||
189 | "搜索忽略大小写 | ||
190 | set ignorecase | ||
191 | |||
192 | "搜索逐字符高亮 | ||
193 | set hlsearch | ||
194 | set incsearch | ||
195 | |||
196 | "行内替换 | ||
197 | set gdefault | ||
198 | |||
199 | "语言设置 | ||
200 | set langmenu=zh_CN.UTF-8 | ||
201 | set helplang=cn | ||
202 | |||
203 | " 我的状态行显示的内容(包括文件类型和解码) | ||
204 | "set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} | ||
205 | "set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] | ||
206 | |||
207 | " 总是显示状态行 | ||
208 | set laststatus=2 | ||
209 | |||
210 | " 命令行(在状态行下)的高度,默认为1,这里是2 | ||
211 | set cmdheight=2 | ||
212 | |||
213 | " 带有如下符号的单词不要被换行分割 | ||
214 | set iskeyword+=_,$,@,%,#,- | ||
215 | |||
216 | set selection=exclusive | ||
217 | set selectmode=mouse,key | ||
218 | |||
219 | " 通过使用: commands命令,告诉我们文件的哪一行被改变过 | ||
220 | set report=0 | ||
221 | |||
222 | " 光标移动到buffer的顶部和底部时保持3行距离 | ||
223 | set scrolloff=3 | ||
224 | |||
225 | " 为C程序提供自动缩进 | ||
226 | |||
227 | " 高亮显示普通txt文件(需要txt.vim脚本) | ||
228 | |||
229 | au BufRead,BufNewFile * setfiletype txt | ||
230 | |||
231 | "自动补全 | ||
232 | "by Suzzz: 原作者这种设置,输入{会自动补全,并且中间插入一个空行,将光标定位到空行。这对于函数是OK的,但是使用花括号初始化数组、vector时就不方便了。所以改为现在这种。只是补全,然后光标在左右括号中间。 | ||
233 | ":inoremap { {<CR>}<ESC>O | ||
234 | :inoremap ( ()<ESC>i | ||
235 | :inoremap ) <c-r>=ClosePair(‘)‘)<CR> | ||
236 | :inoremap { {}<ESC>i | ||
237 | :inoremap } <c-r>=ClosePair(‘}‘)<CR> | ||
238 | :inoremap [ []<ESC>i | ||
239 | :inoremap ] <c-r>=ClosePair(‘]‘)<CR> | ||
240 | :inoremap " ""<ESC>i | ||
241 | :inoremap ‘ ‘‘<ESC>i | ||
242 | |||
243 | function! ClosePair(char) | ||
244 | if getline(‘.‘)[col(‘.‘) - 1] == a:char | ||
245 | return "\<Right>" | ||
246 | else | ||
247 | return a:char | ||
248 | endif | ||
249 | endfunction | ||
250 | |||
251 | set completeopt=longest,menu | ||
252 | |||
253 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
254 | |||
255 | " CTags的设定 | ||
256 | |||
257 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
258 | |||
259 | let Tlist_Sort_Type = "name" " 按照名称排序 | ||
260 | let Tlist_Use_Right_Window = 1 " 在右侧显示窗口 | ||
261 | let Tlist_Compart_Format = 1 " 压缩方式 | ||
262 | let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer,kill窗口也kill掉buffer | ||
263 | let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags | ||
264 | let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树 | ||
265 | autocmd FileType java set tags+=D:\tools\java\tags | ||
266 | "autocmd FileType h,cpp,cc,c set tags+=D:\tools\cpp\tags | ||
267 | "let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的 | ||
268 | "设置tags | ||
269 | set tags=tags | ||
270 | "set autochdir | ||
271 | |||
272 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
273 | |||
274 | "其他东东 | ||
275 | |||
276 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
277 | |||
278 | "默认打开Taglist | ||
279 | let Tlist_Auto_Open=1 | ||
280 | |||
281 | """""""""""""""""""""""""""""" | ||
282 | |||
283 | " Tag list (ctags) | ||
284 | |||
285 | """""""""""""""""""""""""""""""" | ||
286 | |||
287 | let Tlist_Ctags_Cmd = ‘/usr/bin/ctags‘ | ||
288 | let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的 | ||
289 | let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim | ||
290 | let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口 | ||
291 | " minibufexpl插件的一般设置 | ||
292 | let g:miniBufExplMapWindowNavVim = 1 | ||
293 | let g:miniBufExplMapWindowNavArrows = 1 | ||
294 | let g:miniBufExplMapCTabSwitchBufs = 1 | ||
295 | let g:miniBufExplModSelTarget = 1 | ||