-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
286 lines (242 loc) · 7.45 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
" Disable vi compatibility
set nocompatible
" Plugins
" -----------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
" Editor
Plug 'ctrlpvim/ctrlp.vim'
Plug 'dyng/ctrlsf.vim'
Plug 'scrooloose/nerdtree'
Plug 'mkitt/pigment'
Plug 'yssl/QFEnter'
Plug 'ervandew/supertab'
Plug 'scrooloose/syntastic'
Plug 'mkitt/tabline.vim'
Plug 'ton/vim-bufsurf'
Plug 'mhinz/vim-grepper'
Plug 'henrik/vim-indexed-search'
Plug 'terryma/vim-multiple-cursors'
Plug 'nelstrom/vim-visual-star-search'
Plug 'vim-scripts/YankRing.vim'
" Editing
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
" Filetypes
Plug 'othree/html5.vim'
Plug 'keith/swift.vim'
Plug 'fatih/vim-go'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'tpope/vim-rails'
Plug 'derekwyatt/vim-scala'
Plug 'elixir-lang/vim-elixir'
Plug 'hashivim/vim-terraform'
" Utility
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
" Add local bundles
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
call plug#end()
runtime! macros/matchit.vim
filetype plugin indent on
syntax enable
" Preferences
" -----------------------------------------------------------------------------
set autoindent
set autoread
set autowrite
set backspace=2
set clipboard=unnamed
set complete-=i
set completeopt=longest,menu
set directory=~/.vim/tmp/swap/
set display+=lastline
set expandtab
set hidden
set history=1000
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set list
set listchars=tab:▸\ ,eol:¬,trail:·
set mouse=a
set nobackup
set nojoinspaces
set noshowcmd
set nostartofline
set nowrap
set nrformats-=octal
set number
set ruler
set scrolloff=3
set sessionoptions-=options
set shiftround
set shiftwidth=2
set showmatch
set sidescrolloff=3
set smartcase
set smartindent
set smarttab
set softtabstop=2
set splitright splitbelow
set tabstop=2
set title
set ttimeout
set ttimeoutlen=50
set ttyfast
set undolevels=1000
set wildignore+=*.DS_Store
set wildmenu
set wildmode=longest:full,full
if has("balloon_eval") && has("unix")
set ballooneval
endif
if &t_Co == 8 && $TERM !~# '^linux'
set t_Co=16
endif
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j
endif
if executable('rg')
set grepprg=rg\
let g:ctrlp_user_command='rg --files %s'
let g:ctrlp_use_caching=0
endif
let g:ctrlp_by_filename=1
let g:ctrlp_extensions=['line']
let g:ctrlp_cache_dir=$HOME.'/.vim/tmp/ctrlp/'
let g:ctrlp_custom_ignore='vendor/bundle\|.bundle\|tmp\|spec/support/fixtures\|docs/api\|public/uploads\|.git$'
let g:ctrlp_map='<F1>'
let g:ctrlsf_auto_close=0
let g:netrw_liststyle=3
let g:NERDTreeWinSize=40
let g:NERDTreeMinimalUI=1
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeMapUpdir='-'
let g:SuperTabLongestEnhanced=1
let g:SuperTabLongestHighlight=1
" Open quick fix and location window items with CtrlP commands
let g:qfenter_enable_autoquickfix=0
let g:qfenter_keymap = {}
let g:qfenter_keymap.vopen = ['<C-v>']
let g:qfenter_keymap.hopen = ['<C-CR>', '<C-s>', '<C-x>']
let g:qfenter_keymap.topen = ['<C-t>']
let g:syntastic_auto_loc_list=1
let g:syntastic_aggregate_errors=1
let g:syntastic_always_populate_loc_list=1
let g:syntastic_css_checkers=['stylelint']
if executable('node_modules/.bin/stylelint')
let g:syntastic_css_stylelint_exec='node_modules/.bin/stylelint'
endif
let g:syntastic_javascript_checkers=['eslint', 'flow']
let g:syntastic_javascript_eslint_args="--rule 'no-console: 0'"
if executable('eslint_d')
let g:syntastic_javascript_eslint_exec='eslint_d'
endif
if executable('node_modules/.bin/flow')
let g:syntastic_javascript_flow_exec='node_modules/.bin/flow'
let g:syntastic_javascript_flow_exe='node_modules/.bin/flow --show-all-errors --json --quiet'
endif
let g:yankring_window_height=10
let g:yankring_history_dir=$HOME.'/.vim/tmp/yankring/'
let g:indexed_search_show_index_mappings=0
let g:indexed_search_colors=0
let g:javascript_enable_domhtmlcss=1
let g:javascript_plugin_flow=1
let g:jsx_ext_required=0
" Mappings
" -----------------------------------------------------------------------------
" RSI reduction
nnoremap j gj
nnoremap k gk
" Move between splits
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" Another alternative mapping
nnoremap <silent><C-@> :CtrlP<CR>
" NERDTree in a buffer (like netrw)
nnoremap <silent>- :silent edit %:p:h<CR>
nnoremap <silent>_ :silent edit .<CR>
" Override jumplist commands
nnoremap <silent><C-i> :BufSurfBack<CR>
nnoremap <silent><C-o> :BufSurfForward<CR>
" Function keys
let g:ctrlp_map='<F1>'
noremap <F2> :NERDTreeToggle<CR>
noremap <F3> :CtrlPBuffer<CR>
nnoremap <F4> :GrepperRg<space>
xnoremap <F4> y:<c-u>GrepperRg -F <C-R>=shellescape(expand(@"),1)<CR>
nmap <F5> <Plug>CtrlSFPrompt
vmap <F5> <Plug>CtrlSFVwordExec
noremap <F10> :vertical wincmd f<CR>
noremap <F11> :BufSurfBack<CR>
noremap <F12> :BufSurfForward<CR>
" The `g` commands (testing)
nnoremap <silent>gF :vertical wincmd f<CR>
nnoremap <silent>gl :CtrlP<CR>
nnoremap <silent>gL :CtrlPBuffer<CR>
nnoremap <silent>gy :NERDTreeToggle<CR>
nnoremap gs :GrepperRg<space>
xnoremap gs y:<c-u>GrepperRg -F <C-R>=shellescape(expand(@"),1)<CR>
nmap gz <Plug>CtrlSFPrompt
vmap gz <Plug>CtrlSFVwordExec
" Visually select the text that was last edited/pasted
nnoremap <silent>gV `[v`]
" Clear the search highlight
noremap <silent><leader>\ :nohlsearch<CR>
" Remove whitespace
noremap <silent><leader>CW :%s/\s\+$//<CR>
" Yank/paste contents using an unnamed register
vnoremap <silent><leader>y "xy
noremap <silent><leader>p "xp
" Filetypes
" -----------------------------------------------------------------------------
func! Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
if has("autocmd")
augroup FTOptions
autocmd!
autocmd User Grepper :resize 10
autocmd QuickFixCmdPost *grep* botright copen
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
autocmd FileType markdown,text,txt setlocal tw=80 linebreak nolist wrap spell
autocmd BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
autocmd BufRead,BufNewFile .{babel,eslint}rc set filetype=json
autocmd BufRead,BufNewFile *.{flow} set filetype=javascript
autocmd BufRead,BufNewFile Dangerfile set filetype=ruby
" vim-go keybindings
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>b <Plug>(go-build)
autocmd FileType go nmap <leader>t <Plug>(go-test)
autocmd FileType go nmap <leader>c <Plug>(go-coverage)
autocmd FileType go nmap <Leader>ds <Plug>(go-def-split)
autocmd FileType go nmap <Leader>dv <Plug>(go-def-vertical)
autocmd FileType go nmap <Leader>dt <Plug>(go-def-tab)
autocmd FileType go nmap <Leader>gd <Plug>(go-doc)
autocmd FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
autocmd FileType go nmap <Leader>gb <Plug>(go-doc-browser)
autocmd FileType go nmap <Leader>s <Plug>(go-implements)
autocmd FileType go nmap <Leader>i <Plug>(go-info)
autocmd FileType go nmap <Leader>e <Plug>(go-rename)
" Abbreviations
autocmd FileType css iabbrev <buffer> bgc background-color:
autocmd FileType javascript iabbrev <buffer> cdl console.log()<Left><C-R>=Eatchar('\s')<CR>
augroup END
endif
" Theme
" -----------------------------------------------------------------------------
colorscheme pigment
" Load user config
" -----------------------------------------------------------------------------
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif