-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
471 lines (351 loc) · 14 KB
/
vimrc
File metadata and controls
471 lines (351 loc) · 14 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
" Example Vim configuration.
" Copy or symlink to ~/.vimrc or ~/_vimrc.
" Vundle ----------------------------------------------------------------- {{{
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'ack.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'snipmate-snippets'
Plugin 'Tabular'
Plugin 'cucumber.zip'
Plugin 'endwise.vim'
Plugin 'rails.vim'
Plugin 'ruby-matchit'
Plugin 'ecomba/vim-ruby-refactoring.git'
Plugin 'surround.vim'
Plugin 'html-improved-indentation'
Plugin 'Haml'
Plugin 'unimpaired.vim'
Plugin 'commentary.vim'
Plugin 'vim-coffee-script'
Plugin 'Syntastic'
Plugin 'EasyMotion'
Plugin 'tomtom/tlib_vim'
Plugin 'ctrlp.vim'
Plugin 'tpope/vim-dispatch.git'
Plugin 'quickfixsigns'
Plugin 'ruby.vim'
Plugin 'mattn/emmet-vim.git'
Plugin 'Vim-Rspec'
Plugin 'vim-airline'
Plugin 'ragtag.vim'
Plugin 'tpope/vim-markdown'
Plugin 'hexHighlight.vim'
Plugin 'rizzatti/dash.vim'
Plugin 'YankRing.vim'
Plugin 'elixir-lang/vim-elixir'
Plugin 'avdgaag/vim-phoenix'
Plugin 'hashivim/vim-terraform'
Plugin 'juliosueiras/vim-terraform-completion'
Plugin 'slashmili/alchemist.vim'
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'craigemery/vim-autotag'
Plugin 'posva/vim-vue'
Plugin 'leafgarland/typescript-vim'
Plugin 'pangloss/vim-javascript'
Plugin 'peitalin/vim-jsx-typescript'
Plugin 'MaxMEllon/vim-jsx-pretty'
Plugin 'arthurxavierx/vim-caser'
Plugin 'iamcco/markdown-preview.nvim'
Plugin 'catppuccin/nvim'
call vundle#end()
filetype plugin indent on
" }}}
" Basic options ---------------------------------------------------------- {{{
let mapleader=","
set nostartofline " Remeber cursor column after buffer switch
set nocompatible " Must come first because it changes other options.
syntax enable " Turn on syntax highlighting.
filetype plugin indent on " Turn on file type detection.
runtime macros/matchit.vim " Load the matchit plugin.
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set backspace=indent,eol,start " Intuitive backspacing.
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set wildignore+=*.o,*.obj
set wildignore+=*.o,*.obj,.git,public/system/**,tmp,upload,node_modules,deps,storage,build,_build,_deps,**/__pycache__/
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set visualbell " No beeping.
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set directory=/tmp//,. " Keep swap files in one location
set previewheight=20
" UNCOMMENT TO USE
set tabstop=2 " Global tab width.
set shiftwidth=2 " And again, related.
set expandtab " Use spaces instead of tabs
set laststatus=2 " Show the status line all the time
set mouse=a
" highlight current line
" set cursorline
set lazyredraw
set autoread " Auto-refresh files that changed outside vim
" Fix for vim-autotag (https://github.com/craigemery/vim-autotag/issues/34)
let g:autotagStartMethod='fork'
" }}}
" Appearance ------------------------------------------------------------- {{{
set guifont=Inconsolata-dz\ for\ Powerline:h12
set guioptions=m " hide top menu bar
if has("mac") && has("gui")
set macmeta
" enable fullscreen
set fuopt+=maxhorz
map <D-CR> :set invfu<CR>
endif
" Theme
" colorscheme railscasts
" colorscheme solarized
colorscheme molokai
" window sizes
set winwidth=84
" We have to have a winheight bigger than we want to set winminheight. But if
" we set winheight to be huge before winminheight, the winminheight set will
" fail.
set winheight=5
set winminheight=5
set winheight=999
" }}}
" Folding ---------------------------------------------------------------- {{{
set foldlevelstart=0
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
nnoremap zO zCzO
" "Focus" the current line. Basically:
"
" 1. Close all folds.
" 2. Open just the folds containing the current line.
" 3. Move the line to a little bit (15 lines) above the center of the screen.
" 4. Pulse the cursor line. My eyes are bad.
"
" This mapping wipes out the z mark, which I never use.
"
" I use :sus for the rare times I want to actually background Vim.
nnoremap <c-z> mzzMzvzz15
function! MyFoldText()
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction
set foldtext=MyFoldText()
" }}}
" Plugins ---------------------------------------------------------------- {{{
:nmap <silent> <leader>d <Plug>DashSearch
:nmap <silent> <leader>D <Plug>DashGlobalSearch
let g:airline_powerline_fonts = 1
let g:airline#extensions#branch#displayed_head_limit = 17
" Syntastic -------------------------------------------------------------- {{{
" tell ruby not to output warnings. They have too many false positives
let g:syntastic_ruby_mri_args='-T1 -c'
" }}}
" NerdTree --------------------------------------------------------------- {{{
map <leader>nn :NERDTreeToggle<Enter>
map <F3> :NERDTreeToggle<Enter>
map <leader>nr :NERDTreeFind<Enter>
"NERDtree defaults
let NERDTreeHijackNetrw=0
let NERDTreeShowBookmarks=1
" }}}
" Ack Plugin ------------------------------------------------------------- {{{
map <leader>FF :Ack -Q ""<Left>
map <leader>Ff :Ack ""<Left>
map <leader>FA :Ack -Q "<c-r><c-w>"<CR>
map <leader>Fa :Ack "<c-r><c-w>"<CR>
" }}}
" EasyMotion plugin ------------------------------------------------------ {{{
let g:EasyMotion_leader_key = '\'
" }}}
" Rails PLugin ----------------------------------------------------------- {{{
"map <leader>rm :Rmodel<CR>
"map <leader>rc :Rcontroller<CR>
"map <leader>rv :Rview<CR>
"map <leader>rs :e db/schema.rb<CR>
" }}}
" Taglist ---------------------------------------------------------------- {{{
nnoremap <silent> <F7> :TlistToggle<CR>
" }}}
" multi cursor ----------------------------------------------------------- {{{
let g:multi_cursor_start_key='<C-s>'
" }}}
" Fugitive --------------------------------------------------------------- {{{
" auto-close fugitive buffers
autocmd BufReadPost fugitive://* set bufhidden=delete
nmap <leader>gaa :!git add -A; git status<CR>
nmap <leader>gc :Gcommit<CR>
nmap <leader>gs :Gstatus<CR><C-w>20+
nmap <leader>gl :Glog<CR>
nmap <leader>gd :Gdiff<CR>
nmap <leader>dg :diffget<CR>
nmap <leader>dp :diffput<CR>
" }}}
" GitV ------------------------------------------------------------------- {{{
nmap <leader>gv :Gitv --all<cr>
nmap <leader>gV :Gitv! --all<cr>
vmap <leader>gV :Gitv! --all<cr>
" }}}
" CtrlP ----------------------------------------------------------------- {{{
let g:ctrlp_map = '<leader><leader>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_show_hidden = 1
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$\|\.yardoc$\|public\/system$\|tmp$\|upload$\|fixtures\/vcr_cassettes$\|node_modules$|deps$|storage$|build$',
\ 'file': '\.exe$\|\.so$\|\.dat$'
\ }
" Do not try to be smart when determining the working directory. Use the
" actual vim working directory instead.
let g:ctrlp_working_path_mode = '0'
" }}}
" YankRing --------------------------------------------------------------- {{{
nmap <leader>yr :YRShow<CR>
" }}}
" Powerline ------------------------------------------------------------- {{{
set rtp+=/Users/simons/dotfiles/vim/bundle/powerline/powerline/bindings/vim
" }}}
" vim-dispatch ----------------------------------------------------------- {{{
nmap <leader>m :Make<CR>
" }}}
" quickfixsigns ---------------------------------------------------------- {{{
" default: ['qfl', 'loc', 'marks', 'vcsdiff', 'breakpoints']
let g:quickfixsigns_classes = ['qfl', 'loc', 'vcsdiff', 'breakpoints']
" }}}
" Tabularize ------------------------------------------------------------- {{{
if exists(":Tabularize")
nmap <Leader>t<Bar> :Tabularize /<Bar><CR>
vmap <Leader>t<Bar> :Tabularize /<Bar><CR>
nmap <Leader>t: :Tabularize /:\zs<CR>
vmap <Leader>t: :Tabularize /:\zs<CR>
nmap <Leader>t= :Tabularize /=\zs<CR>
vmap <Leader>t= :Tabularize /=\zs<CR>
endif
" }}}
" VIM-Rspec -------------------------------------------------------------- {{{
let g:rspec_command = "compiler rspec | Make -f documentation {spec}"
autocmd User BufEnterRails let g:rspec_command = "compiler rspec | set makeprg=bin/rspec | Make -f documentation {spec}"
map <Leader>sf :call RunCurrentSpecFile()<CR>
map <Leader>ss :call RunNearestSpec()<CR>
map <Leader>sl :call RunLastSpec()<CR>
map <Leader>sa :call RunAllSpecs()<CR>
" }}}
" }}}
" Quick Edits ------------------------------------------------------------ {{{
map <leader>vc :tabedit $MYVIMRC<Enter><esc>
map <leader>vq :tabedit $HOME/Documents/vim-questions.txt<Enter><esc>
map <leader>vs :tabedit $HOME/Documents/vim-cheatsheet.txt<Enter><esc>
map <leader>vn :tabedit $HOME/Documents/vim-notes.txt<Enter><esc>
" }}}
" Search and replace ----------------------------------------------------- {{{
map <leader>ra :%s/<c-r><c-w>/<c-r><c-w>/g<Left><Left>
map <leader>rp :%s/<c-r><c-w>/<c-r><c-w>/gc<Left><Left><Left>
map <leader>rg yiw:Ack -Q "<c-r>""<CR>:Qargs <bar> argdo %s/<c-r>"//gc <bar> update<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
" execute command on quickfix list
" from http://stackoverflow.com/questions/5686206/search-replace-using-quickfix-list-in-vim/5686810#5686810
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(values(buffer_numbers))
endfunction
" }}}
" Show hidden characters ------------------------------------------------- {{{
" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
if has("mac") && has("gui")
set listchars=tab:▸\ ,eol:¬
endif
" }}}
" Navigation ------------------------------------------------------------- {{{
" quick changing buffers, windows and tabs
nmap <C-h> 10h
nmap <C-j> 5j
nmap <C-k> 5k
nmap <C-l> 10l
nmap <A-h> :tabprevious<Enter>
nmap <A-l> :tabnext<Enter>
" go to end of selection after yank
vmap y ygv<Esc>
" }}}
" Highlighting ----------------------------------------------------------- {{{
nnoremap <CR> :noh<CR><CR>
:set colorcolumn=+1
:highlight ColorColumn ctermbg=lightgrey guibg=#222222
" }}}
" Quickfix list ----------------------------------------------------------- {{{
" clear the quickfix list
com! Clfx call setqflist([])
nmap <leader>qc :Clfx<cr>:copen<cr>:cclose<cr>
" }}}
" File Types ------------------------------------------------------------- {{{
filetype on
autocmd FileType xml,python setlocal ts=4 sts=4 sw=4 expandtab
" VIM -------------------------------------------------------------------- {{{
augroup ft_vim
au!
au FileType vim setlocal foldmethod=marker
au FileType help setlocal textwidth=78
augroup END
" }}}
" Cucumber---------------------------------------------------------------- {{{
" automatically align cucumber bars (https://gist.github.com/287147)
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" }}}
" Ruby ------------------------------------------------------------------- {{{
autocmd FileType ruby imap <C-l> =><Space>
autocmd FileType ruby set textwidth=100
autocmd BufNewFile,BufRead *.thor set filetype=ruby
autocmd BufNewFile,BufRead *.arb set filetype=ruby
autocmd BufNewFile,BufRead Guardfile set filetype=ruby
autocmd BufNewFile,BufRead *.html.erb set filetype=eruby.html
" }}}
" RSpec ------------------------------------------------------------------ {{{
autocmd BufNewFile,BufRead *_spec.rb set filetype=ruby.ruby-rspec
" }}}
" Elixir ------------------------------------------------------------------- {{{
autocmd FileType elixir imap <C-l> \|><Space>
autocmd FileType elixir imap <C-j> <-<Space>
autocmd FileType elixir imap <C-k> -><Space>
" }}}
" }}}
" Hex Colors ------------------------------------------------------------- {{{
nmap <leader>h :call HexHighlight()<Return>
" }}}
" Directory navigation --------------------------------------------------- {{{
" double percentage sign in command mode is expanded
" to directory of current file - http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
" }}}