-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
360 lines (290 loc) · 8.82 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
"
" Make sure https://github.com/junegunn/vim-plug is installed
"
set nocompatible " be iMproved, required
filetype off " required
nnoremap <S-W> :q<CR>
nnoremap <S-X> :qa<CR>
nnoremap <S-S> :w<CR>
nnoremap <C-K><C-D> ggvG= " like visual studio
set number relativenumber
set ruler
set wildmenu
set cmdheight=2
" leader key
let mapleader='`'
" CTAGS
set tags=tags;
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set background=dark
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Consolas:h11:cANSI
endif
endif
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
set cursorline " Highlight current line
set guicursor+=a:blinkon0
set hlsearch
"""""""""""""""""""""""""""""""""
" Tabs And Spaces
"""""""""""""""""""""""""""""""""
set expandtab
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
set softtabstop=4
set nojoinspaces
set splitright
set splitbelow
set linespace=0
set showmatch
set ignorecase
autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif
""""""""""""""""""""""""""""""""
" Packages managed by VIM-Plug
""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'majutsushi/tagbar'
" Required for git branch to be displayed on airline
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'easymotion/vim-easymotion'
Plug 'ddollar/nerdcommenter'
Plug 'tpope/vim-repeat'
Plug 'terryma/vim-multiple-cursors'
Plug 'mileszs/ack.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'mbbill/undotree'
Plug 'kien/ctrlp.vim'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'scrooloose/syntastic'
Plug 'luochen1990/rainbow'
Plug 'godlygeek/tabular'
Plug 'valloric/youcompleteme'
Plug 'greyblake/vim-preview'
Plug 'shougo/unite.vim'
Plug 'tungd/unite-session'
Plug 't9md/vim-unite-lines'
Plug 'ludovicchabant/vim-gutentags'
Plug 'Yggdroot/LeaderF', { 'do': '.\install.bat' }
Plug 'mihais/vim-mark'
call plug#end()
" call :PlugInstall to install
""""""""""""""""""""""""""""""
" NERDTREE
""""""""""""""""""""""""""""""
" auto open NERDTree when vim starts up.
" Disable this because SessionIssue
" autocmd VimEnter * NERDTree
" change the cursor focus to the file
" autocmd VimEnter * wincmd p
" auto close NERDTree when treeview is the last window.
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" autocmd VimEnter * NERDTreeTabs
nnoremap <F6> :NERDTree<CR>
let g:NERDTreeWinSize = 30
let g:NERDTreeIgnore = ['\.dll$', '\.exe$', '\.obj$', '\.lib$', '\.pdb$', '\.out$', '\.a$', '\.o$']
let NERDTreeShowBookmarks=1
let NERDTreeKeepTreeInNewTab=1
let g:nerdtree_tabs_open_on_gui_startup=0
""""""""""""""""""""""""""""""
" TAGBAR
""""""""""""""""""""""""""""""
nmap <F8> :TagbarToggle<CR>
""""""""""""""""""""""""""""""
" VIM-AIRLINE
""""""""""""""""""""""""""""""
" enable the tabline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_left_sep='›' " Slightly fancier than '>'
let g:airline_right_sep='‹' " Slightly fancier than '<'
if has('win32')
set encoding=utf-8
endif
nnoremap <S-Left> :bp<CR>
nnoremap <S-Right> :bn<CR>
nnoremap <S-Q> :bd<CR>
" Switch window mappings
" nnoremap <C-L> <C-W><C-L>
if has('nvim')
nnoremap <BS> <C-W>h
endif
:nnoremap <silent> <C-h> :wincmd h<CR>
:nnoremap <silent> <C-j> :wincmd j<CR>
:nnoremap <silent> <C-k> :wincmd k<CR>
:nnoremap <silent> <C-l> :wincmd l<CR>
if has('statusline')
set laststatus=2
endif
""""""""""""""""""""""""""""""
" easy motion
""""""""""""""""""""""""""""""
let g:easymotion_smartcase = 1
" /<keyword> <enter> shows the keyword motion key
map / <plug>(easymotion-sn)
" \l shows the line motion key
nmap <leader>l <plug>(easymotion-overwin-line)
map <leader>l <plug>(easymotion-bd-jk)
" \w shows the word motion key
map <leader>w <plug>(easymotion-bd-w)
nmap <leader>w <plug>(easymotion-overwin-w)
""""""""""""""""""""""""""""""
" nerdcommenter
""""""""""""""""""""""""""""""
" let g:nerdspacedelims=1
""""""""""""""""""""""""""""""
" repeat
""""""""""""""""""""""""""""""
silent! call repeat#set("\<plug>mywonderfulmap", v:count)
""""""""""""""""""""""""""""""
" solarized - must put after vundle
""""""""""""""""""""""""""""""
syntax enable
if has('gui_running')
set background=dark
else
set background=dark
" use degraded 256 colors in ternimal mode
let g:solarized_termcolors=256
endif
let g:solarized_italic=0
colorscheme solarized
""""""""""""""""""""""""""""""
" undo tree
""""""""""""""""""""""""""""""
nnoremap <f9> :undotreetoggle<cr>
if has("persistent_undo")
set undodir=~/.undodir/
set undofile
endif
""""""""""""""""""""""""""""""
" rainbown
""""""""""""""""""""""""""""""
let g:rainbow_active = 1 "0 if you want to enable it later via :rainbowtoggle
""""""""""""""""""""""""""""""
" unit.vim
""""""""""""""""""""""""""""""
nnoremap <leader>us :Unite session<cr>
nnoremap <leader>ul :Unite lines<cr>
nnoremap <leader>ub :Unite buffer<cr>
nnoremap <leader>ur :Unite file<cr>
""""""""""""""""""""""""""""""
" ctrlp
""""""""""""""""""""""""""""""
let g:ctrlp_working_path_mode='ra'
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_lazy_update = 0
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_max_height = 20
let g:ctrlp_max_files=0
" let g:ctrlp_use_caching = 5000
let g:ctrlp_match_window_reversed = 1
if exists("g:ctrlp_user_command")
unlet g:ctrlp_user_command
endif
if has('win32')
let g:ctrlp_cache_dir = '$USERPROFILE/.vim/tmp/ctrlp'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\\](\.(git|hg|svn)|(obj|objd|out))$',
\ 'file': '\v\.(exe|so|dll|err|log|trc|wrn|prf|pyc|pdb|nupkg|sln)$',
\ 'link': '',
\ }
else
let g:ctrlp_cache_dir = '~/.vim/tmp/ctrlp'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll|err|log|trc|wrn|prf|pyc|pdb|nupkg)$',
\ 'link': '',
\ }
endif
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*.swp,*.zip,*.exe,*.dll,*.pdb,*.nupkg,*\\obj\\*,*\\objd\\*,*\\tmp\\* " Windows
""""""""""""""""""""""""""""""
" leaderF (replace ctrlp)
""""""""""""""""""""""""""""""
nmap <Leader>ff :LeaderfFile<cr>
nmap <Leader>ft :LeaderfTag<cr>
nmap <Leader>fb :LeaderfBuffer<cr>
nmap <Leader>fm :LeaderfFunction<cr>
" current folder with git root
let g:Lf_WorkingDirectoryMode = 'Ac'
" Notes:
"<C-C> : quit from LeaderF.
"<C-R> : switch between fuzzy search mode and regex mode.
"<C-F> : switch between full path search mode and name only search mode.
""""""""""""""""""""""""""""""
" sessionmanager
""""""""""""""""""""""""""""""
nmap <leader>sl :sessionlist<cr>
nmap <leader>ss :sessionsave<cr>
nmap <leader>sc :SessionClose<CR>
""""""""""""""""""""""""""""""
" YouCompleteMe
""""""""""""""""""""""""""""""
" disable when not launching from gui
if has("gui_running")
let g:loaded_youcompleteme = 1
else
let g:loaded_youcompleteme = 0
endif
"let g:ycm_add_preview_to_completeopt = 0
"let g:ycm_show_diagnostics_ui = 0
"let g:ycm_server_log_level = 'info'
"let g:ycm_min_num_identifier_candidate_chars = 2
"let g:ycm_collect_identifiers_from_comments_and_strings = 1
"let g:ycm_complete_in_strings=1
"let g:ycm_key_invoke_completion = '<c-z>'
"set completeopt=menu,menuone
"let g:ycm_semantic_triggers = {
" \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
" \ 'cs,lua,javascript': ['re!\w{2}'],
" \ }
""""""""""""""""""""""""""""""
" Ack
""""""""""""""""""""""""""""""
cnoreabbrev Ack Ack!
cnoreabbrev ack Ack!
nnoremap <Leader>a :Ack! --ignore-case<Space>
if executable('ag')
let g:ackprg = 'ag --vimgrep --ignore-case --nogroup'
else
if has ('win32')
let g:ackprg = 'silver_search --vimgrep --ignore-case --nogroup'
else
:echo "AG is NOT installed. It's strongly recommend to install that!"
endif
endif
""""""""""""""""""""""""""""""
" Gutentags
""""""""""""""""""""""""""""""
let g:gutentags_enabled = 0
""""""""""""""""""""""""""""""
" Highlight
""""""""""""""""""""""""""""""