/
vimrc
776 lines (701 loc) · 24.5 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
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
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
" Super standard stuff
set nocompatible " Forget vi.
filetype off
" Shut up!
set visualbell
" Set up Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
" Plugins
" Window manager
Bundle 'spolu/dwm.vim'
" Split management
Bundle 'roman/golden-ratio'
Bundle 'vim-scripts/bufkill.vim'
" Undo management
Bundle 'sjl/gundo.vim'
" VCS
Bundle 'Lawrencium'
Bundle 'tpope/vim-fugitive'
" Terminal/iTerm integration (Macvim)
Bundle 'gcmt/tube.vim'
" Tmux integration
Bundle 'benmills/vimux'
" Make FocusLost work in vim -> tmux -> iTerm2
Bundle 'sjl/vitality.vim'
" Move between Vim and tmux splits seamlessly
Bundle 'christoomey/vim-tmux-navigator'
" Align stuff
Bundle 'godlygeek/tabular'
" Repeat plugin commands
Bundle 'tpope/vim-repeat'
" Add comments faster
Bundle 'tpope/vim-commentary'
" Search / Replace preview
Bundle 'osyo-manga/vim-over'
" vimproc
Bundle 'Shougo/vimproc.vim'
" outline
Bundle 'Shougo/unite-outline'
" vimshell
Bundle 'Shougo/vimshell.vim'
" vimfiler
Bundle 'Shougo/vimfiler.vim'
" Unite.vim
Bundle 'Shougo/unite.vim'
" Unite-ssh
Bundle 'Shougo/unite-ssh'
" Unite-mark
Bundle 'tacroe/unite-mark'
" Unite-session
Bundle 'tungd/unite-session'
Bundle 'xolox/vim-misc'
Bundle 'xolox/vim-session'
" Bunch of color schemes
Bundle 'Colour-Sampler-Pack'
Bundle 'junegunn/seoul256.vim'
" Status bar
Bundle 'bling/vim-airline'
" Bindings for ack (using ag in the back)
Bundle 'mileszs/ack.vim'
" Syntax checker
Bundle 'scrooloose/syntastic'
" File explorer
Bundle 'scrooloose/nerdtree'
" Zencoding for HTML
Bundle 'mattn/emmet-vim'
" Tagbar / Autocomplete / Go to symbol
Bundle 'majutsushi/tagbar'
Bundle 'sequenceGeek/MRU-Function'
" Bundle 'Valloric/YouCompleteMe'
Bundle 'Shougo/neocomplete.vim'
Bundle 'travisjeffery/vim-gotosymbol'
" Go to character
Bundle 'svermeulen/vim-extended-ft'
Bundle 'justinmk/vim-sneak'
" Change surrounding text
Bundle 'tpope/vim-surround'
" Snippets
Bundle 'SirVer/ultisnips'
Bundle 'Shougo/neosnippet.vim'
Bundle 'honza/vim-snippets'
" Adds closing tags automatically
Bundle 'Raimondi/delimitMate'
" Allows selection of multiple occurances of a patterns for faster changes
Bundle 'terryma/vim-multiple-cursors'
" Javascript intelligence
Bundle 'marijnh/tern_for_vim'
" Python tools
Bundle 'davidhalter/jedi-vim'
" Python linters
Bundle 'nvie/vim-flake8'
" Better syntax
Bundle 'plasticboy/vim-markdown'
Bundle 'jelera/vim-javascript-syntax'
Bundle 'django.vim'
Bundle 'mustache/vim-mode'
" Buffer movement
" Look for stuff here
set path=.,**
" Status bar config
" Powerline setup.
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
set laststatus=2 " Always display status line in all windows
set noshowmode " Don't show the current mode at the bottom (since powerline does it)
" Vim-airline setup
let g:airline_powerline_fonts = 1
let g:airline_theme='powerlineish'
let g:airline#extensions#tabline#enabled = 1
" General settings
set t_Co=256
syntax enable
syntax on
filetype on
filetype plugin indent on
" Keep the buffer around when switching between buffers
set hidden
" Show line numbers
" set relativenumber
set number
" Basic editing stuff
" set wrap " Wrap lines
" set textwidth=80 " Cut down anything > 80 chars
set nowrap
set virtualedit=block
set tabstop=4 " Set tab as 4 spaces
set shiftwidth=4 " No of spaces for autoindent
set expandtab " Expand tabs to spaces
set backspace=indent,eol,start " Allow backspace for everything in insert mode
set autoindent " Auto indent everything
set copyindent " Copy previous indentation on autoindenting
set shiftround " Use multiple of shiftwidth when indenting with stuff like <
set linespace=1 " Sets linespace (px between lines)
set wildmenu " Better command-line completion
set wildmode=full " Auto-complete menu
set nofoldenable " I don't remember asking you to fold a goddamn thing
" Make cursor move as expected with wrapped lines
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
" Automatically save files when i switch buffers
set autowrite
" Enable mouse in normal mode
set mouse=n
" Show spaces and tabs - Doesn't seem to be working for existing code
" set listchars=tab:>~,nbsp:.,trail:.
" set list
set shortmess=atI " Don't show the Vim intro message
set autoread " Auto reload files changed outside
" Folder specific vimrc
set exrc " enable per directory vimrc files
set secure " disable unsafe commands in those files
" Timeout settings
set ttimeout
set ttimeoutlen=100
set notimeout
" Testing some tweaks to make Vim faster
" let loaded_matchparen=1 " Don't load matchit.vim (paren/bracket matching)
" set noshowmatch " Don't match parentheses/brackets
" set nocursorline " Don't paint cursor line
" set nocursorcolumn " Don't paint cursor column
" set lazyredraw " Wait to redraw
" set scrolljump=8 " Scroll 8 lines at a time at bottom/top
let html_no_rendering=1 " Don't render italic, bold, links in HTML
" File ignores
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem,.hg
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Ignore rails temporary asset caches
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/*
" Ignore node modules
set wildignore+=node_modules/*
" Disable temp and backup files
set wildignore+=*.swp,*~,._*
" Disable merge related files
set wildignore+=*.orig,*.rej
" Don't backup files.
set nobackup
set noswapfile
" Undo across sessions
set undodir=~/.vim-undo
set undofile
set undolevels=1000 "max number of changes that can be undone
set undoreload=10000 "max number lines to save for undo on buffer reload
" Search
set showmatch " Show matching parenthesis
set ignorecase " Ignore case when searching
set smartcase " ignore case if search pattern is lowercase, case sensitive otherwise
set hlsearch " Hightlight search terms
" <leader>ll to clear highlighted text
noremap scls :set nohlsearch<CR>
set incsearch " Show search matches as you type
" History
set history=1000 " More history!
set undolevels=1000 " More undo levels!
" Window settings
set title " Show title
set ruler " Display cursor position in lower right corner
set showcmd " Display the command in lower right corner
" Split window to the right
set splitright
" Make cursor to always stay in the middle of the window
set scrolloff=999
" Quickfix navigation
nnoremap <leader>cc :cc<CR>
nnoremap <leader>cn :cn<CR>
nnoremap <leader>cp :cp<CR>
" Navigation across splits
nnoremap <C-w><C-h> <C-h>
nnoremap <C-w><C-j> <C-j>
nnoremap <C-w><C-k> <C-k>
nnoremap <C-w><C-l> <C-l>
" Copy/Paste settings
set clipboard=unnamed " Use the OS clipboard by default
set pastetoggle=<leader>pp
nnoremap Y bv$hd
nnoremap <silent> <Tab> :bn<CR>
nnoremap <silent> <S-Tab> :bp<CR>
" Use , instead of \ for leader
let mapleader=","
" Annoyances
" Set leader to , instead of \
command! -bang -range=% -complete=file -nargs=* W <line1>,<line2>write<bang> <args>
command! -bang Q quit<bang>
nnoremap <leader>c :bp\|bd #<CR>
function! MkDirCurrent()
let current_path = expand("%:h")
call mkdir(current_path, "p")
endfunction
command! MkDirCurrent call MkDirCurrent()
" Trim trailing spaces
function! TrimTrailingWhitespace()
execute "normal mz"
%s/\s\+$//ge
execute"normal `z"
endfunction
" Auto commands
if !exists("autocommands_loaded")
let autocommands_loaded = 1
" Automatically reload .vimrc on save
autocmd BufWritePost .vimrc source %
" Save when you lose focus (don't warn about unsaved files)
autocmd FocusLost * silent! wa
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
" JSON formatting
autocmd FileType json nnoremap <leader>js :%!python -m json.tool<CR>
" Fix html indent
autocmd FileType html setlocal indentkeys-=*<Return>
" Trim trialing whitespace always
" autocmd BufWrite * :call TrimTrailingWhitespace()
" Jump to the last position when reopening a file
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" vimrc shortcut and fold expression
nmap <silent> <leader>ev :e $MYVIMRC<CR>
autocmd FileType vim call s:vimrc_settings()
function! s:vimrc_settings()
setlocal foldenable
setlocal foldmethod=expr
setlocal foldexpr=GetVimScriptFold(v:lnum)
function! GetVimScriptFold(line_number)
let current_line = getline(a:line_number)
if current_line =~? '\v^\"'
return '1'
elseif current_line =~? '\v^\s*$'
return '0'
else
return 1
endif
endfunction
endfunction
" Folding for HTML
" TODO: Make this togglable
" Vatzf = Select around tag and fold
autocmd FileType html call s:HtmlSettings()
autocmd FileType htmldjango call s:HtmlSettings()
function! s:HtmlSettings()
nnoremap <space> Vatzf
nnoremap <leader>re :silent !chrome-reload-current<CR>:redraw!<CR>
endfunction
" indent and keep selection so that I can do it again
vnoremap < <gv
vnoremap > >gv
" Map <leader>o to go to the previous line (since O is too hard to type)
inoremap <leader>o <ESC>O
nnoremap <leader>o <ESC>O
" Map ; to :
nnoremap ; :
" Map jk/kj to ESC key in insert mode
inoremap jk <ESC>
inoremap kj <ESC>
" Map <leader>e to ESC in insert and visual mode
inoremap <leader>e <ESC>
vnoremap <leader>e <ESC>
" Emacs key-binding in vim!
inoremap <C-a> <C-o>0
inoremap <C-e> <C-o>$
nnoremap <C-e> $
nnoremap <C-a> 0
" Make vim look pretty
colorscheme desert
set background=dark
" Convinent save/delete
" Using noremap for the mappings below screws up insert mode
" Map <leader>s to save file
inoremap <leader>s <ESC> :w <CR>
nnoremap <leader>s <ESC> :w <CR>
vnoremap <leader>s <ESC> :w <CR>
" Map <leader>d to delete the buffer
inoremap <leader>d <ESC> :BD <CR>
nnoremap <leader>d <ESC> :BD <CR>
vnoremap <leader>d <ESC> :BD <CR>
" cnoremap bd BD
" Bubble text
" Bubble single lines
"nnoremap <C-k> ddkP
nnoremap <C-j> ddp
" Bubble multiple lines
vnoremap <C-k> xkP`[V`]
vnoremap <C-j> xp`[V`]
" Shortcuts for easier editing
inoremap <leader>u <ESC>u
inoremap <leader>w <ESC>ciw
" Better shortcuts for incrementing/decrementing numbers
nnoremap + <C-a>
nnoremap - <C-x>
" Redraw screen
nnoremap <leader>C :redraw!<CR>
" Command mappings
cnoremap %% <C-R>=expand('%:h').'/'<cr>
" Operator mappings
onoremap p i(
" Save a file as root (,W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" markdown helpers
nnoremap <leader>h1 yyp^v$r=
nnoremap <leader>h2 yyp^v$r-
" Remote file editing goodness
if !exists("g:remote_edit_session_host")
let g:remote_edit_session_host = ''
endif
function! RemoteEditOpen(host)
let g:remote_edit_session_host = a:host
echo 'Opening ssh session to ' . a:host
silent execute '!ssh -f -N ' . a:host | redraw!
echo 'Opened ssh session to ' . a:host
echo 'Do not forget to call RemoteEditEnd once you are done'
endfunction
function! RemoteEditClose()
silent execute '!ps -ef | grep ' . g:remote_edit_session_host . ' | grep -v grep | awk ' . "'{print $2'}" .' | xargs kill -9' | redraw!
echo 'Closed connection to ' . g:remote_edit_session_host
let g:remote_edit_session_host = ''
endfunction
command! -nargs=1 RemoteEdit call RemoteEditOpen("<args>")
command! RemoteEditEnd call RemoteEditClose()
" Vimux
nnoremap <leader>r :VimuxPromptCommand <CR>
nnoremap <leader>r. :VimuxRunLastCommand <CR>
" Set shortcut for NERDTree
nnoremap <leader>nt :NERDTreeToggle <CR>
vnoremap <leader>nt :NERDTreeToggle <CR>
" Gundo mapping
nnoremap <leader>u :GundoToggle <CR>
" Tabular mappings
let mapleader=','
" Tabularize
nnoremap <Leader>a= :Tabularize /=<CR>
vnoremap <Leader>a= :Tabularize /=<CR>
nnoremap <Leader>a: :Tabularize /:\zs<CR>
vnoremap <Leader>a: :Tabularize /:\zs<CR>
" Disable syntastic plugin for html files since it complains about templates
" in script tags
let g:syntastic_enable_highlighting = 0
let g:syntastic_quiet_warnings=1
let g:syntastic_mode_map={ 'mode': 'passive',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['js', 'html'] }
" Replaced by Unite.vim - Leaving it here in case I come back
" CtrlP settings
" let g:ctrlp_map = '<leader>f'
" set wildignore+=*.pyc,*.orig,*.rej,*.git/*,*.hg/*
" Load local matchit.vim if not loaded
" Enables % to match open/close parens, blocks, etc
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
" YouCompleteMe completion preview
let g:ycm_add_preview_to_completeopt = 0
" Go To definition
nnoremap <C-d> :YcmCompleter GoToDefinitionElseDeclaration<CR>
" nnoremap <C-d>c :YcmCompleter GoToDeclaration<CR>
" nnoremap <C-d>f :YcmCompleter GoToDefinition<CR>
" Tell YouCompleteMe to take identifiers from tags
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_semantic_triggers = {
\ 'c' : ['->', '.'],
\ 'objc' : ['->', '.'],
\ 'ocaml' : ['.', '#'],
\ 'cpp,objcpp' : ['->', '.', '::'],
\ 'perl' : ['->'],
\ 'php' : ['->', '::'],
\ 'cs,java,vim,python,javascript,perl6,scala,vb,elixir,go' : ['.'],
\ 'ruby' : ['.', '::'],
\ 'lua' : ['.', ':'],
\ 'erlang' : [':'],
\ }
" Making Ultisnips work with Tab
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
function! g:UltiSnips_Complete()
call UltiSnips_ExpandSnippet()
if g:ulti_expand_res == 0
if pumvisible()
return "\<C-n>"
else
call UltiSnips_JumpForwards()
if g:ulti_jump_forwards_res == 0
return "\<TAB>"
endif
endif
endif
return ""
endfunction
autocmd BufEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
" Mapping for GotoSymbol
nnoremap <leader>t :GotoSymbol
" tern for javascript config
let g:tern_map_keys=1
set completeopt-=preview " Don't open the goddamn scratch buffer everytime
" Tell ack.vim to use ag instead.
let g:ackprg = 'ag --nogroup --nocolor --column'
" Vim python-mode
autocmd FileType python call s:python_mode_settings()
function! s:python_mode_settings()
setlocal wrap
command! PyLint call Flake8()
cmap pylint PyLint
noremap <leader>br :call InsertLine()<CR>
function! InsertLine()
let trace = expand("import ipdb; ipdb.set_trace()")
execute "normal o".trace
endfunction
endfunction
" Ignore some these PEP8 errors
" let g:flake8_ignore="E221,E222,E302"
let g:syntastic_python_checkers=['flake8']
let g:syntastic_python_checker_args='--ignore=E221,E222,E302'
let g:syntastic_python_flake8_post_args='--ignore=E221,E222,E302'
" E221 - multiple spaces before operator
" E222 - multiple spaces after operator
" E302 expected 2 blank lines, found 0
" DWM.vim
nnoremap <silent> <C-w> :call DWM_New()<CR>
nnoremap <silent> <leader>q :exec DWM_Close()<CR>
" The two commands below screw up arrow keys in normal mode
" nnoremap <silent> <C-]> :call DWM_GrowMaster()<CR>
" nnoremap <silent> <C-[> :call DWM_ShrinkMaster()<CR>
" nnoremap <silent> <Tab> :call DWM_Rotate(0)<CR>
" nnoremap <silent> <S-Tab> :call DWM_Rotate(1)<CR>
nnoremap <leader>w :wincmd w<CR>
nnoremap <leader>W :wincmd W<CR>
let g:dwm_master_pane_width=120
" vimfiler
let g:vimfiler_as_default_explorer = 1
" jedi-vim config
autocmd FileType python setlocal omnifunc=jedi#completions
let g:jedi#auto_vim_configuration = 0
"let g:neocomplete#force_omni_input_patterns.python = '[^. \t]\.\w*'
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#use_splits_not_buffers = "left"
let g:jedi#goto_assignments_command = "<C-g>"
let g:jedi#goto_definitions_command = "<C-d>"
let g:jedi#documentation_command = "K"
let g:jedi#rename_command = "<leader>re"
let g:jedi#usages_command = "<leader>n"
let g:jedi#show_call_signatures = "1"
let g:jedi#popup_select_first = 1
let g:jedi#popup_on_dot = 0
" Trying out neocomplete.
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#auto_completion_start_length = 1
let g:neocomplete#sources#buffer#cache_limit_size = 50000
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 1
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#force_omni_input_patterns.javascript = '[^. \t]\.\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#smart_close_popup() . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>"
" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left> neocomplete#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
"inoremap <expr><Up> neocomplete#close_popup() . "\<Up>"
"inoremap <expr><Down> neocomplete#close_popup() . "\<Down>"
" Or set this.
" let g:neocomplete#enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplete#enable_insert_char_pre = 1
" AutoComplPop like behavior.
let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
" Neosnippet config
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
let g:neosnippet#enable_snipmate_compatibility = 1
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" let g:unite_enable_start_insert = 1
" " Yank history
" let g:unite_source_history_yank_enable = 1
" " Cache max of 500 files
" let g:unite_source_rec_max_cache_files=500
" " Use ag for search.
" let g:unite_source_grep_command="ag"
" let g:unite_source_grep_default_opts="-i --nocolor --nogroup"
" " Fancy prompts
" let g:unite_prompt = '» '
" " Fuzzy search ALL THE THINGS!
" call unite#filters#matcher_default#use(['matcher_fuzzy'])
" " Goodbye CtrlP
" nnoremap <leader>f :Unite -no-split -buffer-name=files -start-insert -auto-resize buffer file file_rec/async<cr>
" nnoremap <leader>vf :Unite -vertical -buffer-name=files -start-insert -auto-preview file_rec/async<cr>
" " Buffer list
" nnoremap <leader>b :Unite -no-split -buffer-name=buffer -start-insert buffer<cr>
" nnoremap <leader>vb :Unite -vertical -buffer-name=buffer -start-insert buffer<cr>
" " Tags!
" nnoremap <leader>p :Unite -no-split -buffer-name=outline -start-insert outline<cr>
" " Yank history!
" nnoremap <leader>y :Unite -no-split -buffer-name=yank history/yank<cr>
" " Go to directory
" nnoremap <leader>cd :<C-u>Unite -no-split directory_mru directory_rec:. -start-insert -buffer-name=cd -default-action=cd<CR>
" nnoremap E :UniteWithBufferDir -buffer-name=files buffer file<CR>
" " Super search
" nnoremap <leader>g :Unite -buffer-name=search -start-insert -auto-preview grep:.<cr>
" nnoremap <leader>l /
" nnoremap / :Unite -buffer-name=search_line line -start-insert<CR>
" nnoremap <leader>j :Unite -buffer-name=jump jump -start-insert<CR>
" " Custom mappings for the unite buffer
" autocmd FileType unite call s:unite_settings()
" function! s:unite_settings()
" setlocal nolist nopaste
" " Do the right thing on ESC
" nmap <buffer> <nowait> q <Plug>(unite_exit)
" imap <buffer> <nowait> q <Plug>(unite_exit)
" " <Tab> to go to next line
" imap <buffer> <TAB> <Plug>(unite_select_next_line)
" " refresh the cache
" nmap <buffer> <nowait> <F5> <Plug>(unite_redraw)
" imap <buffer> <nowait> <F5> <Plug>(unite_redraw)
" " change directories in unite
" nmap <buffer> <nowait> <leader>cd <Plug>(unite_restart)
" endfunction
" " Window config
" let g:unite_winheight = 10
" let g:unite_split_rule = 'topleft'
" Magic file open
" Currently VERY stupid
" Looks for first file with first matching directory
" Does not return if file not in first directory
" TODO:
" Integrate with Unite.vim to show list of matches
" Search for file in all possible subdirectories
" Add file formats / ignores
" Try adding second letters for matches
" Try adding _ as a possible separator
" Add a cache to make searching large codebases faster
" Package / Release this as a plugin
function! MagicFileOpen()
let chars = []
let nextChar = getchar()
while nextChar != 13
call add(chars, nr2char(nextChar))
let nextChar = getchar()
endwhile
let possible_path = "."
for char in chars
let current_path = possible_path
let matched_files = split(globpath(current_path, char . '*'), "\n")
for matched_file in matched_files
if isdirectory(matched_file) == 1
let possible_path = matched_file
break
endif
endfor
endfor
echo possible_path
let matches = split(globpath(possible_path, chars[-1] . '*'), "\n")
echo matches
if matches != []
silent! exe ':find ' . matches[0]
endif
endfunction
" command! MagicFile call MagicFileOpen()
" nnoremap e :MagicFile<CR>
" vim-mustache
let g:mustache_abbreviations = 1
" vim-session
let g:session_autoload="no"
let g:session_autosave="no"
" Search / replace preview
nnoremap <leader>/ :OverCommandLine<CR>
" Execute shell command and put result in split buffer
" Stolen from https://opensource.conformal.com/wiki/vim
function! s:ExecuteInShell(command, bang)
let _ = a:bang != '' ? s:_ : a:command == '' ? '' : join(map(split(a:command), 'expand(v:val)'))
if (_ != '')
let s:_ = _
let bufnr = bufnr('%')
let winnr = bufwinnr('^' . _ . '$')
silent! execute winnr < 0 ? 'new ' . fnameescape(_) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap
silent! :%d
let message = 'Execute ' . _ . '...'
call append(0, message)
echo message
silent! 2d | resize 1 | redraw
silent! execute 'silent! %!'. _
silent! execute 'resize ' . line('$')
silent! execute 'autocmd BufUnload <buffer> execute bufwinnr(' . bufnr . ') . ''wincmd w'''
silent! execute 'autocmd BufEnter <buffer> execute ''resize '' . line(''$'')'
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . _ . ''', '''')<CR>'
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>g :execute bufwinnr(' . bufnr . ') . ''wincmd w''<CR>'
endif
endfunction
command! -complete=shellcmd -nargs=* -bang Shell call s:ExecuteInShell(<q-args>, '<bang>')
cabbrev shell Shell
"nnoremap <leader><Space> :silent !grunt deploy:hf<CR>:redraw!<CR>
nnoremap <leader><Space> :!grunt deploy:hf<CR>