-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc_latest
More file actions
548 lines (452 loc) · 17.7 KB
/
vimrc_latest
File metadata and controls
548 lines (452 loc) · 17.7 KB
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Reference http://mixandgo.com/blog/vim-config-for-rails-ninjas
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = " "
autocmd!
set nocompatible
"set noshowmode
" Disable tag generation on file save, slow for large projects
" then you need to do it whenever tags file is out of date
"let g:vim_tags_auto_generate = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle Start
" // To install:
" Launch vim and run :PluginInstall
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype off "required for vundle
" Load local .vimrc relative to the project repo
set exrc
" Load .vimrc whenever it's saved
au BufWritePost .vimrc so $MYVIMRC
" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Plugin 'gmarik/vundle'
" Recently added Plugins
" Plugin 'scrooloose/nerdtree'
Plugin 'preservim/nerdtree'
"Plugin 'bling/vim-airline' " cannot get powerline work on some environments
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
" All other Plugins
" Plugin 'dockyard/vim-easydir'
" Plugin 'ecomba/vim-ruby-refactoring'
" Plugin 'SirVer/ultisnips'
" Plugin 'int3/vim-extradite'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'kchmck/vim-coffee-script'
Plugin 'pangloss/vim-javascript'
Plugin 'rorymckinley/vim-rubyhash'
" Plugin 'tmhedberg/matchit'
" Plugin 'tpope/vim-commentary'
" Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-haml'
" Plugin 'tpope/vim-ragtag'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
" Plugin 'tpope/vim-surround'
" Plugin 'tpope/vim-vinegar'
" Plugin 'tpope/vim-unimpaired'
" Plugin 'tpope/vim-speeddating'
" Plugin 'tpope/vim-rsi'
" Plugin 'tpope/vim-projectionist'
" Plugin 'stefanoverna/vim-i18n'
Plugin 'szw/vim-tags'
Plugin 'vim-ruby/vim-ruby'
" Plugin 'danchoi/ri.vim'
Plugin 'kien/ctrlp.vim'
Plugin 'd11wtq/ctrlp_bdelete.vim'
Plugin 'tacahiroy/ctrlp-funky'
" Plugin 'mileszs/ack.vim'
" Plugin 'junegunn/vim-easy-align'
" Plugin 'chriskempson/vim-tomorrow-theme'
" Plugin 'christoomey/vim-tmux-runner'
" Plugin 'gabebw/vim-spec-runner'
" Plugin 'marcweber/vim-addon-mw-utils'
" Plugin 'tomtom/tlib_vim'
" Plugin 'wellle/targets.vim'
" Plugin 'vim-scripts/SyntaxAttr.vim'
" Plugin 'guns/xterm-color-table.vim'
" Plugin 'slim-template/vim-slim'
" Plugin 'nanotech/jellybeans.vim'
" Plugin 'jgdavey/vim-blockle.git'
" Plugin 'vim-scripts/closetag.vim'
" Plugin 'tommcdo/vim-exchange'
" Plugin 'AndrewRadev/switch.vim'
" Plugin 'mattn/gist-vim'
" Plugin 'mattn/webapi-vim'
" Plugin 'tpope/vim-abolish'
" Plugin 'tpope/vim-repeat'
" Plugin 'gregsexton/gitv'
Plugin 'gabrielelana/vim-markdown'
" Plugin 'henrik/vim-indexed-search'
" Plugin 'vim-scripts/LargeFile'
" Plugin 'skwp/greplace.vim'
" Plugin 'chriskempson/base16-vim'
" Plugin 'AndrewRadev/splitjoin.vim'
Plugin 'avakhov/vim-yaml'
" Plugin 'idanarye/vim-merginal'
" Plugin 'mustache/vim-mustache-handlebars'
" Plugin 'godlygeek/tabular'
Plugin 'vim-scripts/indentpython.vim'
" Bundle 'Valloric/YouCompleteMe'
" For python autocompletion
Plugin 'davidhalter/jedi-vim'
" Plugin 'vim-syntastic/syntastic'
" All of Plugins must be added before the following line
call vundle#end()
filetype plugin indent on "requried
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle End
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Syntastic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_python_exec = '/usr/local/bin/python3'
let g:syntastic_mode_map = {
\ 'mode': 'passive',
\ 'active_filetypes': ['python'],
\ 'passive_filetypes': [] }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Valloric/YouCompleteMe
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
map <leader>r :YcmCompleter GoToReferences<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => CtrlP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
hi def link CtrlPMatch CursorLine
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_switch_buffer = 'Et'
let g:ctrlp_custom_ignore = {
\ 'dir': '\^.git$\|^node_modules$\|^bin$\|\^.hg$\|\^.svn$\|^build$\|^log$\|^resources$\|^coverage$\|^doc$\|^tmp$\|^public/assets$\|^vendor$\|^Android$',
\ 'file': '\.jpg$\|\.exe$\|\.so$\|tags$\|\.dll$'
\ }
" nnoremap <C-b> :CtrlPBuffer<cr>
" CtrlP Delete
call ctrlp_bdelete#init()
" CtrlP Funky
let g:ctrlp_extensions = ['funky']
let g:ctrlp_funky_multi_buffers = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Other
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Vim tmux runner
"" I don't want the default key mappings
"let g:VtrUseVtrMaps = 0
"" Vim spec runner
"let g:spec_runner_dispatcher = 'call VtrSendCommand("{command}")'
"map <Leader>tf <Plug>RunCurrentSpecFile
"map <Leader>tt <Plug>RunFocusedSpec
"map <Leader>tl <Plug>RunMostRecentSpec
" Get rid of buffers I don't use by Ctrl-c
nnoremap <C-c> :bnext\|bdelete #<CR>
" Use vim's default file manager instead of NERDTree
"let g:netrw_liststyle = 0
" I use NERDTree for now
""""Rubyhash""""
" Don't map rubyhash keys
let g:rubyhash_map_keys = 0
" ruby path if you are using RVM
"let g:ruby_path = system('rvm current')
" Disable mappings from vim-ruby-refactoring
let g:ruby_refactoring_map_keys = 0
" Intent private methods
"Disabling it because of strange line change behavior
"let g:ruby_indent_access_modifier_style = 'outdent'
"This one just tells the ultisnips plugin where it should look for my custom
"snippets
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
" Default encoding
set encoding=utf-8 nobomb
" Disable ex-mode
nnoremap Q <nop>
" Invisible characters
"set listchars=tab:?\ ,trail:?,eol:?,nbsp:_,extends:?,precedes:?
" Syntax coloring lines that are too long just slows down the world
set synmaxcol=1200
" Use only 1 space after "." when joining (J key) lines instead of 2
"set nojoinspaces
" Don't reset cursor to start of line when moving around
set nostartofline
" Autocomplete ids and classes in CSS
autocmd FileType css,scss set iskeyword=@,48-57,_,-,?,!,192-255
" Add the '-' as a keyword in erb files
autocmd FileType eruby set iskeyword=@,48-57,_,192-255,$,-
" Make those debugger statements painfully obvious
au BufEnter *.rb syn match error contained "\<binding.pry\>"
au BufEnter *.rb syn match error contained "\<debugger\>"
" Other one-liners
set hlsearch " highlight the search
" remove search highlighting
nnoremap <leader>h :noh<cr>
" ls <=> laststatus
set ls=2 " show a status line even if there's only one window
" Improve vim's scrolling speed
set ttyfast
set ttyscroll=3
set lazyredraw
set wildmenu " show completion on the mode-line
set linespace=0 " number of pixels between the lines
set splitright " open vertical splits on the right
set splitbelow " open the horizontal split below
" set wrap! " don't wrap long lines //correlated to Plugin ecomba/vim-ruby-refactoring
set textwidth=79 " definition for long lines
set linebreak " break lines at word end
set nobackup " don't want no backup files
set nowritebackup " don't make a backup before overwriting a file
set noswapfile " no swap files
set hidden " hide buffers when abandoned
" Time out on key codes but not mappings
set notimeout
set ttimeout
set ttimeoutlen=100
" Auto-reload buffers when files are changed on disk
set autoread
" Lines with equal indent form a fold.
set foldmethod=indent
set foldlevel=1
set foldnestmax=10
" Open all folds by default
set nofoldenable
set undofile " Save undo's after file closes
set undodir=~/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
set vb " disable alert sound
set showcmd " display incomplete commands
set history=100 " a ton of history
" Default shell and shell syntax and source ~/.bash_profile
set shell=/bin/bash\ --login
"set shell=/usr/bin/zsh\ --login
let g:is_bash=1
" Whitespace
set tabstop=4 shiftwidth=4 " a tab is two spaces
set expandtab " use spaces, not tabs
set backspace=indent,eol,start " backspace through everything in insert mode
" Searching
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
set scrolloff=5 " keep a 5 line padding when moving the cursor
set autoindent " indent on enter
set smartindent " do smart indenting when starting a new line
set shiftround " indent to the closest shiftwidth
set switchbuf="" " do not move focus/cursor to where the buffer is already open
set tagbsearch " use binary searching for tags
set cursorline
" The 'Press ENTER or type command to continue' prompt is jarring and usually unnecessary.
"set shortmess=atI
" C-c send enter in insert mode
"inoremap <C-c> <Esc>
"I'm aliasing w and q to their uppercase counterparts because I often have the shift key pressed and I type W instead of w.
cnoreabbrev W w
cnoreabbrev Q q
" Expand %% to current directory (eg. :%%)
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%')<cr>
" Force you to type commit messages that are no longer than 72 characters.
" Which is a very good practice.
autocmd Filetype gitcommit setlocal spell textwidth=72
" TODO:
" I want a minimalistic one with just the file name and probably the line/col
" numbers but I'm not entirely sold on it, I know I'm gonna change it in the
" near future.
if has("statusline") && !&cp
set statusline=%y\ %<%f\ %h%m%r%=%-16.(line\ %l\ of\ %L%)
set statusline+=%#warningmsg#
set statusline+=%*
endif
" Changing files only writable by the root user
"cnoremap w!! %!sudo tee > /dev/null %
" Visually select the text that was last edited/pasted
nnoremap gV `[v`]
" selelct what you've just pasted
nnoremap gp `[v`]
" reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" Given you have your hands on the home row most of the time, these shortcuts
" will save you when you try to switch window splits. And that happens a lot.
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" type the spacebar twice and it will bring me back to the last buffer I was on
nnoremap <leader><leader> :b#<cr>
" The <leader>V get to my .vimrc file quickly.
nnoremap <leader>V :e $MYVIMRC<cr>
" I don't use vim-fugitive too much but when I do I want those buffers it
" creates to be gone by the time I'm done with it. That's what the line above
" does, it removes those fugitive buffers.
"autocmd BufReadPost fugitive://* set bufhidden=delete
" .hamljs files should be using the haml mode.
autocmd BufRead,BufNewFile *.hamljs set filetype=haml
" resizes the quickfix window to match it's contents.
"au FileType qf call AdjustWindowHeight(3, 15)
"function! AdjustWindowHeight(minheight, maxheight)
" exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _"
"endfunction
" call update on the current file whenever you leave it. So that your files
" will always be saved.
"autocmd BufLeave,FocusLost * silent! update
""I've used this in the past to do a replace in project kind of operation.
"Unfortunately this is how ugly it looks in vim."
" The custom :Qargs command sets the arglist to contain each of the files
" referenced by the quickfix list.
"command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
"function! QuickfixFilenames()
" " Building a hash ensures we get each buffer only once
" let buffer_numbers = {}
" for quickfix_item in getqflist()
" let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
" endfor
" return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
"endfunction
"That's the last one. I'm using vim in terminal inside tmux so I want my vim
"windows to resize themselves whenever I resize the terminal window.
autocmd VimResized * :wincmd =
" NERDTree
nmap <leader>n :NERDTreeToggle<CR>
nmap <leader>m :NERDTreeFind<CR>
"let NERDTreeHighlightCursorline=1
let NERDTreeIgnore = ['tmp', '.yardoc', 'pkg']
" Disable NERDTreeDirArrows (use +dir -file)
let g:NERDTreeDirArrows=0 " cannot get powerline arrow to work in some environments
"let g:NERDTreeDirArrows = 1
"let g:NERDTreeDirArrowExpandable = '>'
"let g:NERDTreeDirArrowCollapsible = '<'
" Vim-airline
let g:airline_powerline_fonts = 1
" Set up line number
set number
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Tmux helper
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Compeletion
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Complete till longest common string.
" When more than one match exists, list them all.
set wildmode=longest,list
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Ignore images and log files
set wildignore+=*.gif,*.jpg,*.png,*.log
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Ignore rails temporary asset caches
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/*
" Ignore custom folders
set wildignore+=*/resources/*
" Ignore node modules
set wildignore+=node_modules/*
" Disable temp and backup files
set wildignore+=*.swp,*~,._*
" Disable osx index files
set wildignore+=.DS_Store
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => file type specific settings
" example JSON files have the javascript mode enabled, markdown files have
" different spaces/tabs setting, and so on.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup vimrcEx
" Clear all autocmds for the current group
autocmd!
" Jump to last cursor position unless it's invalid or in an event
" handler or
" a git commit
au BufReadPost *
\ if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Some file types use real tabs
au FileType {make,gitconfig} set noexpandtab sw=4
" Treat JSON files like JavaScript
au BufNewFile,BufRead *.json setf javascript
" Make Python follow PEP8
au FileType python set sts=4 ts=4 sw=4 tw=79
" Make sure all markdown files have the correct filetype
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} setf markdown
" MultiMarkdown requires 4-space tabs
au FileType markdown set sts=4 ts=4 sw=4
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
let python_highlight_all = 1
syntax enable
syntax sync fromstart
set background=dark
colorscheme desert
"colorscheme railscasts
highlight Normal guifg=grey90
"hi TabLineFill ctermfg=Grey
hi TabLine ctermbg=LightBlue
hi TabLineSel ctermbg=Red
"hi Title ctermfg=LightBlue ctermbg=Magenta
"vmap <C-x> :!pbcopy<CR>
""map <C-c> :w !pbcopy<CR><CR>
"nmap <F2> :w !pbcopy<CR><CR>
"vmap <C-v> :r !pbpaste<CR>
"
" Before having clipboard working, make sure vim is compiled with clipboard
" enabled.
" > vim --version | grep "clipboard"
" you shall see "+clipboard" rather than "-clipboard"
" yank to clipboard
if has("clipboard")
set clipboard=unnamed " copy to the system clipboard
if has("unnamedplus") " X11 support
set clipboard+=unnamedplus
endif
endif
autocmd FileType python nnoremap <buffer> <F9> :w<CR>:ter python3 %<CR>
autocmd FileType python nnoremap <buffer> <F10> :w<CR>:exec '!python3' shellescape(@%, 1)<CR>
" autocmd FileType python nnoremap <buffer> <F10> :w<CR>:!clear; python3 %<CR>
" wrap or not wrap long line display
" :set wrap
" :set nowrap
"
":set showbreak=↪\
:set showbreak=>
":set list // show line end $
:set nolist
"set listchars=tab:→\ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Setup for Powerline
" Fixes issues like no color for vim within tmux
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set guifont=Inconsolata\ for\ Powerline:h15
let g:Powerline_symbols = 'fancy'
set encoding=utf-8
set t_Co=256
set fillchars+=stl:\ ,stlnc:\
set term=xterm-256color
set termencoding=utf-8
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"