-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·607 lines (515 loc) · 22.2 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
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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
"
" Kyle Tolle's .vimrc
" TODO: See http://www.linode.com/wiki/index.php/Vim_Tutorial for more ideas
" Mostly for the h and l across lines feature
" Some settings borrowed from $VIMRUNTIME\vimrc_example.vim
" Configure Ruby version
" Using info from https://github.com/macvim-dev/macvim/issues/581#issuecomment-341876633
" Must have Ruby 2.5.3 installed using `brew install ruby`
" set rubydll=/usr/local/Cellar/ruby/2.5.3_1/lib/libruby.2.5.dylib
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Setting up Vundle - the vim plugin bundler
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"Add your bundles here
" To install new ones do: \s to source this update file and then :PluginInstall
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
let g:airline_theme='solarized'
Plugin 'wincent/command-t'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rhubarb'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-haml'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-jdaddy'
Plugin 'tpope/vim-rbenv'
Plugin 'tpope/vim-obsession'
Plugin 'vim-ruby/vim-ruby'
Plugin 'pangloss/vim-javascript'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'godlygeek/tabular'
Plugin 'sjl/gundo.vim'
Plugin 'jQuery'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'airblade/vim-gitgutter'
Plugin 'rizzatti/funcoo.vim'
Plugin 'rizzatti/dash.vim'
Plugin 'mattn/emmet-vim'
Plugin 'elzr/vim-json'
Plugin 'briancollins/vim-jst'
Plugin 'ngmy/vim-rubocop'
Plugin 'jgdavey/vim-blockle'
Plugin 'rorymckinley/vim-rubyhash'
Plugin 'kchmck/vim-coffee-script'
Plugin 'HerringtonDarkholme/yats'
Plugin 'ecomba/vim-ruby-refactoring'
Plugin 'AndrewRadev/splitjoin.vim'
Plugin 'wesQ3/vim-windowswap'
Plugin 'wavded/vim-stylus'
Plugin 't9md/vim-ruby-xmpfilter'
Plugin 'easymotion/vim-easymotion'
Plugin 'mhinz/vim-startify'
Plugin 'gioele/vim-autoswap'
" Plugin 'Yggdroot/indentLine'
" Also need to do `gem install rufo`
" Use it through :Rufo
Plugin 'ruby-formatter/rufo-vim'
Plugin 'thoughtbot/vim-rspec'
Plugin 'powerman/vim-plugin-AnsiEsc' " Use via :AnsiEsc
Plugin 'mileszs/ack.vim' " https://github.com/mileszs/ack.vim#keyboard-shortcuts
Plugin 'tarekbecker/vim-yaml-formatter' " https://github.com/tarekbecker/vim-yaml-formatter
" Tags
" Instal UniversalCtags from http://docs.ctags.io/en/latest/osx.html?highlight=install
" brew tap universal-ctags/universal-ctags
" brew install --HEAD universal-ctags
" https://vim.fandom.com/wiki/Browsing_programs_with_tags
" Plugin 'ludovicchabant/vim-gutentags'
Plugin 'majutsushi/tagbar'
" Writing plugins
Plugin 'reedes/vim-pencil'
Plugin 'junegunn/goyo.vim'
let g:instant_markdown_autostart = 0
" You can manually trigger markdown previewing with :InstantMarkdownPreview
Plugin 'suan/vim-instant-markdown'
Plugin 'vim-pandoc/vim-criticmarkup'
Plugin 'dbmrq/vim-ditto'
Plugin 'reedes/vim-wordy'
Plugin 'chrisbra/unicode.vim' " Use :UnicodeName to identify character under cursor
" All of your Plugins must be added before the following line
call vundle#end() " required
nmap <leader>p :PluginInstall<CR>
nmap <leader>P :PluginInstall!<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Stuff from $VIMRUNTIME\vimrc_example.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set backup " keep a backup file
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
set guioptions+=t
" Remove scrollbars!
set guioptions-=L
set guioptions-=R
set guioptions-=l
set guioptions-=r
" Use system clipboard by default
" Set this in VSCode by following steps at https://stackoverflow.com/a/61066089/249218
set clipboard=unnamed
" Don't use Ex mode, use Q for formatting
map Q gq
" Make Y yank to end of line instead of yank entire line
map Y y$
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 80 characters.
autocmd FileType text,markdown,ruby,javascript setlocal textwidth=80
set cc=80
hi ColorColumn ctermbg=lightgrey guibg=lightgrey
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" git commits always start on the first line.
" From http://vim.wikia.com/wiki/Always_start_on_first_line_of_git_commit_message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
autocmd VimEnter Rbenv shell 2.4.1
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Airline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:airline_powerline_fonts = 1
set laststatus=2
" Don't show git info
let g:airline_section_b = '' " Don't show git info. https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt#L369
let g:airline_section_y = '' " Don't show file encoding. https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt#L373
let g:airline#extensions#gutentags#enabled = 1 " https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt#L690
let g:airline#extensions#wordcount#enabled = 1 " https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt#L1253
" Install the fonts for the icons: https://powerline.readthedocs.org/en/latest/installation/osx.html#installation-osx
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
map <leader>b :NERDTreeFromBookmark
let NERDTreeMinimalUI=1 " YAGNI
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Backup/Temp files
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Store temporary files in a central spot
set backupdir=~/vimfiles/tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/vimfiles/tmp,~/.tmp,~/tmp,/var/tmp,/tmp
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Highlight whitespace at the end of lines
" From: http://vim.wikia.com/wiki/Highlight_unwanted_spaces
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
if has("autocmd")
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
endif " has("autocmd")
" Strip trailing whitespace from all lines in the file
map <Leader>w :%s/\s\+$//g<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Font, colors, highlighting
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable
" set background=dark
set background=light
colorscheme solarized
" colorscheme hemisukyle
" Set font
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 15
elseif has("gui_win32")
set guifont=Consolas:h15:cANSI
elseif has("gui_macvim")
set guifont=Droid\ Sans\ Mono\ for\ Powerline:h15
endif
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Window size/layout
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set columns=100 lines=56
set ch=2 "Set command line 2 lines high
set scrolloff=2 " Keeps 2 lines of context around the cursor
"Auto resizes tabs when toggling between them!
set winwidth=86 " Enough width for two 80 char splits using gvim
set winheight=5
set winminheight=5
set colorcolumn=80 " Highlight the 80 char column
set cursorline " --- Cursor crosshair
set cursorcolumn " /
set mousehide " Hides the mouse when typing
set hidden " Switch to another buffer when current one has modifications
set nu " Display line numbers
set relativenumber
" Remember more commands and search history
set history=1000
" Make tab completion for files/buffers act like bash
set wildmenu
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set ignorecase " Case insensitive search
set smartcase " Ignore's case of search only if all lowercase
set wildignore+=tmp,node_modules/**,vendor/assets/**,spec/reports/**
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Text formatting
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
setlocal spell spelllang=en_us
"http://jamescrisp.org/2007/03/01/_vimrc-for-ruby/
set autoindent " Auto indentation
set expandtab " All new tab characters will be turned to spaces.
set shiftround
set shiftwidth=2 " Set shift width to n characters
" Tab at start of line inserts shiftwidth spaces, elsewhere inserts tabstop spaces
set smarttab
set tabstop=2
" use :retab to convert all existing tab characters to match current tab
" settings.
"http://vim.wikia.com/wiki/Omni_completion
set ofu=syntaxcomplete#Complete
" http://oldwiki.rubyonrails.org/rails/pages/HowtoUseVimWithRails
"syntax on " Syntax highlighting, overrides color settings.
let g:rubycomplete_rails = 1
runtime! macros/matchit.vim " Load matchit (% to bounce from do to end, etc.)
set nojoinspaces
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Filetypes
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
au BufRead,BufNewFile *.less set filetype=css
au BufRead,BufNewFile *.scss set filetype=css
au BufRead,BufNewFile *.sass set filetype=css
au BufRead,BufNewFile *.rabl set filetype=ruby
au BufRead,BufNewFile Guardfile set filetype=ruby
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.json set filetype=json
au BufNewFile,BufReadPost *.styl set filetype=stylus
endif " has("autocmd")
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Key Mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map to open .vimrc easily
noremap <Leader>v :e ~/.vimrc<CR>
" Map to open .zshrc easily
noremap <Leader>z :e ~/.zshrc<CR>
"Map to clear highlights fast
noremap <Leader>h :noh<CR>
"Reload the vimrc
noremap <Leader>so :so ~/.vimrc<CR>
noremap <Leader>f :CommandTFlush<Enter>
" Reset the syntax highlighting for when it gets mixed up
noremap <Leader>i :syntax sync fromstart<CR>
" Make window splits easier to move between
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Things to do on file open/close
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"http://vim.wikia.com/wiki/Restore_screen_size_and_position
"RESTORE VIM POSITION
if has("gui_running")
function! ScreenFilename()
if has('amiga')
return "s:.vimsize"
elseif has('win32')
return $HOME.'\_vimsize'
else
return $HOME.'/.vimsize'
endif
endfunction
function! ScreenRestore()
" Restore window size (columns and lines) and position
" from values stored in vimsize file.
" Must set font first so columns and lines are based on font size.
let f = ScreenFilename()
if has("gui_running") && g:screen_size_restore_pos && filereadable(f)
let vim_instance = (g:screen_size_by_vim_instance==1?(v:servername):'GVIM')
for line in readfile(f)
let sizepos = split(line)
if len(sizepos) == 5 && sizepos[0] == vim_instance
silent! execute "set columns=".sizepos[1]." lines=".sizepos[2]
silent! execute "winpos ".sizepos[3]." ".sizepos[4]
return
endif
endfor
endif
endfunction
function! ScreenSave()
" Save window size and position.
if has("gui_running") && g:screen_size_restore_pos
let vim_instance = (g:screen_size_by_vim_instance==1?(v:servername):'GVIM')
let data = vim_instance . ' ' . &columns . ' ' . &lines . ' ' .
\ (getwinposx()<0?0:getwinposx()) . ' ' .
\ (getwinposy()<0?0:getwinposy())
let f = ScreenFilename()
if filereadable(f)
let lines = readfile(f)
call filter(lines, "v:val !~ '^" . vim_instance . "\\>'")
call add(lines, data)
else
let lines = [data]
endif
call writefile(lines, f)
endif
endfunction
if !exists('g:screen_size_restore_pos')
let g:screen_size_restore_pos = 1
endif
if !exists('g:screen_size_by_vim_instance')
let g:screen_size_by_vim_instance = 1
endif
if has("autocmd")
au VimEnter * if g:screen_size_restore_pos == 1 | call ScreenRestore() | endif
au VimLeavePre * if g:screen_size_restore_pos == 1 | call ScreenSave() | endif
endif " has("autocmd")
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pretty print json
" From: https://coderwall.com/p/tpfysw
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To format file as JSON: gg=G
au FileType json setlocal equalprg=python\ -m\ json.tool
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ruby Hash to JSON
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>j :%s/:\(\w*\)=>/"\1":/g \| :%s/nil/null/g \| :set ft=json \| :execute "normal gqaj" \| :noh<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tabularize
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>\| :Tab /\|<CR>
map <leader>= :Tab /=<CR>
map <leader>, :Tab /,\zs<CR>
map <leader>{ :Tab /{<CR>
map <leader>\: :Tab /:\zsl0r1<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Gundo
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:gundo_prefer_python3 = 1
nnoremap <Leader>g :GundoToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-ruby-xmpfilter
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Type ruby code, end the line with # => and then run <leader>r to have the
" comment populated with the output of running that line. Each time you run
" it, all commented lines are updated with new values. Great for seeing what
" is happening as you write a program, right from vim.
autocmd FileType ruby nmap <buffer> <leader>m <Plug>(xmpfilter-mark)
autocmd FileType ruby xmap <buffer> <leader>m <Plug>(xmpfilter-mark)
autocmd FileType ruby imap <buffer> <leader>m <Plug>(xmpfilter-mark)
autocmd FileType ruby nmap <buffer> <leader>r <Plug>(xmpfilter-run)
autocmd FileType ruby xmap <buffer> <leader>r <Plug>(xmpfilter-run)
autocmd FileType ruby imap <buffer> <leader>r <Plug>(xmpfilter-run)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Syntastic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-pencil
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:pencil#wrapModeDefault = 'soft'
let g:pencil#conceallevel=0
let g:markdown_syntax_conceal = 0
augroup pencil
" Remove ALL autocommands for the current group.
autocmd!
" autocmd FileType markdown,mkd call pencil#init({'wrap': 'soft'})
autocmd BufRead,BufNewFile,BufWinEnter *.{md,yaml} call pencil#init({'wrap': 'soft'})
" autocmd FileType text call pencil#init()
autocmd BufRead,BufNewFile,BufWinEnter *.{md,yaml} setlocal scrolloff=0 " Keeps 2 lines of context around the cursor
autocmd BufRead,BufNewFile,BufWinEnter *.{md,yaml} GitGutterDisable
autocmd BufRead,BufNewFile,BufWinEnter *.{md,yaml} setlocal nocursorcolumn " Remove vertical part of cursor crosshair.
autocmd BufRead,BufNewFile,BufWinEnter *.{md,yaml} setlocal cc=0 " Turn off column 80 highlight
" Replace HTML link with a markdown one
map <Leader>mdl :%s/<a\_.\{-}href="\(.\{-}\)".*>\(.\{-}\)<\/a>/\[\2\]\(\1\)/gc<CR>
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-ditto
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use autocmds to check your text automatically and keep the highlighting
" up to date (easier):
" Turning DittoOn for these files makes vim _really_ slow for large files.
" Let's turn it off by default and it's easily turned on later for when you
" want to figure out what words are reused a lot.
" au FileType markdown,text,tex DittoOn " Turn on Ditto's autocmds
nmap <leader>di <Plug>ToggleDitto " Turn Ditto on and off
" If you don't want the autocmds, you can also use an operator to check
" specific parts of your text:
" vmap <leader>d <Plug>Ditto " Call Ditto on visual selection
" nmap <leader>d <Plug>Ditto " Call Ditto on operator movement
nmap =d <Plug>DittoNext " Jump to the next word
nmap -d <Plug>DittoPrev " Jump to the previous word
nmap +d <Plug>DittoGood " Ignore the word under the cursor
nmap _d <Plug>DittoBad " Stop ignoring the word under the cursor
nmap ]d <Plug>DittoMore " Show the next matches
nmap [d <Plug>DittoLess " Show the previous matches
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-easymotion
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" `s{char}{label}`
nmap s <Plug>(easymotion-overwin-f)
" or
" `s{char}{char}{label}`
" Need one more keystroke, but on average, it may be more comfortable.
" nmap s <Plug>(easymotion-overwin-f2)
" Turn on case insensitive feature
let g:EasyMotion_smartcase = 1
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-rubocop
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:vimrubocop_config = '~/code/realvolve/realvolve/.rubocop.yml'
" The default keyboard shortcut to run Rubocop is <Leader>ru
nmap <Leader>ra :RuboCop -a<CR>
" View other keyboard shortcuts here: https://github.com/ngmy/vim-rubocop#keyboard-shortcuts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Create parent directories on save
" http://stackoverflow.com/a/4294176/249218
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RSpec.vim support
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TODO: Still need to flesh this out.
let g:rspec_runner = "os_x_iterm"
" Key mappings
map <Leader>rt :call RunCurrentSpecFile()<CR>
map <Leader>rs :call RunNearestSpec()<CR>
map <Leader>rl :call RunLastSpec()<CR>
map <Leader>rr :call RunAllSpecs()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tags
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" nmap <F8> :TagbarToggle<CR>
map <Leader>bt :TagbarToggle<CR>
:set tags=./tags;
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vim-yaml-formatter
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:yaml_formatter_indent_collection=1