diff options
author | 2024-12-20 11:55:11 +0800 | |
---|---|---|
committer | 2024-12-20 11:55:11 +0800 | |
commit | c9f6228370e4302e577ae346cdcd54169fe78fb1 (patch) | |
tree | 25b8f6b2d196a72aa80626290e1f78a31c07edc9 | |
download | vimrc-c9f6228370e4302e577ae346cdcd54169fe78fb1.tar.gz vimrc-c9f6228370e4302e577ae346cdcd54169fe78fb1.zip |
Original commit.
vimrc the system vimrc, used to import other config files
vimrcs real config files
vimrcs/codecmd.vim: set sth about code, such as formatter, head of
file, etc.
vimrcs/keybind.vim keyboard shortcut
vimrcs/match.vim bracket matching
vimrcs/myset.vim color scheme and other showoff
vimrcs/plugs.vim vim plugin and relative set
vimrcs/statusline.vim style of status line
-rw-r--r-- | vimrc | 14 | ||||
-rw-r--r-- | vimrcs/codecmd.vim | 85 | ||||
-rw-r--r-- | vimrcs/keybind.vim | 41 | ||||
-rw-r--r-- | vimrcs/match.vim | 15 | ||||
-rw-r--r-- | vimrcs/myset.vim | 38 | ||||
-rw-r--r-- | vimrcs/plugs.vim | 153 | ||||
-rw-r--r-- | vimrcs/statusline.vim | 70 |
7 files changed, 416 insertions, 0 deletions
@@ -0,0 +1,14 @@ | |||
1 | set nocompatible " 关闭兼容模式 | ||
2 | |||
3 | let vimrcs = { | ||
4 | \ "plugs": "Vundle插件管理及插件内容", | ||
5 | \ "statusline": "状态栏与标签页设置", | ||
6 | \ "codecmd": "代码设置", | ||
7 | \ "keybind": "自己设的快捷键", | ||
8 | \ "match": "符号自动匹配", | ||
9 | \ "myset": "自行设置", | ||
10 | \ } | ||
11 | |||
12 | for vimrc in keys(vimrcs) | ||
13 | execute "source /etc/vim/vimrcs/".vimrc.".vim" | ||
14 | endfor | ||
diff --git a/vimrcs/codecmd.vim b/vimrcs/codecmd.vim new file mode 100644 index 0000000..4fb5ab9 --- /dev/null +++ b/vimrcs/codecmd.vim | |||
@@ -0,0 +1,85 @@ | |||
1 | set expandtab " 设置tab键替换为tabstop规定的空格数 | ||
2 | set tabstop=4 " 编辑时tab键占用的空格数 | ||
3 | set shiftwidth=4 " 设置tab的间隔(格式化时) | ||
4 | set softtabstop=4 " 设置退格键退格的空格数,让vim把连续的空格当作一个tab | ||
5 | autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab | ||
6 | |||
7 | set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处 | ||
8 | set nowrap " 设置自动折行 | ||
9 | |||
10 | set textwidth=500 " 设置自动换行的长度 | ||
11 | set lbr " 设置自动换行 | ||
12 | set foldmethod=syntax " 设置按语法折叠代码 | ||
13 | set nofoldenable " 在打开文件时不要折叠 | ||
14 | |||
15 | " 自动补全配置 | ||
16 | autocmd FileType python set omnifunc=pythoncomplete#Complete | ||
17 | autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS | ||
18 | autocmd FileType html set omnifunc=htmlcomplete#CompleteTags | ||
19 | autocmd FileType css set omnifunc=csscomplete#CompleteCSS | ||
20 | autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags | ||
21 | autocmd FileType php set omnifunc=phpcomplete#CompletePHP | ||
22 | autocmd FileType c set omnifunc=ccomplete#Complete | ||
23 | |||
24 | " 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 | ||
25 | autocmd BufReadPost,BufWritePre *.html,*.vim,*.sh,*.py normal! g1G=G`"z<CR> | ||
26 | " 在保存时自动使用clang-format格式化代码 | ||
27 | augroup FormatAutocmd | ||
28 | autocmd! | ||
29 | autocmd BufWritePre *.c,*.cpp,*.h :let save_cursor = getpos(".") | ||
30 | autocmd BufWritePre *.c,*.cpp,*.h :normal! ggVG | ||
31 | autocmd BufWritePre *.c,*.cpp,*.h :ClangFormat | ||
32 | autocmd BufWritePost *.c,*.cpp,*.h :call setpos('.', save_cursor) | ||
33 | augroup END | ||
34 | " 定义ClangFormat命令 | ||
35 | command! -nargs=0 ClangFormat :silent %!clang-format -style="{IndentWidth: 4}" | ||
36 | " 映射gg=G到ClangFormat | ||
37 | autocmd FileType c,h,cpp,hpp,cc nnoremap <buffer> gg=G :ClangFormat<CR> | ||
38 | |||
39 | " 新建.c/.cpp/.sh/.py文件,自动插入文件头 | ||
40 | autocmd BufNewFile *.cpp,*.[ch],*.sh exec ":call SetTitle()" | ||
41 | func SetTitle() | ||
42 | if &filetype == 'sh' | ||
43 | call setline(1,"#!/bin/bash") | ||
44 | call append(line("."), "" ) | ||
45 | call append(line(".")+1, "\##########################################################################" ) | ||
46 | call append(line(".")+2, "\# File Name : ".expand("%")) | ||
47 | call append(line(".")+3, "\# Encoding : utf-8") | ||
48 | call append(line(".")+4, "\# Author : We-unite") | ||
49 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") | ||
50 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d %H:%M:%S",localtime())) | ||
51 | call append(line(".")+7, "\##########################################################################" ) | ||
52 | call append(line(".")+8, "") | ||
53 | elseif &filetype =='py' | ||
54 | call setline(1,"#!/usr/bin/env python") | ||
55 | call append(line("."), "" ) | ||
56 | call append(line(".")+1, "\##########################################################################" ) | ||
57 | call append(line(".")+2, "\# File Name : ".expand("%")) | ||
58 | call append(line(".")+3, "\# Encoding : utf-8") | ||
59 | call append(line(".")+4, "\# Author : We-unite") | ||
60 | call append(line(".")+5, "\# Email : weunite1848@gmail.com") | ||
61 | call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d %H:%M:%S",localtime())) | ||
62 | call append(line(".")+7, "\##########################################################################" ) | ||
63 | call append(line(".")+8, "") | ||
64 | else | ||
65 | call setline(1, "/*************************************************************************") | ||
66 | call append(line("."), " > File Name : ".expand("%")) | ||
67 | call append(line(".")+1, " > Encoding : utf-8") | ||
68 | call append(line(".")+2, " > Author : We-unite") | ||
69 | call append(line(".")+3, " > Email : weunite1848@gmail.com ") | ||
70 | call append(line(".")+4, " > Created Time : ".strftime("%Y-%m-%d %H:%M:%S",localtime())) | ||
71 | call append(line(".")+5, " ************************************************************************/") | ||
72 | call append(line(".")+6, "") | ||
73 | if &filetype == 'cpp' | ||
74 | call append(line(".")+7, "#include <iostream>") | ||
75 | call append(line(".")+8, "using namespace std;") | ||
76 | call append(line(".")+9, "") | ||
77 | elseif &filetype == 'c' | ||
78 | call append(line(".")+7, "#include <stdio.h>") | ||
79 | call append(line(".")+8, "#include <stdlib.h>") | ||
80 | call append(line(".")+9, "") | ||
81 | endif | ||
82 | endif | ||
83 | " 光标移动到文件末尾 | ||
84 | normal G | ||
85 | endfunc | ||
diff --git a/vimrcs/keybind.vim b/vimrcs/keybind.vim new file mode 100644 index 0000000..2cb0778 --- /dev/null +++ b/vimrcs/keybind.vim | |||
@@ -0,0 +1,41 @@ | |||
1 | " 设置leader为space | ||
2 | let mapleader = "\<Space>" | ||
3 | map - dd | ||
4 | map H 0 | ||
5 | map <silent> J :<C-u>exe "normal! ".v:count1*10."j"<CR> | ||
6 | map <silent> K :<C-u>exe "normal! ".v:count1*10."k"<CR> | ||
7 | vmap <silent> J :<C-u>exe "normal! ".v:count1*10."j"<CR> | ||
8 | vmap <silent> K :<C-u>exe "normal! ".v:count1*10."k"<CR> | ||
9 | map L $ | ||
10 | nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面 | ||
11 | nmap <c-s> :w !sudo tee %<cr>L<cr> | ||
12 | nmap <leader>p <c-x><c-f> "补全路径 | ||
13 | " nmap <C-tab> :tabn<CR> | ||
14 | nmap <tab> :tabp<CR> | ||
15 | nmap <M-tab> :tabnew<CR> | ||
16 | " map <space>= <buffer><esc>:vertical resize +5<cr> | ||
17 | " map <space>- <esc>:vertical resize -5<cr> | ||
18 | |||
19 | nnoremap <M-1> 1gt | ||
20 | nnoremap <M-2> 2gt | ||
21 | nnoremap <M-3> 3gt | ||
22 | nnoremap <M-4> 4gt | ||
23 | nnoremap <M-5> 5gt | ||
24 | nnoremap <M-6> 6gt | ||
25 | nnoremap <M-7> 7gt | ||
26 | nnoremap <M-8> 8gt | ||
27 | nnoremap <M-9> 9gt | ||
28 | nnoremap <M-0> :tablast<CR> | ||
29 | |||
30 | " 光标在页面间切换 | ||
31 | nnoremap <leader>h <C-w><C-h> | ||
32 | nnoremap <leader>j <C-w><C-j> | ||
33 | nnoremap <leader>k <C-w><C-k> | ||
34 | nnoremap <leader>l <C-w><C-l> | ||
35 | |||
36 | " 复制粘贴 | ||
37 | vnoremap <C-y> "+y | ||
38 | nnoremap <C-p> "+p | ||
39 | |||
40 | " 按下Ctrl+`时,使用:terminal打开终端,显示在当前窗口的下边 | ||
41 | nnoremap <C-`> :terminal<CR> | ||
diff --git a/vimrcs/match.vim b/vimrcs/match.vim new file mode 100644 index 0000000..897b3c7 --- /dev/null +++ b/vimrcs/match.vim | |||
@@ -0,0 +1,15 @@ | |||
1 | " 各类符号自动匹配 | ||
2 | :inoremap ( ()<ESC>i | ||
3 | :inoremap ) <c-r>=ClosePair(')')<CR> | ||
4 | :inoremap [ []<ESC>i | ||
5 | :inoremap ] <c-r>=ClosePair(']')<CR> | ||
6 | :inoremap { {}<ESC>i | ||
7 | :inoremap } <c-r>=ClosePair('}')<CR> | ||
8 | |||
9 | function ClosePair(char) | ||
10 | if getline('.')[col('.') - 1] == a:char | ||
11 | return "\<Right>" | ||
12 | else | ||
13 | return a:char | ||
14 | endif | ||
15 | endfunction | ||
diff --git a/vimrcs/myset.vim b/vimrcs/myset.vim new file mode 100644 index 0000000..19848f0 --- /dev/null +++ b/vimrcs/myset.vim | |||
@@ -0,0 +1,38 @@ | |||
1 | set encoding=utf-8 | ||
2 | set fileencoding=utf-8 | ||
3 | set fileencodings=ucs-bom,utf-8,GB18030,cp936,big5,euc-jp,euc-kr,latin1 | ||
4 | set fileformat=unix | ||
5 | set helplang=cn " 帮助中文支持 | ||
6 | set mouse=a " 设置鼠标 | ||
7 | set noeb " 去掉输入错误的提示声音 | ||
8 | set confirm " 在处理未保存或只读文件的时候,弹出确认 | ||
9 | set langmenu=zh_CN.UTF-8 | ||
10 | set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 | ||
11 | set vb t_vb= " 关闭错误提示声音 | ||
12 | |||
13 | set rnu " 设置相对行号 | ||
14 | set nu " 设置绝对行号 | ||
15 | " Set cursor shape and color | ||
16 | if &term =~ "xterm" | ||
17 | " INSERT mode | ||
18 | let &t_SI = "\<Esc>[6 q" . "\<Esc>]12;blue\x7" | ||
19 | " REPLACE mode | ||
20 | let &t_SR = "\<Esc>[3 q" . "\<Esc>]12;black\x7" | ||
21 | " NORMAL mode | ||
22 | let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7" | ||
23 | endif | ||
24 | " 1 -> blinking block 闪烁的方块 | ||
25 | " 2 -> solid block 不闪烁的方块 | ||
26 | " 3 -> blinking underscore 闪烁的下划线 | ||
27 | " 4 -> solid underscore 不闪烁的下划线 | ||
28 | " 5 -> blinking vertical bar 闪烁的竖线 | ||
29 | " 6 -> solid vertical bar 不闪烁的竖线 | ||
30 | |||
31 | syntax on | ||
32 | set cul | ||
33 | set cuc | ||
34 | set list " 显示tab和空格 | ||
35 | set listchars=tab:>-,trail:- " 设置tab和空格的显示 | ||
36 | colorscheme industry " 设置颜色主题 | ||
37 | autocmd VimEnter * hi CursorLine cterm=NONE ctermbg=darkblue ctermfg=NONE guibg=darkblue guifg=NONE | ||
38 | autocmd VimEnter * hi CursorColumn cterm=NONE ctermbg=darkblue ctermfg=NONE guibg=darkblue guifg=NONE | ||
diff --git a/vimrcs/plugs.vim b/vimrcs/plugs.vim new file mode 100644 index 0000000..4d389a3 --- /dev/null +++ b/vimrcs/plugs.vim | |||
@@ -0,0 +1,153 @@ | |||
1 | " Vundle插件管理器配置 | ||
2 | set nocompatible " 去除VIM一致性,必须 | ||
3 | filetype off " 必须 | ||
4 | |||
5 | " 设置包括vundle和初始化相关的运行时路径" | ||
6 | set rtp+=/home/player/useful/bundle/Vundle.vim | ||
7 | call vundle#begin('/home/player/useful/bundle') | ||
8 | |||
9 | Plugin 'VundleVim/Vundle.vim' " 启用vundle管理插件,必须 | ||
10 | Plugin 'Valloric/YouCompleteMe' " 代码补全插件 | ||
11 | Plugin 'preservim/nerdtree' " 文件目录树插件 | ||
12 | Plugin 'Xuyuanp/nerdtree-git-plugin' " nerdtree git支持 | ||
13 | Plugin 'scrooloose/syntastic' " 语法检查插件 | ||
14 | Plugin 'github/copilot.vim' " GitHub Copilot插件 | ||
15 | Plugin 'voldikss/vim-translator' " 翻译插件 | ||
16 | Plugin 'yegappan/taglist' " taglist插件 | ||
17 | Plugin 'octol/vim-cpp-enhanced-highlight' " C++语法高亮插件,在原生基础上支持STL等 | ||
18 | Plugin 'nathanaelkane/vim-indent-guides' " 缩进线插件 | ||
19 | Plugin 'scrooloose/nerdcommenter' " 注释插件 | ||
20 | " Plugin 'skywind3000/vim-terminal-help' " vim-terminal-help插件 | ||
21 | " Plugin 'neoclide/coc.nvim' " coc.nvim插件 | ||
22 | " Plugin 'Lokaltog/powerline',{'rtp':'powerline/bindings/vim/'} " 状态栏信息插件 | ||
23 | |||
24 | call vundle#end() | ||
25 | filetype plugin indent on " 加载vim自带和插件相应的语法和文件类型相关脚本,必须 | ||
26 | |||
27 | " YouCompleteMe | ||
28 | let g:ycm_global_ycm_extra_conf = '/home/player/useful/bundle/YouCompleteMe/.ycm_extra_conf.py' | ||
29 | let g:ycm_python_binary_path = '/usr/bin/python' " python路径 | ||
30 | " let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' " C family语言的配置文件 | ||
31 | let g:ycm_confirm_extra_conf = 0 " 停止提示是否载入本地ycm_extra_conf文件 | ||
32 | let g:ycm_use_ultisnips_completer = 1 " 默认载入本地ycm_extra_conf文件 | ||
33 | let g:ycm_min_num_of_chars_for_completion = 2 " 从第2个键入字符就开始罗列匹配项 | ||
34 | let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 从注释和字符串中收集标识符 | ||
35 | let g:ycm_complete_in_comments = 1 " 在注释中也可以补全 | ||
36 | let g:ycm_complete_in_strings = 1 " 在字符串中也可以补全 | ||
37 | let g:ycm_enable_fuzzy_match = 1 " 开启模糊匹配 | ||
38 | let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全 | ||
39 | let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM 基于标签引擎 | ||
40 | let g:ycm_key_list_select_completion = ['<C-n>', '<Down>'] " 选择第1项的快捷键(默认为<TAB>和<Down>) | ||
41 | let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>'] " 选择前1项的快捷键(默认为<S-TAB>和<UP>) | ||
42 | let g:ycm_autoclose_preview_window_after_completion = 1 " 补全后自动关闭预览窗口 | ||
43 | " let g:ycm_key_invoke_completion = ['<C-Space>'] " 主动补全, 默认为<C-Space> | ||
44 | " let g:ycm_key_list_stop_completion = ['<C-y>'] " 停止显示补全列表防影响视野, <C-Space>重新弹出 | ||
45 | let g:ycm_semantic_triggers = { | ||
46 | \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'], | ||
47 | \ 'cs,lua,javascript': ['re!\w{2}'], | ||
48 | \ } | ||
49 | " hi PMenu ctermfg=34 ctermbg=21 guifg=darkred guibg=darkblue | ||
50 | " hi PMenuSel ctermfg=21 ctermbg=34 guifg=darkblue guibg=darkred | ||
51 | hi PMenu ctermfg=darkgrey ctermbg=21 guifg=darkred guibg=darkblue | ||
52 | hi PMenuSel ctermfg=yellow ctermbg=34 guifg=darkblue guibg=darkred | ||
53 | nnoremap gdec :YcmCompleter GoToDeclaration<CR> | ||
54 | nnoremap gdef :YcmCompleter GoToDefinition<CR> | ||
55 | nnoremap gd :YcmCompleter GoToDefinitionElseDeclaration<CR> | ||
56 | nnoremap gr :YcmCompleter GoToReferences<CR> | ||
57 | |||
58 | " NERDTree | ||
59 | " autocmd vimenter * NERDTree "进入vim自动打开nerdtree | ||
60 | " 当nerdtree为当前标签页剩余唯一窗口时自动关闭 | ||
61 | autocmd bufenter * if(winnr('$') ==1 && exists('b:NERDTree') && b:NERDTree.isTabTree()) | quit | endif | ||
62 | nmap T :NERDTreeToggle<CR> " 开关文件目录树,注意shift+i切换是否显示隐藏文件 | ||
63 | let g:NERDTreeDirArrowExpandable = '+' | ||
64 | let g:NERDTreeDirArrowCollapsible = '-' " 修改树的显示图标 | ||
65 | let g:NERDTreeWinPos='left' " 窗口位置 | ||
66 | let g:NERDTreeSize=10 " 窗口尺寸 | ||
67 | let g:NERDTreeShowLineNumbers=1 " 窗口是否显示行号 | ||
68 | let NERDTreeShowHidden=1 " 显示隐藏文件 | ||
69 | let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] " 过滤: 所有指定文件和文件夹不显示 | ||
70 | autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif " 在每个标签页打开相同的文件树 | ||
71 | |||
72 | " nerdtree-git-plugin | ||
73 | let g:NERDTreeGitStatusIndicatorMapCustom = { | ||
74 | \ 'Dirty' :'Dty', | ||
75 | \ 'Modified' :'M', | ||
76 | \ 'Staged' :'Sta', | ||
77 | \ 'Untracked' :'U', | ||
78 | \ 'Renamed' :'R', | ||
79 | \ 'Unmerged' :'Umg', | ||
80 | \ 'Deleted' :'X', | ||
81 | \ 'Ignored' :'Ign', | ||
82 | \ 'Clean' :'Cl', | ||
83 | \ 'Unknown' :'?', | ||
84 | \ } | ||
85 | let g:NERDTreeGitStatusShowIgnored = 1 " a heavy feature may cost much more time. default: 0 | ||
86 | let g:NERDTreeGitStatusUntrackedFilesMode = 'all' " a heavy feature too. default: normal | ||
87 | |||
88 | " vim-terminal-help | ||
89 | " set termwinsize=10*106 | ||
90 | " let g:terminal_key = '' | ||
91 | " 设置光标在终端与编辑器间切换的快捷键 | ||
92 | |||
93 | " syntastic | ||
94 | " YouCompleteMe插件对该插件支持过于优秀,一般不再需要配置,故废弃 | ||
95 | let g:syntastic_python_checkers=['pylint'] | ||
96 | let g:syntastic_python_pylint_args=['--disable=C0111,R0903,C0301'] | ||
97 | " GNU as汇编语言语法检查,需要安装as86和ld86 | ||
98 | let g:syntastic_asm_checkers=['as86'] | ||
99 | " syntastic end | ||
100 | |||
101 | " powerline | ||
102 | let laststatus=2 | ||
103 | let g:airlinr_powerline_fonts=1 " 使用官方打过补丁的字体 | ||
104 | let g:Powerline_symbols='fancy' | ||
105 | |||
106 | " vim-translator | ||
107 | let g:translator_target_lang = 'zh' | ||
108 | let g:translator_source_lang = 'auto' | ||
109 | " let g:translator_default_engines = ['youdao', 'bing', 'google', 'haici'] | ||
110 | let g:translator_default_engines = ['bing'] | ||
111 | let g:translator_history_enable = v:true | ||
112 | let g:translator_window_type = 'popup' " 可选值为 'popup' 和 'preview',默认为 'popup' | ||
113 | " Echo translation in the cmdline | ||
114 | nmap <silent> <Leader>t <Plug>Translate | ||
115 | vmap <silent> <Leader>t <Plug>TranslateV | ||
116 | " Display translation in a window | ||
117 | nmap <silent> <Leader>w <Plug>TranslateW | ||
118 | vmap <silent> <Leader>w <Plug>TranslateWV | ||
119 | " Close the translation window | ||
120 | nmap <silent> <Leader>c <Plug>TranslateC | ||
121 | " Replace the text with translation | ||
122 | nmap <silent> <Leader>r <Plug>TranslateR | ||
123 | vmap <silent> <Leader>r <Plug>TranslateRV | ||
124 | " Translate the text in clipboard | ||
125 | nmap <silent> <Leader>x <Plug>TranslateX | ||
126 | |||
127 | " 进行Taglist的设置 | ||
128 | " map <space>tl Tlist<CR> " | ||
129 | let Tlist_Ctags_Cmd='/usr/local/bin/ctags' " 因为我们放在环境变量里,所以可以直接执行 | ||
130 | let Tlist_Use_Right_Window=1 " 让窗口显示在右边,0的话就是显示在左边 | ||
131 | let Tlist_Show_One_File=1 " 让taglist可以同时展示多个文件的函数列表 | ||
132 | let Tlist_File_Fold_Auto_Close=0 " 非当前文件列表折叠隐藏 | ||
133 | let Tlist_Exit_OnlyWindow=1 " 当taglist是最后一个分割窗口时,自动推出vim | ||
134 | let Tlist_Process_File_Always=1 " 是否一直处理tags.1:处理;0:不处理 | ||
135 | let Tlist_Inc_Winwidth=1 " 不是一直实时更新tags,因为没有必要 | ||
136 | " 每隔多少秒更新一次tags,如果为0则不更新 | ||
137 | let Tlist_Update_Time=5 | ||
138 | " 在每个标签页打开相同的函数列表 | ||
139 | autocmd BufWinEnter * if getcmdwintype() == '' | silent TlistUpdate | endif | ||
140 | " 打开新标签页时自动打开函数列表 | ||
141 | autocmd BufWinEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.IsTabTree()) | silent TlistToggle | endif | ||
142 | |||
143 | " vim-indent-guides | ||
144 | let g:indent_guides_enable_on_vim_startup = 1 " 启动时自动开启缩进线 | ||
145 | let g:indent_guides_guide_size = 1 " 缩进线宽度 | ||
146 | let g:indent_guides_start_level = 2 " 从第二级开始显示缩进线 | ||
147 | let g:indent_guides_auto_colors = 1 " 自动颜色 | ||
148 | autocmd VimEnter * :IndentGuidesToggle | ||
149 | highlight IndentGuidesOdd ctermbg=darkgray " 缩进线颜色 | ||
150 | highlight IndentGuidesEven ctermbg=darkgrey " 缩进线颜色 | ||
151 | |||
152 | " nerdcommenter | ||
153 | map <space-m> <Leader>c<space> | ||
diff --git a/vimrcs/statusline.vim b/vimrcs/statusline.vim new file mode 100644 index 0000000..6bf42ed --- /dev/null +++ b/vimrcs/statusline.vim | |||
@@ -0,0 +1,70 @@ | |||
1 | set guitablabel=%{ShortTabLabel()} | ||
2 | function ShortTabLabel () | ||
3 | let bufnrlist = tabpagebuflist (v:lnum) | ||
4 | let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1]) | ||
5 | let filename = fnamemodify (label, ':t') | ||
6 | return filename | ||
7 | endfunction | ||
8 | |||
9 | set tabline=%!MyTabLine() | ||
10 | function MyTabLine() | ||
11 | let s = '' | ||
12 | for i in range(tabpagenr('$')) | ||
13 | " 选择高亮 | ||
14 | if i + 1 == tabpagenr() | ||
15 | let s .= '%#TabLineSel#' | ||
16 | else | ||
17 | let s .= '%#TabLine#' | ||
18 | endif | ||
19 | " 设置标签页号 (用于鼠标点击) | ||
20 | let s .= '%' . (i + 1) . 'T' | ||
21 | " MyTabLabel() 提供完整路径标签 MyShortTabLabel 提供文件名标签 | ||
22 | let s .= ' %{MyShortTabLabel(' . (i + 1) . ')} ' | ||
23 | endfor | ||
24 | " 最后一个标签页之后用 TabLineFill 填充并复位标签页号 | ||
25 | let s .= '%#TabLineFill#%T' | ||
26 | " 右对齐用于关闭当前标签页的标签 | ||
27 | if tabpagenr('$') > 1 | ||
28 | let s .= '%=%#TabLine#%999Xclose' | ||
29 | endif | ||
30 | return s | ||
31 | endfunction | ||
32 | |||
33 | " 文件名标签 | ||
34 | function MyShortTabLabel(n) | ||
35 | let buflist = tabpagebuflist(a:n) | ||
36 | let label = bufname (buflist[tabpagewinnr (a:n) -1]) | ||
37 | let filename = fnamemodify (label, ':t') | ||
38 | return filename | ||
39 | endfunction | ||
40 | " 完整路径标签 | ||
41 | function MyTabLabel(n) | ||
42 | let buflist = tabpagebuflist(a:n) | ||
43 | let winnr = tabpagewinnr(a:n) | ||
44 | return bufname(buflist[winnr - 1]) | ||
45 | endfunction | ||
46 | |||
47 | " 状态栏显示git分支 | ||
48 | function! GitBranch() | ||
49 | " 获取当前所在分支名,注意不要保留开头的*和行末的空符号 | ||
50 | let s:branch = system("git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/\\1/' | tr -d '\n' | tr -d ' '") | ||
51 | return strlen(s:branch) ? 'b: '.s:branch.'> ' : '' | ||
52 | endfunction | ||
53 | |||
54 | set laststatus=2 " 显示状态栏(默认值为 1,无法显示状态栏) | ||
55 | set statusline=%f%m%r%h%w\ >\ %{GitBranch()}%=\ <\ %{&ff},\ %{&fenc}\ <\ %y\ <\ %l,%v\ <\ %p%%\ <\ lines=%L | ||
56 | |||
57 | function! CurDir() | ||
58 | let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") | ||
59 | return curdir | ||
60 | endfunction | ||
61 | |||
62 | " 标签样式 | ||
63 | " TabLineFill tab pages line, where there are no labels | ||
64 | hi TabLineFill term=none | ||
65 | hi TabLineFill ctermfg=DarkGrey | ||
66 | hi TabLineFill guifg=#777777 | ||
67 | " TabLineSel tab pages line, active tab page label | ||
68 | hi TabLineSel term=inverse | ||
69 | hi TabLineSel cterm=none ctermfg=yellow ctermbg=Black | ||
70 | hi TabLineSel gui=none guifg=yellow guibg=Black | ||