-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
368 lines (273 loc) · 10.4 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
361
362
363
364
365
366
367
368
"============================================================================
" vim config
"============================================================================
"
" This vim configuration uses vundle (https://github.com/gmarik/vundle) for
" managing plugins.
"
"============================================================================
" clear autocommands
autocmd!
"=== vundle =================================================================
set nocompatible " drop vi compatibility
filetype off " required for vundle
set rtp+=~/.vim/bundle/vundle/ " add vundle search path
call vundle#rc()
"=== general ================================================================
syntax on " syntax highlighting on.
filetype plugin on " turn on filetype plugin
filetype plugin indent on " required for vundle
set modeline " file specific options
set history=1000 " history size
set mouse=a " mouse gestures
set encoding=utf-8 " set internal encoding
set scrolloff=4 " scroll offset
set visualbell " use visual bell
set vb t_vb= " disable both audible and visible bell
set background=dark
set switchbuf=useopen
set shortmess=aotTOI
"=== plugins ================================================================
" vundle plugin management
Bundle 'gmarik/vundle'
" molokai theme
Bundle 'mrtazz/molokai.vim'
" solarized theme
Bundle 'altercation/vim-colors-solarized'
" summerfruit256 theme
Bundle 'vim-scripts/summerfruit256.vim'
" nerdtree
Bundle 'scrooloose/nerdtree'
" powerline
Bundle 'Lokaltog/vim-powerline'
" pastie
Bundle 'tpope/vim-pastie'
" mustang theme
Bundle 'cschlueter/vim-mustang'
" tComment
Bundle 'tComment'
" matchit
Bundle 'matchit.zip'
" indent guides
Bundle 'nathanaelkane/vim-indent-guides'
if 0 && v:version >= 703
" A fuzzy code completion engine
Bundle 'Valloric/YouCompleteMe'
endif
" supertab
Bundle 'ervandew/supertab'
if 0
" AutoComplPop
Bundle 'AutoComplPop'
endif
if 0
" latex box
Bundle 'LaTeX-Box-Team/LaTeX-Box'
endif
" fugitive
Bundle 'tpope/vim-fugitive'
" detect indent
Bundle 'irock/detectindent'
" hilight trailing whitespace
Bundle 'bronson/vim-trailing-whitespace'
" file-line
Bundle 'file-line'
" visual-star
Bundle 'thinca/vim-visualstar'
" markdown
Bundle 'hallison/vim-markdown'
" date incrementing
Bundle 'tpope/vim-speeddating'
" tagbar
Bundle 'majutsushi/tagbar'
" gitv
Bundle 'gregsexton/gitv'
" wiki for vim
Bundle 'vimwiki'
" Git gutter
Bundle 'airblade/vim-gitgutter'
if 0
" Indexed search
Bundle 'IndexedSearch'
endif
" Ctrl-P
Bundle 'kien/ctrlp.vim'
" A.vim (switch between header and source file easily)
Bundle 'a.vim'
" JavaScript support
Bundle 'pangloss/vim-javascript'
" TypeScript syntax
Bundle 'leafgarland/typescript-vim'
"==== plugin configuration ==================================================
"===== indent guides ========================================================
let g:indent_guides_auto_colors = 0
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_enable_on_vim_startup = 1
"===== detectindent =========================================================
let g:detectindent_preferred_expandtab = 1
let g:detectindent_preferred_indent = 2
let g:detectindent_max_lines_to_analyse = 4096
let g:detectindent_min_indent = 2
" detect indentation by default
autocmd BufRead * :DetectIndent
"===== vimroom ==============================================================
" use full height for text
let g:vimroom_sidebar_height = 0
"===== tagbar ===============================================================
let g:tagbar_compact = 1
let g:tagbar_singleclick = 1
let g:tagbar_indent = 1
"===== vimwiki ==============================================================
let work_wiki = {}
let work_wiki.path = '~/docs/wiki/work'
let personal_wiki = {}
let personal_wiki.path = '~/docs/wiki/personal'
let g:vimwiki_list = [work_wiki, personal_wiki]
"===== YouCompleteMe ========================================================
"let g:ycm_filetype_specific_completion_to_disable = { 'cpp': 1, }
"==== gitgutter =============================================================
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
let g:gitgutter_sign_column_always = 1
"==== eclim =================================================================
let g:EclimCompletionMethod = 'omnifunc'
let g:acp_behaviorJavaEclimLength = 3
function MeetsForJavaEclim(context)
return g:acp_behaviorJavaEclimLength >= 0 &&
\ a:context =~ '\k\.\k\{' . g:acp_behaviorJavaEclimLength . ',}$'
endfunction
let g:acp_behavior = {
\ 'java': [{
\ 'command': "\<c-x>\<c-u>",
\ 'completefunc' : 'eclim#java#complete#CodeComplete',
\ 'meets' : 'MeetsForJavaEclim',
\ }]
\ }
"==== ctrlp =================================================================
let g:ctrlp_by_filename = 1
let g:ctrlp_regexp = 1
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
"=== appearance =============================================================
let s:colorschemes = ['molokai', 'hemisu', 'summerfruit256', 'solarized']
let s:colorschemes_idx = 0
function! s:LoadColorscheme()
execute 'colorscheme '.s:colorschemes[s:colorschemes_idx]
endfunction
function! s:ShiftColorscheme()
let s:colorschemes_idx = (s:colorschemes_idx + 1) % len(s:colorschemes)
call s:LoadColorscheme()
endfunction
set showmatch " jump to matching bracket and back when inserted
set matchtime=3 " time for showmatch
set wildmenu " command line completion
set ruler " show the ruler
set laststatus=2 " always show status line.
set showcmd " show command in last line
set nocursorline " don't hilight the current line (faster)
set number " use absolute line numbers
set wrap " wrap long lines
set splitright " open new vsplit windows to the right
" close popup menu automatically
autocmd CursorMovedI,InsertLeave * if pumvisible() == 0|silent!
\ pclose|endif
let g:solarized_termcolors=256 " use 256 colors for solarized colorscheme
"=== indentation ============================================================
set autoindent " copy indentation from current line to new line
set tabstop=2 " number of spaces that a tab is replaced with
set shiftwidth=2 " number of spaces to use with autoindent
set softtabstop=2 " number of spaces that a <Tab> counts for while
" performing editing operations
set smarttab " replace tabs at start of line with spaces.
set expandtab " use spaces instead of hard '\t' tabs
"=== searching ==============================================================
set hlsearch " highlighting of search terms.
set incsearch " go to first match when typing
set ignorecase " case insensitive search
set smartcase " if search contains mixed case, do a case sensitive
" search
set gdefault " use /g by default when doing replaces.
"=== code completion ========================================================
set completeopt=menuone
inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
\ "\<lt>C-n>" :
\ "\<lt>C-x>\<lt>C-o>"
imap <C-@> <C-Space>
"=== mappings ===============================================================
let mapleader="," " use <comma> as leader
let maplocalleader=";" " use <semicolon> as local leader
imap <C-l> <ESC>
map <leader>tt :tabnew<cr>
map <leader>n :tabnext<cr>
map <leader>b :tabprevious<cr>
map <leader>tw :tabclose<cr>
map <leader>e :NERDTreeToggle<cr>
map <leader>tb :TagbarToggle<cr>
map <leader>c :TComment
map <leader>p :r! cat<cr>
map <leader>h :r! cat<cr>
map <leader>g :silent Ggrep
" Make with quickfix
command! -nargs=* Make make <args> | cwindow 3
map <leader>m :Make<cr><cr><cr>
command! ShiftColorscheme call s:ShiftColorscheme()
command! LoadColorscheme call s:LoadColorscheme()
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
map <Esc>1 :tabnext 1<cr>
map <Esc>2 :tabnext 2<cr>
map <Esc>3 :tabnext 3<cr>
map <Esc>4 :tabnext 4<cr>
map <Esc>5 :tabnext 5<cr>
map <Esc>6 :tabnext 6<cr>
map <Esc>7 :tabnext 7<cr>
map <Esc>8 :tabnext 8<cr>
map <Esc>9 :tabnext 9<cr>
map <Esc>0 :tabnext 10<cr>
nnoremap <leader><space> :noh<cr>
nnoremap <leader>jd :JavaSearchContext<cr>
nnoremap <leader>jh :JavaDocSearch<cr>
nnoremap <leader>ji :JavaImport<cr>
nnoremap j gj
nnoremap k gk
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
nnoremap <leader>q gqip
nnoremap <leader>v V`]
inoremap jj <ESC>
nnoremap <leader>c :TComment<cr>
vnoremap <leader>c :TComment<cr>
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
"=== filetypes ==============================================================
autocmd BufRead,BufNewFile *.asm set ft=nasm
autocmd BufRead,BufNewFile *.tex set ft=tex
autocmd BufRead,BufNewFile *.md set ft=markdown
"=== hilighting =============================================================
function! s:InitColors()
augroup InitColors
au!
hi IndentGuidesOdd ctermbg=235
hi IndentGuidesEven ctermbg=236
hi Normal ctermbg=234
hi Pmenu ctermbg=237 ctermfg=254
hi PmenuSel ctermbg=214 ctermfg=234
hi SpellBad ctermbg=none ctermfg=red " incorrect spelling
hi CursorLine cterm=none ctermbg=235 cterm=none gui=none
autocmd VimEnter * :hi ExtraWhitespace ctermbg=238 guibg=#382424
augroup END
endfunction
autocmd ColorScheme * :call s:InitColors()
" Load colorscheme last, to be sure all hooks have been initialized
call s:LoadColorscheme()
"=== utilities ==============================================================
"==== create dirs on save ===================================================
function WriteCreatingDirs()
execute ':silent !mkdir -p %:h'
write
endfunction
command W call WriteCreatingDirs()