-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
337 lines (285 loc) · 10.4 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
" Vundle
" ------------------------------------------- "
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" Drew's plugins
Plugin 'mhinz/vim-startify'
Plugin 'wesQ3/vim-windowswap'
Plugin 'tpope/vim-sensible'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'Valloric/MatchTagAlways'
Plugin 'alvan/vim-closetag'
Plugin 'othree/javascript-libraries-syntax.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'ternjs/tern_for_vim'
Plugin 'Raimondi/delimitMate'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'dkprice/vim-easygrep'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'mileszs/ack.vim'
Plugin 'dyng/ctrlsf.vim'
Plugin 'tpope/vim-surround'
Plugin 'easymotion/vim-easymotion'
Plugin 'w0rp/ale'
Plugin 'solarnz/thrift.vim'
Plugin 'flowtype/vim-flow'
"Plugin 'romainl/vim-qf'
Plugin 'JamshedVesuna/vim-markdown-preview'
Plugin 'jparise/vim-graphql'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
" prevents vim from sometimes creating a new file instead of modifying the old
" one when saving, which can interfere with the webpack file watcher
set backupcopy=yes
" Plugins
" ------------------------------------------- "
" map leader key here in case i use it in plugins?
" not sure if this matters
let mapleader=" "
" Sublime style multiple cursors
" HTML syntax highlighting
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'jinja' : 1,
\ 'javascript' : 1,
\}
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.jsx"
let g:used_javascript_libs = 'underscore,jquery,ramda,react,lodash'
let g:jsx_ext_required = 0
" Autocomplete
" make sure to run ~/.vim/bundle/YouCompleteMe/install.py --tern-completer
" after intitial PluginInstall
let g:ycm_autoclose_preview_window_after_completion = 1
"let g:ycm_add_preview_to_completeopt = 0
"set completeopt-=preview
let g:ycm_show_diagnostics_ui = 0
let g:ycm_min_num_of_chars_for_completion = 1
let g:ycm_register_as_syntastic_checker = 0
let g:ycm_filepath_blacklist = {}
let g:ycm_error_symbol = '❌'
let g:ycm_warning_symbol = '⚠️'
"set omnifunc=syntaxcomplete#Complete
"let g:tern_map_keys=1
"let g:tern_show_argument_hints="on_hold"
" Syntax checker
"function! FindConfig(prefix, what, where)
"let cfg = findfile(a:what, escape(a:where, ' ') . ';')
"return cfg !=# '' ? ' ' . a:prefix . ' ' . cfg : ''
"endfunction
"autocmd FileType javascript let b:syntastic_javascript_jscs_args =
"\ get(g:, 'syntastic_javascript_jscs_args', '') .
"\ FindConfig('-c', '.eslintrc', expand('<amatch>:p:h', 1))
" flow
" ------------------------------------------------
" Syntax highlighting
let g:javascript_plugin_flow = 1
"Use locally installed flow
let local_flow = finddir('node_modules', '.;') . '/.bin/flow'
if matchstr(local_flow, "^\/\\w") == ''
let local_flow= getcwd() . "/" . local_flow
endif
if executable(local_flow)
let g:flow#flowpath = local_flow
endif
let g:flow#autoclose = 1
let g:flow#showquickfix = 0 " let ale handle it
nnoremap <Leader>d :FlowJumpToDef<CR>
" ------------------------------------------------
" ALE and prettier config
" ------------------------------------------------
let g:ale_fixers = {}
let g:ale_fixers['javascript'] = ['prettier', 'eslint']
let g:ale_linters = {}
let g:ale_linters['javascript'] = ['flow', 'eslint']
let g:ale_fix_on_save = 1
let g:ale_lint_on_enter = 1
let g:ale_set_highlights = 1
let g:ale_javascript_prettier_options = '--single-quote --no-bracket-spacing --jsx-bracket-same-line --trailing-comma all'
let g:ale_javascript_eslint_executable = 'eslint_d'
highlight clear ALEErrorSign " otherwise uses error bg color (typically red)
highlight clear ALEWarningSign " otherwise uses error bg color (typically red)
let g:ale_sign_error = '❌'
let g:ale_sign_warning = '⚠️'
let g:ale_statusline_format = ['X %d', '? %d', '']
let g:ale_echo_msg_format = '%linter% says %s'
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
nnoremap <leader>an :ALENextWrap<cr>
nnoremap <leader>ap :ALEPreviousWrap<cr>
" ------------------------------------------------
"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
"let g:syntastic_javascript_checkers = ['eslint']
"let g:syntastic_javascript_eslint_exe = 'eslint_d'
"" uses local eslint
""let g:syntastic_javascript_eslint_exe = '$(npm bin)/eslint'
"let g:syntastic_error_symbol = '❌'
"let g:syntastic_style_error_symbol = '⁉️'
"let g:syntastic_warning_symbol = '⚠️'
"let g:syntastic_style_warning_symbol = '💩'
" uses global eslintrc
"let g:syntastic_javascript_eslint_exe = 'eslint --no-eslintrc -c ./.eslintrc'
" let g:syntastic_debug = 1
"highlight link SyntasticErrorSign SignColumn
"highlight link SyntasticWarningSign SignColumn
"highlight link SyntasticStyleErrorSign SignColumn
"highlight link SyntasticStyleWarningSign SignColumn
"map <leader>e :Errors<cr>
"nnoremap <leader>l :lnext<cr>
" eslint_d fix
"nnoremap <leader>f mF:%!eslint_d --stdin --fix-to-stdout<CR>`F
" CtrlP
" ------------------------------------------------
map <leader>gf :CtrlPClearAllCaches<cr> :CtrlP features_wip<cr>
nnoremap <Leader>n :CtrlPMRU<cr>
" ------------------------------------------------
" Markdown preview
" ------------------------------------------------
let vim_markdown_preview_hotkey = '<C-m>'
let vim_markdown_preview_browser='Google Chrome'
let vim_markdown_preview_github = 1
" ------------------------------------------------
" easymotion
" ------------------------------------------------
"map / <Plug>(easymotion-sn)
"omap / <Plug>(easymotion-tn)
"map n <Plug>(easymotion-next)
"map N <Plug>(easymotion-prev)
map <Leader>l <Plug>(easymotion-w)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-b)
let g:EasyMotion_startofline = 0 " keep cursor column when JK motio
" ------------------------------------------------
" NERDCommenter
" ------------------------------------------------
" comment and uncomment with command + /
let g:NERDCustomDelimiter = { 'javascript': { 'left': '// ', 'leftAlt': '/*', 'rightAlt': '*/' }}
nnoremap <D-/> :call NERDComment(0,"toggle")<CR>
vnoremap <D-/> :call NERDComment(0,"toggle")<CR>
inoremap <D-/> :call NERDComment(0,"toggle")<CR>
nnoremap <C-b> :NERDTreeToggle<CR>
nnoremap <Leader>b :NERDTreeFind<CR>
let NERDTreeIgnore = ['\.pyc$']
let NERDTreeWinSize = 40
" ------------------------------------------------
" multi cursor
" ------------------------------------------------
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
" ------------------------------------------------
" Drew's stuff
" ------------------------------------------- "
" line numbers
set number
" tabs
"set tabstop=2
"set shiftwidth=2
"set softtabstop=2
"set expandtab
" fix backspace to work like normal editor
set backspace=indent,eol,start
" ignore in search
let g:ctrlp_max_files = 0
let g:ctrlp_show_hidden = 1
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/node_modules*,*/.meteor/*,*/meteor/packages/*,*.pyc,*/rcov/*,*/dist-*
let g:ctrlsf_ignore_dir = ['bower_components', 'node_modules', 'dist-client', 'dist-server', 'dist-test']
set wildchar=<Tab> wildmenu wildmode=list:longest,full
" better escape
inoremap jj <Esc>
inoremap jk <Esc>
" movement
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" shift-enter to leave insert mode
inoremap <S-CR> <Esc>
" QuickFix settings
"nmap ; <Plug>qf_qf_toggle
" tab width
set expandtab
set smarttab
set tabstop=8 softtabstop=0 shiftwidth=2
command! Tab4 set tabstop=8 softtabstop=0 shiftwidth=4
command! Tab2 set tabstop=8 softtabstop=0 shiftwidth=2
" check file change every 4 seconds ('CursorHold') and reload the buffer upon detecting change
set autoread
au CursorHold * checktime
" BUFFERS
nnoremap <leader>vb :vertical sbuffer
nnoremap <leader>sb :sbuffer
" autocomplete colors
highlight Pmenu guibg=DodgerBlue4
" Ctrl SF find
nmap <Leader>f <Plug>CtrlSFPrompt -ignoredir "javascript"
noremap <Leader>F :CtrlSFToggle<cr>
vmap <Leader>f <Plug>CtrlSFVwordExec
nnoremap <c-]> :CtrlPtjump<cr>
vnoremap <c-]> :CtrlPtjumpVisual<cr>
" Better beginning/end of line movements
nnoremap H ^
vnoremap H ^
nnoremap L $
vnoremap L $
" Respect destination indentation level when pasting
nnoremap <leader>p p
nnoremap <leader>P P
nnoremap p p'[v']=
nnoremap P P'[v']=
vnoremap <D-l> >gv
syntax on
colorscheme monokai
" SETUP
" ------------------------------------------- "
" npm install -g eslint_d
" npm install -g import-js
" clone into ~/.vim/bundle : [email protected]:Galooshi/vim-import-js.git
" npm install -g eslint-cli
" add .tern-config to ~/
" copy .tern-config to project/.tern-project
" cd ~/.vim/bundle/YouCompleteMe && ./install.py --tern-completer
" cd ~/.vim/bundle/tern_for_vim && npm i