- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
Latest commit
542 lines (467 loc) · 15.1 KB
/
Copy pathvimrc
File metadata and controls
542 lines (467 loc) · 15.1 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
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
"
" Isam | http://github.com/lsd/vim | 07/23/2016
"
" Written primarily on MacVim but should be agnostic
" Currently experimenting heavily with VimR <vimr.org>
" (auto open Markdown preview on BufRead currently off)
"
" Notice: Before using, read Caveats below
"
" Help: <Leader>h and <Leader>hh in INSERT mode. <ESC>\h<CR> opens cheatsheet
" Internalize these keymaps:
" \cu uncomment
" \ci comment lines individually //..
" \cm comment block /* */..
" \cs comment pretty (?)
" \cl or \cb comments aligned to left/BOL
" \cA add comment at end of line
" \c<space> toggle comment state
"
" Note: Everything else was moved to EXTRA.md
"
" Upcoming:
" Get YouCompleteMe and Unite setup
" Significantly clean up vimrc
" Ensure it works out of the box on Linux
" Create simple optional setup script
function!SettingsGeneral()
setmat=5
setnolist
setmouse=a
setvbt_vb=
sett_Co=256
setgdefault
setshowmode
setincsearch
setcursorline
setcopyindent
settextwidth=0
setwrapmargin=0
sethistory=2000
setcmdheight=2
setscrolloff=4
setshowbreak=↪
sethidden
highlightFoldColumn guibg=grey guifg=blue
highlightFolded ctermfg=11 ctermbg=8 guibg=#444444 guifg=#cccccc
highlightSpecialKey guifg=#073642 guibg=NONE ctermbg=NONE ctermfg=241
if$VIM_NOBACKUPS=="true"
echo"\nNOTICE: Backups Disabled. See VIM_NOBACKUPS in ~/.vimrc\n"
setnobackup
setnowritebackup
else
setbackup
setbackupdir=~/.vim/backups
setdirectory=~/.vim/tmp
endif
endfunction
function!SettingsDeveloper()
setnocompatible
settimeoutlen=265
setttimeoutlen=100
setsmartindent
setshowmatch
setsmartcase
setexpandtab
setfillchars=stl:~,stlnc:-,vert:\|,fold:-,diff:-
setnumber
setnowrap
setfoldlevel=1
setnofoldenable
setfoldnestmax=6
setfoldminlines=4
setvirtualedit=all
setformatoptions+=1
setfoldmethod=syntax
setcomplete-=kcomplete+=k
setbackspace=indent,eol,start
settabstop=2shiftwidth=2softtabstop=2
settags=./tags,tags
"set list listchars=tab:\I>trail:·
setverbose=0
endfunction
function!PluginManagement()
ifhas('vim_starting')
if &compatible
setnocompatible
endif
setruntimepath+=~/.vim/bundle/neobundle.vim/
endif
filetypeoff
callneobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
""""""""""""""""""""""""""""""""""""""""""""
" 2015 REFACTOR! XXX! TODO!
" --- Iterate through bundles from conf file (Bundlefile, Vimscript,
" --- see http://vimawesome.com/plugin/endwise-vim
""""""""""""""""""""""""""""""""""""""""""""
NeoBundle 'Shougo/vimproc', { 'build' : { 'mac' : 'make -f make_mac.mak' }, }
NeoBundle 'kien/ctrlp.vim.git'
"
"http://github.com/reedes/vim-colors-pencil
"http://github.com/reedes/vim-lexical
"http://github.com/reedes/vim-wordy
"http://github.com/reedes/vim-pencil
"
" http://github.com/reedes/vim-thematic
" NeoBundle 'reedes/vim-thematic'
"
NeoBundle 'tyru/open-browser.vim'
" NeoBundle 'digitaltoad/vim-jade'
"NeoBundle 'mikewest/vimroom'
" NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'thinca/vim-ref'
NeoBundle 'kshenoy/vim-signature'
NeoBundle 'jeetsukumaran/vim-buffergator'
NeoBundle 'altercation/vim-colors-solarized'
NeoBundle 'vim-scripts/vim-auto-save'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'vim-scripts/mru.vim'
NeoBundle 'scrooloose/nerdcommenter'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'jistr/vim-nerdtree-tabs'
NeoBundle 'vim-ruby/vim-ruby'
NeoBundle 'evanmiller/nginx-vim-syntax'
NeoBundle 'https://github.com/bling/vim-airline'
NeoBundle 'tpope/vim-surround'
NeoBundle 'tpope/vim-characterize'
NeoBundle 'mileszs/ack.vim'
NeoBundle 'juvenn/mustache.vim'
NeoBundle 'vim-scripts/showMarks'
"NeoBundle 'vim-scripts/applescript.vim'
NeoBundle 'vim-scripts/Txtfmt-The-Vim-Highlighter'
NeoBundle 'nathanaelkane/vim-indent-guides'
NeoBundle 'tilljoel/vim-automatic-ctags'
NeoBundle 'majutsushi/tagbar'
NeoBundle 'tpope/vim-unimpaired'
NeoBundle 'tpope/vim-abolish'
NeoBundle 'maxbrunsfeld/vim-emacs-bindings'
" NeoBundle 'tpope/vim-surround'
" NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-bundler'
NeoBundle 'sophacles/vim-processing'
NeoBundle 'L9'
NeoBundle 'plasticboy/vim-markdown'
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'mxw/vim-jsx'
NeoBundle 'justinj/vim-react-snippets'
NeoBundle 'tomtom/tlib_vim'
NeoBundle 'marcweber/vim-addon-mw-utils'
NeoBundle 'editorconfig/editorconfig-vim'
NeoBundle 'mattn/emmet-vim'
NeoBundle 'ervandew/supertab'
NeoBundle 'nathanaelkane/vim-indent-guides'
NeoBundle 'marijnh/tern_for_vim'
NeoBundle 'Valloric/YouCompleteMe'
"NeoBundle 'Shougo/unite.vim'
"NeoBundle 'git://github.com/tpope/vim-eunuch.git'
"NeoBundle 'garbas/vim-snipmate'
"NeoBundle 'eiginn/netrw'
callneobundle#end()
filetypepluginindenton
setomnifunc=syntaxcomplete#Complete
NeoBundleCheck
endfunction
function!SetAutoCommands()
" Empty autocommands to avoid duplicate autocmd on :source %
autocmd!
" Autosave on blur (ignore warnings)
" au FocusLost * silent! wa
" Trim trailing whitespace
" Change to current file's working dir
auBufEnter*silent!lcd%:p:h
" auto spellcheck git commits
auFileTypegitcommitsetlocalspell
" Universal Go style (gofmt) default is real tabs ts 8
auBufRead,BufNewFile*.gosetlocalnolistnoexpandtabtabstop=8shiftwidth=8softtabstop=8
" cat tags/README.md to learn how to generate the tag files.
"au BufRead,BufNewFile *.rb set tags+=~/.vim/tags/ruby2.0.0.tags
"au BufRead,BufNewFile *.py set tags+=~/.vim/tags/python3.3.tags
auBufRead,BufNewFilecomposer.lock,*.as,*.jsonsetft=javascript
auBufRead,BufNewFile*.pdesetfiletype=arduino
auBufRead,BufNewFile*.inosetfiletype=arduino
" PHP (PSR-2 compliance: EOF needs newline, indent is 4 space tab, on newline)
auBufRead,BufNewFile*.php,*.phps,*.phtmlsettabstop=4shiftwidth=4softtabstop=4
" au BufRead,BufNewFile *.php,*.phps set tags+=~/.vim/tags/php5.6.10.tags
auBufRead,BufNewFile*.php,*.phps,*.phtmllet php_minlines=500
auBufRead,BufNewFile*.twigsetft=php
" au BufRead,BufNewFile *.md call InitMarkdown()
" au BufRead,BufNewFile *.mkd call InitMarkdown()
" au BufRead,BufNewFile *.markdown call InitMarkdown()
" turn off for now, as vimR has this feature
" call OnWriteOverride()
endfunction
" If opening a Markdown file, set filetype to 'markdown' for diff extensions
" and open live preview of the buffer using a a shell script 'marko' (open -n -a /Applications/Marko.app "$@")
"function! InitMarkdown()
" set ft=markdown
" :!marko %
"endfunction
function!SetFnKeyMaps()
setpastetoggle=<F2>
nnoremap<F2>:set invpaste paste?<CR>
nnoremap<F3>:MRU<CR>
nnoremap<F4>:buffers<CR>:buffer<Space>
nnoremap<F5>:set wrap!<CR>
nnoremap<F6>:TagbarToggle<CR>
nnoremap<F7>:e ~/.shell_aliases<CR>
" call togglebg#map("<F8>")
" nnoremap <F9> :GundoToggle<CR>
nnoremap<F10>:NeoBundleInstall<CR>
nnoremap<F11><ESC>:set hlsearch!<CR>/\s<CR><ESC>
nnoremap<F12>:so ~/.vimrc<CR>:echo "reloaded vimrc\n"<CR>
" Drag Current Line Vertically
nnoremap<C-j>:m+<CR>
nnoremap<C-k>:m-2<CR>
inoremap<C-j><Esc>:m+<CR>
inoremap<C-k><Esc>:m-2<CR>
vnoremap<C-j>:m'>+<CR>gv
" TODO choose proper comment based on filetype. allow block comments,... NERD Commenter?
map<C-c>I# <Esc>$<CR><Esc>
nnoremapq:echo 'q recording disabled'<CR>
nnoremapqq:echo 'qq recording disabled. Did you mean ``?'<CR>
endfunction
function!DisplayNotice()
endfunction
function!SetLeaderMaps()
" unmap \t
nnoremap\ts:set spell!<CR>
"nnoremap \\ts :set spell!<CR>
" Change all [TAB] to 2 [SPACE]s
" nnoremap \tc :%s: : :<CR><ESC>
" Change ALL whitespace to single [SPACE]
nnoremap\tcc:%s:\s\+: :<CR><ESC>
nnoremap\tl:set hlsearch!<CR><ESC>
nnoremap\rf:call RunMe()<CR>
nnoremap\lf:call LintMe()<CR>
" nnoremap \tg :TagbarOpenAutoClose<CR><ESC>
nnoremap\tm:ShowMarksToggle<CR>
cnoremap\vs:VimShellPop<CR>
" now use alt+cmd+P for preview
nnoremap\omd:!marko %<CR>
nnoremap\ov:!mvim %<CR>
nnoremap\of:!open -R %<CR>
nnoremap\orc:e ~/.vimrc<CR>:redraw<CR>:echo "\n* Use F12 to source .vimrc when done\n"<CR>
" noremap \em :Emodel
" noremap \ev :Eview
" noremap \ec :Econtroller
" noremap \es :Espec
" noremap \ej :Ejavascript
" noremap \et :Etask
endfunction
function!MappingHelper()
letg:FnKeyMappings="\n
\ F1: Toggle Left Side Bar\n
\ F2: Toggle Paste Mode\n
\ F3: Display Recent Files\n
\ F4: Display and Jump to Buffer\n
\ F5: Toggle Word Wrap\n
\ F6: Toggle Right Side Tag Bar\n
\ F7: Tidy current file\n
\ F8: Toggle Dark/Light BG (solarized plugin)\n
\ F9: Toggle Gundo Undo Tree\n
\ F10: exec NeoBundInstall\n
\ F11: Show all whitespace\n
\ F12: SourceVimRC\n"
"\ <Leader>t : unmapped - Delay to help \* \\* commands toggle easier\n
letg:leaderMappings="\nList of Leader Key Mappings (\\)\n
\ --------------------------\n
\ <Leader>ts : Toggle spellcheck\n
\ <Leader>tcw : Fix all ^I, ^M chars inbuffer\n
\ <Leader>tcc: Change all whitespace to1 space\n
\ <Leader>tl : Toggle search Highlight\n
\ <Leader>tg : Toggle Tagbar Autoclose\n
\ <Leader>tm : Toggle Show Line Marks\n
\ <Leader>omd : Open current buffer with Marko.app. File must be .md\n\n
\ <Leader>ov : Open current bufferin mvim\n\n
\ <Leader>of : Reveal current filein Finder \n\n
\ <Leader>orc : Open .vimrc in current buffer\n\n
\ <Leader>h : List Fn key maps\n\n
\ <Leader>hh : List Leader key maps\n\n"
" \ Plugin rails.vim\n
" \ --------------------------\n
" \ <Leader>em : Emodel (rails.vim)\n
" \ <Leader>ev : Eview\n
" \ <Leader>ec : Econtroller\n
" \ <Leader>es : Espec\n
" \ <Leader>ej : Ejavascript\n
" \ <Leader>et : Etask\n\n"
noremap\h:echo g:FnKeyMappings<CR>
noremap\hh:echo g:leaderMappings<CR>
endfunction!
function!LittlePinPrick()
" INJECTIONS ([t]timeoutlen LOW, so hit keys fast :h map-overview)
" TODO OPTIMIZE XXX should only be enabled per filetype
inoremap{{}<LEFT>
inoremap{}{}
inoremap{{{
inoremap{<CR>{<CR>}<ESC>O<Space><Space>
inoremap<silent>}}<ESC>
inoremap<?<?php <ESC><CR><CR>i
inoremap<??<?php echo ?><LEFT><LEFT><LEFT>
inoremap<?!<?php die('<pre>' . var_dump(Array()) . '</pre>') ?><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>
inoremap<xml<?xml version="1.0" encoding="UTF-8" ?><ESC><CR>i
inoremap<%<% %><LEFT><LEFT><LEFT>
inoremap<%%<%= %><LEFT><LEFT><LEFT>
inoremapcclconsole.log();<LEFT><LEFT>
inoremapcc'console.log('');<LEFT><LEFT><LEFT>
inoremapccdconsole.debug();<LEFT><LEFT>
inoremapdvddie(var_dump(array(__FILE__.':'.__LINE__, )));<LEFT><LEFT><LEFT><LEFT>
inoremapbrpbinding.remote_pry
inoremap<C-CR><SPACE><SPACE><CR>
endfunction
function!RunMe()
if (&ft=='php')
!php %
endif
if (&ft=='javascript')
!node %
endif
endfunction
function!LintMe()
if (&ft=='rb')
!ruby-c%<CR>
elseif (&ft=='js'|| &ft=='javascript'|| &ft=='json')
!gjslint %
elseif (&ft=='html'|| &ft=='htm')
!echo-e"\t\tneed html `&ft` lint support in ~/.vimrc"
elseif (&ft=='php')
!php -l%
elseif (&ft=='haml')
!haml -c%
elseif (&ft=='vim')
echo"pending: implement vimL lint"
else
echo"No known lint available for this filetype. see ':set ft'"
endif
endfunction
function!SettingsPlugins()
nnoremap<silent><C-t>:CtrlP<CR>
letg:netrw_http_cmd="open"
" Syntastic
setstatusline+=%#warningmsg#
setstatusline+=%{SyntasticStatuslineFlag()}}
setstatusline+=%*
letg:syntastic_always_populate_loc_list=1
letg:syntastic_auto_loc_list=1
letg:syntastic_check_on_open=1
letg:syntastic_check_on_wq=0
" Move bwt buffers
nnoremap<C-h>:bp<CR>
inoremap<C-h><ESC>:bp<CR>
nnoremap<C-l>:bn<CR>
inoremap<C-l><ESC>:bn<CR>
"nnoremap <silent> <C-k> :bn<CR>
"nnoremap <silent> <C-j> :bp<CR>
" Move Lineelection UP/DOWN
nnoremap<C-k>:m+<CR>
inoremap<C-k><Esc>:m+<CR>
"vnoremap <C-k> :m'>+<CR>gv
" DOWN
nnoremap<C-j>:m-2<CR>
inoremap<C-j><Esc>:m-2<CR>
"vnoremap <C-j> :m'<-2<CR>gv
" PLUGIN SETTINGS
" vim-auto-save sets uptime to 200.
" It autosaves in NORMAL mode only
letg:auto_save=1
letg:auto_save_in_insert_mode=0
" vim-processing
letg:processing_fold=1
letg:processing_doc_style='web'
letg:processing_doc_path='/tmp/p'
" by default, JSX highlighting/indenting is only files .jsx. This adds
" it to .js files
letg:jsx_ext_required=0
" open+launch focus on new buffer in MacVim not vimR
ifhas("gui_vimr")
letg:nerdtree_tabs_open_on_gui_startup=0
letg:nerdtree_tabs_smart_startup_focus=0
endif
ifhas("gui_macvim")
letg:nerdtree_tabs_open_on_gui_startup=1
letg:nerdtree_tabs_smart_startup_focus=2
endif
letg:nerdtree_tabs_open_on_console_startup=0
letg:MRU_Max_Entries=30
letg:MRU_Max_Menu_Entries=20
letg:MRU_Window_Open_Always=1
letg:ScreenImpl='Tmux'
setwildignore+=*.o,*.obj,.git,.svn,vendor/rails/**,tmp/**,publicystem/**
letg:CommandTMaxCachedDirectories=10
letg:CommandTMaxHeight=20
letg:showmarks_enable=0
letg:vim_markdown_folding_disabled=0
"let g:Powerline_symbols = 'fancy'
letg:airline_powerline_fonts=1
setlaststatus=2
"let g:tagbar_width = 20
"let g:tagbar_phpctags_memory_limit = '512MB'
letg:Tlist_Exit_OnlyWindow=1
letg:Tlist_Show_One_File=1
letg:Tlist_Enable_Fold_Column=1
letg:Tlist_Process_File_Always=1
letg:Tlist_Show_Menu=1
letg:Tlist_Sort_Type="order"
letg:Tlist_Use_Right_Window=1
letg:Tlist_Compact_Format=1
setbg=dark
colors darkburn
" if has("gui_running")
" colorscheme solarized
" set bg=light
" else
" colorscheme peachpuff
" endif
nnoremap<F1>:NERDTreeToggle<CR>
ifhas("gui_running")
setlines=65
setcolumns=160
" autocmd VimEnter * call LeftSidebarToggle()
" nnoremap <F1> :call LeftSidebarToggle()<CR>
map<Leader>n :NERDTreeCWD<CR>
map<Leader>] :bn<CR>
map<Leader>[ :bp<CR>
map<Leader>} :blast<CR>
map<Leader>{ :bfirst<CR>
" Remove Tool+scroll bars
setguioptions-=T
setguioptions-=l
setguioptions-=L
setguioptions-=r
setguioptions-=R
setguifont=Sauce\ Code\ Powerline:h14
endif
endfunction
function!OnWriteOverride()
" autocmd!
auFocusLost* :%s/\s\+$//ge
auFocusLost* :setff=unix
endfunction
function!InitializeVim()
callPluginManagement()
callSettingsGeneral()
callSettingsDeveloper()
" CAVEAT: This removes all current autocmds
callSettingsPlugins()
callSetAutoCommands()
callSetFnKeyMaps()
callSetLeaderMaps()
callMappingHelper()
callLittlePinPrick()
syntaxon
endfunction
callInitializeVim()
"function! PrintHighlightColors(msg)
" let Highlight_Colors_2 = [
" \ "WarningMsg",
" \ "Question",
" \ "Cursor",
" \ "CursorIM"]
" for color in Highlight_Colors_2
" echohl color
" echom color a:msg
" echohl None
" endfor
"endfunction