-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
419 lines (327 loc) · 10.7 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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
""""""""""""""""""""""" Vundle Configuration """"""""""""""""""""""""""""""""""""
syntax on
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
"Plugin 'altercation/vim-colors-solarized'
Plugin 'chriskempson/vim-tomorrow-theme'
Plugin 'kien/ctrlp.vim'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'gabrielelana/vim-markdown'
"Plugin 'mbbill/undotree'
"Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'scrooloose/nerdcommenter'
"Plugin 'matze/vim-move'
"Plugin 'ervandew/supertab'
Plugin 'xolox/vim-misc'
"Plugin 'xolox/vim-session'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
"Plugin 'tpope/vim-fugitive'
"Plugin 'tpope/vim-rails'
"Plugin 'bling/vim-bufferline'
Plugin 'gcmt/wildfire.vim'
Plugin 'fholgado/minibufexpl.vim'
Plugin 'mutewinter/nginx.vim'
"Plugin 'mhinz/vim-startify'
Plugin 'StanAngeloff/php.vim'
Plugin 'bkad/CamelCaseMotion'
Plugin 'kana/vim-textobj-user'
"Plugin 'nelstrom/vim-textobj-rubyblock'
"Plugin 'Rip-Rip/clang_complete'
"Plugin 'Valloric/YouCompleteMe'
Plugin 'ekalinin/Dockerfile.vim'
"Plugin 'terryma/vim-multiple-cursors'
Plugin 'benmills/vimux'
"Plugin 'xuhdev/SingleCompile'
"Plugin 'vim-scripts/a.vim'
"Plugin 'xolox/vim-easytags'
Plugin 'craigemery/vim-autotag'
"Plugin 'xuhdev/vim-latex-live-preview'
"Plugin 'jcf/vim-latex'
Plugin 'fatih/vim-go'
"Plugin 'godlygeek/tabular'
"Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'majutsushi/tagbar'
Plugin 'godlygeek/tabular'
Plugin 'wellle/tmux-complete.vim'
"Plugin 'pangloss/vim-javascript'
Plugin 'othree/javascript-libraries-syntax.vim'
"Plugin 'burnettk/vim-angular'
Plugin 'vim-ruby/vim-ruby'
Plugin 'vim-scripts/groovy.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"""""""""""""""""""""""""""""""""" General """"""""""""""""""""""""""""""""""""""""
runtime macros/matchit.vim
set mouse=a
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
set pastetoggle=<F2> " pastetoggle (sane indentation on pastes)
set nu " Show line numbers
" Show trailing white spaces as dots
set list listchars=tab:»~,trail:~
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" Tabs sizes
set shiftwidth=2 " Use indents of 2 spaces
set tabstop=2 " An indentation every four columns
set softtabstop=2 " Let backspace delete indent
set ai "Auto indent
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set si "Smart indent
set nowrap "Don't Wrap lines
set noswapfile
set history=700
" while typing a command, show it in the bottom right corner
set showcmd
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Root Save
command! W w !sudo tee % > /dev/null
" cursor padding
set so=3
" Turn on the WiLd menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
set wildignore+=.git\*,.hg\*,.svn\*
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/cache/*
set autowrite
set autoread
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" Add a bit extra margin to the left
set foldcolumn=1
" Don't move cursor to beginning to line
set nosol
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all
" Setting the clipboard
set clipboard=unnamed
" Black hole deletion/change (persist yanked lines in non-visual mode)
nnoremap d "_d
nnoremap dd "_dd
nnoremap D "_D
nnoremap c "_c
nnoremap C "_C
nnoremap x "_x
" Stop the stupid windows
map q: :q
"""""""""""""""""""""""""" Colors """""""""""""""""""""""""""""""""""""""""""""
set background=dark
color Tomorrow-Night
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=black ctermbg=black
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=darkgrey ctermbg=darkgrey
" 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 t_Co=256 " Enable 256 colors to stop the CSApprox warning and make xterm vim shine
"""""""""""""""""""""""""" Moving Around """""""""""""""""""""""""""""""""""""""""
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Fast scrolling
noremap <Right> 20zl
noremap <Left> 20zh
noremap <Up> 20<C-y>
noremap <Down> 20<C-e>
" Disable highlight
nnoremap <leader><CR> :noh<cr>
" Disable latex conflict with <C-j>
map <silent>$# <Plug>IMAP_JumpForward
" move to end of pasted text, to ease multiple pastes
vnoremap y y`]
vnoremap p p`]
nnoremap p p`]
" Some helpers to edit mode
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
" Map the compile and run custom function
map <leader>r :call MakeAndRun(0)<cr>
map <leader>rf :call MakeAndRun(1)<cr>
set hidden
map tl :MBEbn<CR>
map th :MBEbp<CR>
cabbrev bd MBEbd
map <leader>t :enew<CR>
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
""""""""""""""""""""""""""" Status Line """""""""""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
""""""""""""""""""""""""""" Others """""""""""""""""""""""""""""""""""""""""""""
au BufRead,BufNewFile *.rabl setfiletype ruby
au BufRead,BufNewFile *.angular setfiletype html
autocmd FileType C call CPPSET()
autocmd FileType cc call CPPSET()
autocmd FileType cpp call CPPSET()
autocmd FileType java call JAVASET()
autocmd FileType python call PYSET()
"""""""""""""""""""""""""" Plugins """"""""""""""""""""""""""""""""""
" Nerd Tree
map <C-E> :NERDTreeToggle<cr>
let NERDTreeShowHidden=1
let NERDTreeKeepTreeInNewTab=1
let NERDTreeChDirMode=2
" CtrlP
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll|aux|lof|bbl|blg|log|toc|out)$',
\ 'link': '',
\ }
" Vim airline
"let g:airline#extensions#tabline#enabled = 1
"let g:airline#extensions#tabline#left_sep = '>'
let g:airline_symbols = {}
let g:airline_symbols.branch = '⎇ '
let g:airline_section_y = ''
let g:airline#extensions#whitespace#enabled = 0
"MiniBuffExpl
let g:miniBufExplBRSplit = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplBuffersNeeded = 0
let g:miniBufExplCycleArround = 1
"You compelete Me
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
let g:ycm_show_diagnostics_ui = 0
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
set completeopt-=preview
let g:EclimCompletionMethod = 'omnifunc'
let g:tmuxcomplete#trigger = 'omnifunc'
" LaTeX-Suite
let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_GotoError = 0
let g:Tex_AutoFolding = 0
let g:Tex_Folding = 0
" Syntastic
let g:syntastic_cpp_compiler_options = ' -std=c++11'
let g:syntastic_check_on_open = 1
let g:syntastic_go_checkers = ['go']
"vim-go
let g:go_fmt_command = "goimports"
let g:go_fmt_fail_silently = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_auto_type_info = 0
let g:go_info_mode = 'guru'
let g:go_auto_type_info = 1
let g:go_gocode_unimported_packages = 1
set statusline+=%#goStatuslineColor#
set statusline+=%{go#statusline#Show()}
set statusline+=%*
" javascript-syntax
let g:used_javascript_libs = 'angularjs'
"Utlisnips
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
"vim-tmux-navigator
let g:tmux_navigator_no_mappings = 1
"tagbar
"autocmd FileType go nested :TagbarOpen
nnoremap <silent> <c-a>h :TmuxNavigateLeft<cr>
nnoremap <silent> <c-a>j :TmuxNavigateDown<cr>
nnoremap <silent> <c-a>k :TmuxNavigateUp<cr>
nnoremap <silent> <c-a>l :TmuxNavigateRight<cr>
""""""""""""""""""""""""""" Functions """""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" Python
function! PYSET()
noremap ,py :!python<CR>
noremap ,apy :%!python<CR>
set shiftwidth=4
set tabstop=4
set softtabstop=4
endfunction
" C/C++:
function! CSET()
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ gcc\ -O2\ -g\ -Wall\ -o%.bin\ %\ -lm;fi;fi
set errorformat^=%-G%f:%l:\ warning:%m
set cindent
set textwidth=0
set nowrap
command! Execute call VimuxRunCommand(expand('%:p') . '.bin') | call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
endfunction
function! CPPSET()
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ g++\ -std=gnu++0x\ -O2\ -g\ -Wall\ -o%.bin\ %;fi;fi
set errorformat^=%-G%f:%l:\ warning:%m
set cindent
set textwidth=0
set nowrap
command! Execute call VimuxRunCommand(expand('%:p') . '.bin') | call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
endfunction
" Java
function! JAVASET()
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make\ $*;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make\ $*;else\ javac\ -g\ %;fi;fi
set cindent
set textwidth=0
set nowrap
command! Execute call VimuxRunCommand('java ' . expand('%:r')) | call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
endfunction
function! MakeAndRun(forceRun)
:make!
if len(getqflist()) == 0 || a:forceRun == 1
:Execute
endif
endfunction
function! FixTabs()
:set tabstop=2 shiftwidth=2 expandtab
:retab
endfunction