/
vimrc
394 lines (325 loc) · 10.1 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
set nocompatible
filetype off
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Python for neovim
let g:python3_host_prog = '/usr/local/bin/python3'
let g:python_host_prog = '/usr/local/var/pyenv/shims/python2'
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
Plug 'f-person/git-blame.nvim'
Plug 'pangloss/vim-javascript'
Plug 'ms-jpq/chadtree', {'branch': 'chad', 'do': 'python3 -m chadtree deps'}
Plug 'ryanoasis/vim-devicons'
Plug 'tpope/vim-vividchalk'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-tbone'
Plug 'kchmck/vim-coffee-script'
Plug 'tpope/vim-ragtag'
Plug 'tpope/vim-haml'
Plug 'slim-template/vim-slim'
Plug 'Townk/vim-autoclose'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'scrooloose/nerdcommenter'
Plug 'vim-syntastic/syntastic'
Plug 'dense-analysis/ale'
Plug 'othree/html5.vim'
Plug 'janx/vim-rubytest'
Plug 'ap/vim-css-color'
Plug 'adelarsq/vim-matchit'
Plug 'ervandew/supertab'
" telescope
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" For vim-snipmate
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'majutsushi/tagbar'
Plug 'chr4/nginx.vim'
Plug 'mattn/emmet-vim'
Plug 'tpope/vim-bundler'
Plug 'airblade/vim-gitgutter'
Plug 'Yggdroot/indentLine'
Plug 'Yggdroot/hiPairs'
Plug 'mileszs/ack.vim'
Plug 'rking/ag.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'moll/vim-node'
Plug 'digitaltoad/vim-pug'
Plug 'skalnik/vim-vroom'
Plug 'fatih/vim-go'
Plug 'rainerborene/vim-reek'
" Rust
Plug 'rust-lang/rust.vim'
"Python related stuff
Plug 'python-mode/python-mode'
Plug 'nvie/vim-flake8'
"Plug 'davidhalter/jedi-vim'
"JXML
Plug 'git@github.com:zopim/vim-jxml.git'
"React related
Plug 'MaxMEllon/vim-jsx-pretty'
"PR Reviews
Plug 'sindrets/diffview.nvim'
" fancy searchers
set rtp+=~/.fzf
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'jremmen/vim-ripgrep'
" barbar
Plug 'kyazdani42/nvim-web-devicons'
Plug 'romgrk/barbar.nvim'
call plug#end()
" Toggle CHADTree with \n
map <Leader>n :CHADopen<CR>
map <F3> :CHADopen<CR>
" Toggle git-blame.nvim
nnoremap <F4> <CMD>GitBlameToggle<CR>
let g:gitblame_enabled = 1
map <Leader>te :tabe<CR>
" Toggle Hex editing
map <F8> :%!xxd<CR>
map <F9> :%!xxd -r<CR>
" Tagbar
map <Leader>g :TagbarToggle<CR>
" vim-rails
map <Leader>rp :Rextract
map <Leader>rm :Emodel<CR>
map <Leader>rc :Econtroller<CR>
map <Leader>rv :Eview<CR>
map <Leader>ra :A<CR>
map <Leader>rr :R<CR>
map <Leader>t :CtrlP<CR>
" Clear CtrlP cache
map <Leader>cp :CtrlPClearAllCaches<CR>
map <Leader>ct :CtrlPClearAllCaches<CR>
" code review stuff
cnoreabbrev cdiff DiffviewOpen
nnoremap <Leader>dc <CMD>DiffviewClose<CR>
nnoremap <Leader>dtf <CMD>DiffToggleFiles<CR>
nnoremap <Leader>dff <CMD>DiffviewFocusFiles<CR>
" map something to search faster for current keyword
map <Leader>ag yiw:Ag <C-R>0<CR>
map <Leader>rg yiw:Rg <C-R>0<CR>
" telescope
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>flg <cmd>Telescope live_grep<cr>
nnoremap <leader>frg yiw<cmd>Telescope live_grep<cr><c-r>0<cr>
nnoremap <leader>fgf <cmd>Telescope git_files<cr>
nnoremap <leader>fb <cmd>Telescope file_browser<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" Rspec.vim mappings
"map <Leader>r :call RunCurrentSpecFile()<CR>
"map <Leader>rn :call RunNearestSpec()<CR>
"map <Leader>rl :call RunLastSpec()<CR>
"map <Leader>ra :call RunAllSpecs()<CR>
" FZF
map <Leader>z :FZF<CR>
" Rust
map <Leader>rf :RustFmt<CR>
" barbar.nvim
" Move to previous/next
nnoremap <Leader>, :BufferPrevious<CR>
nnoremap <Leader>. :BufferNext<CR>
" Re-order to previous/next
nnoremap <Leader>t< :BufferMovePrevious<CR>
nnoremap <Leader>t> :BufferMoveNext<CR>
nnoremap <Leader>t1 :BufferGoto 1<CR>
nnoremap <Leader>t2 :BufferGoto 2<CR>
nnoremap <Leader>t3 :BufferGoto 3<CR>
nnoremap <Leader>t4 :BufferGoto 4<CR>
nnoremap <Leader>t5 :BufferGoto 5<CR>
nnoremap <Leader>t6 :BufferGoto 6<CR>
nnoremap <Leader>t7 :BufferGoto 7<CR>
nnoremap <Leader>t8 :BufferGoto 8<CR>
nnoremap <Leader>t9 :BufferLast<CR>
" Pin/unpin buffer
nnoremap <Leader>tp :BufferPin<CR>
" Close buffer
nnoremap <Leader>tc :BufferClose<CR>
syntax on
set fileencodings=utf-8
set fileencoding=utf-8
set encoding=utf-8
set tenc=utf-8
set ruler
set number
set incsearch
set hlsearch
set t_Co=256
set hidden " hide buffers, not close
set backspace=indent,eol,start
set autoindent
set cindent
set copyindent
set showmatch
set history=200
set undolevels=200
set pastetoggle=<F2>
set mouse="" "disable mouse support"
" Whitespace stuff
set tabstop=4
set shiftwidth=4
set softtabstop=4
"set list listchars=tab:▸\ ,eol:¬,trail:·
set noeol
set shiftround
set smarttab
"set nofoldenable
" Window settings
set wrap
set lbr
set cursorline
set title
"set visualbell
"set noerrorbells
" Share Mac clipboard
set clipboard=unnamed
" set folding
set foldmethod=syntax
"set foldmethod=indent
set foldnestmax=2
set foldlevel=1
let ruby_fold = 0
let php_folding = 1
"don't use the old regex
set re=0
"don't search for include files for completion
"http://stackoverflow.com/questions/2169645/vims-autocomplete-is-excruciatingly-slow
set complete-=i
" diable highlight temporarily
map <Leader>h :nohlsearch<CR>
" if opened file without sudo priv, use tee
cmap w!! w !sudo tee % > /dev/null
" Status bar
set laststatus=2
"set statusline=%t\ %y\ format:\ %{&ff};\ [%l,%c]
" let airline use powerline fancy fonts
let g:airline_powerline_fonts=1
let g:airline_theme='dark'
" ruby path if you are using RVM
" let g:ruby_path = system('rvm current')
let g:ruby_path = system('echo $HOME/.rbenv/shims')
let g:syntastic_ruby_checkers = ['rubocop', 'mri']
let g:syntastic_ruby_rubocop_exec = system('echo $HOME/.rbenv/shims/rubocop')
let g:ale_linters = {
\ 'ruby': ['rubocop'],
\ 'python': ['flake8'],
\ 'javascript': ['eslint'],
\}
" linters for javascript
let g:syntastic_javascript_checkers = ['jshint', 'jsxhint', 'eslint']
" PHPDoc for Vim: PDV
inoremap <C-G> <ESC>:call PhpDocSingle()<CR>i
nnoremap <C-G> :call PhpDocSingle()<CR>
vnoremap <C-G> :call PhpDocRange()<CR>
" Ctrl-Q to toggle Taglist
nnoremap <C-Q> :TlistToggle<CR>
" Syntastic
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_python_flake8_args='--ignore=W191,E101,E127,E128,C0103,E117'
" Flake8
let g:flake8_show_in_gutter=1
" vim-multiple-cursors
let g:multi_cursor_quit_key = '<Esc>'
" rust.vim autosave into RustFmt
let g:rustfmt_autosave = 1
" RubyTest - change from <Leader>t to <Leader>\
map <Leader>\ <Plug>RubyTestRun
"ctrlp
let g:ctrlp_map = '<c-p>'
set wildignore+=*.so,*.swp,*.zip
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_max_files=0
let g:ctrlp_max_depth=100
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
let g:ctrlp_clear_cache_on_exit = 0
if executable('rg')
"Use Ag over Grep
set grepprg=rg\ --color=never
"Use rg in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
let g:ctrlp_use_caching = 0
endif
" ripgrep
let g:rg_binary = '/opt/homebrew/bin/rg'
let g:rg_highlight = 'true'
" Gitgutter
let g:gitgutter_eager = 0
" Filetypes
au BufRead,BufNewFile *.ctp set filetype=php.html
au BufRead,BufNewFile /etc/nginx/* set ft=nginx
au BufRead,BufNewFile /usr/local/nginx/conf/* set ft=nginx
" Default color scheme
highlight Comment ctermfg=darkcyan
highlight Search term=reverse ctermbg=4 ctermfg=7
"let g:solarized_visibility='medium'
"let g:solarized_contrast='normal'
set background=dark
colorscheme vividchalk
" Swap files. Generally things are in version control
" don't use backupfiles either.
set noswapfile
set nobackup
set nowritebackup
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" python-mode
let g:pymode_lint_ignore = 'W191,E101,E127,E128,C0103,E117'
map <Leader>pl :PymodeLint<CR>
" Persistent undos
"set undodir=~/.vim/backup
"set undofile
" Autocompletes
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType js set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" make uses real tabs
au FileType make setl noexpandtab
" Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
au BufRead,BufNewFile *.rb set ft=ruby
" Map .twig files as jinja templates
au BufRead,BufNewFile *.{twig} set ft=htmljinja
" Map *.coffee to coffee type
au BufRead,BufNewFile *.coffee set ft=coffee
" Highlight JSON like Javascript
au BufNewFile,BufRead *.json set ft=javascript
" Make eruby filetype also html
au BufNewFile,BufRead *.erb set ft=eruby.html
" Map *.py to python type
au BufNewFile,BufRead *.py set ft=python
" make python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
"au FileType python setl softtabstop=4 shiftwidth=4 tabstop=4 textwidth=90 expandtab
au FileType python setl softtabstop=0 noexpandtab shiftwidth=4 textwidth=90
au FileType rst setl textwidth=80
" Make ruby use 2 spaces for indentation.
au FileType ruby setl softtabstop=2 tabstop=2 shiftwidth=2 expandtab
au FileType eruby setl softtabstop=2 tabstop=2 shiftwidth=2 expandtab
" PHP settings
au FileType php setl textwidth=120 softtabstop=4 shiftwidth=4 tabstop=4 noexpandtab
" Javascript settings
au FileType javascript setl textwidth=120 softtabstop=4 shiftwidth=4 tabstop=4 noexpandtab
" Coffeescript uses 2 spaces too.
au FileType coffee setl softtabstop=2 shiftwidth=2 tabstop=2 expandtab