-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
145 lines (117 loc) · 3.47 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
" ---- General ----
syntax on
syntax enable
" Don't wrap text to the screen
set nowrap
" Allow cursor movement to wrap across lines
set whichwrap=<,>,h,l,[,]
" Use 2 spaces instead of tabs
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
" set working directory to current file set autochdir
" Indention
set autoindent
set nosmartindent
set nocindent
" Better search
set ignorecase
set smartcase
set incsearch
set hlsearch
" Don't show command to speed up
set noshowcmd
set nolazyredraw
" color
colorscheme OceanicNext
set background=dark
set ruler
set nu
" enable project level .vimrc
set exrc
set secure
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
" VimPlug https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'kien/ctrlp.vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'scrooloose/nerdcommenter'
Plug 'lyuts/vim-rtags'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive'
Plug 'vim-scripts/a.vim'
Plug 'vim-scripts/AnsiEsc.vim'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py' }
call plug#end()
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
" Key bindings
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
let mapleader=","
" tabs
noremap <leader>tn :tabn<CR>
noremap <leader>tp :tabp<CR>
noremap <leader>tc :tabnew<Space>
" Fat finger saving
command WQ wq
command Wq wq
command W w
command Q q
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
" NERDTree
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
"
" open console or switch to main view
"map <leader><leader> :NERDTreeFind<CR>
map <leader><leader> :NERDTreeToggle<CR>
" calls NERDTreeFind iff NERDTree is active, current window contains a modifiable file, and we're not in vimdiff
function! s:syncTree()
let s:curwnum = winnr()
NERDTreeFind
exec s:curwnum . "wincmd w"
endfunction
function! s:syncTreeIf()
if (winnr("$") > 1)
call s:syncTree()
endif
endfunction
" Shows NERDTree on start and synchronizes the tree with opened file when switching between opened windows
"autocmd BufEnter * call s:syncTreeIf()
" Automatically close vim if only NERDTree left
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Do not show additional information
let NERDTreeMinimalUI=1
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
" Fugitive
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
map <leader>gb :Gblame<CR>
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
" YouCompleteme
" ~~~~~~~~~~~~~~~~~~~~~~~~~~
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
"" YCM 补全菜单配色
"" 菜单
"highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
"" 选中项
"highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
" 补全功能在注释中同样有效
let g:ycm_complete_in_comments=1
" 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
let g:ycm_confirm_extra_conf=0
" 开启 YCM 标签补全引擎
let g:ycm_collect_identifiers_from_tags_files=1
" YCM 集成 OmniCppComplete 补全引擎,设置其快捷键
"inoremap <leader>; <C-x><C-o>
" 补全内容不以分割子窗口形式出现,只显示补全列表
set completeopt-=preview
" 从第一个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=1
" 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
" 语法关键字补全
let g:ycm_seed_identifiers_with_syntax=1
nnoremap <leader>jl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>jg :YcmCompleter GoToDefinition<CR>
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>